List of usage examples for android.os Bundle putLongArray
public void putLongArray(@Nullable String key, @Nullable long[] value)
From source file:com.wirelessmoves.cl.MainActivity.java
@Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); /* save variables */ savedInstanceState.putLong("NumberOfSignalStrengthUpdates", NumberOfSignalStrengthUpdates); savedInstanceState.putLong("LastCellId", LastCellId); savedInstanceState.putLong("NumberOfCellChanges", NumberOfCellChanges); savedInstanceState.putLong("LastLacId", LastLacId); savedInstanceState.putLong("NumberOfLacChanges", NumberOfLacChanges); savedInstanceState.putLongArray("PreviousCells", PreviousCells); savedInstanceState.putInt("PreviousCellsIndex", PreviousCellsIndex); savedInstanceState.putLong("NumberOfUniqueCellChanges", NumberOfUniqueCellChanges); savedInstanceState.putBoolean("outputDebugInfo", outputDebugInfo); savedInstanceState.putDouble("CurrentLocationLong", CurrentLocationLong); savedInstanceState.putDouble("CurrentLocationLat", CurrentLocationLat); /* save the trace data still in the write buffer into a file */ saveDataToFile(FileWriteBufferStr,/* w w w . ja v a 2 s . c o m*/ "---in save instance, " + DateFormat.getTimeInstance().format(new Date()) + "\r\n"); FileWriteBufferStr = ""; }
From source file:ru.moscow.tuzlukov.sergey.weatherlog.MainActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); List<Long> baseLongList = new ArrayList<>(temperatureMap.keySet()); List<Double> baseDoubleList = new ArrayList<>(temperatureMap.values()); long[] timeArray = new long[baseLongList.size()]; double[] tempArray = new double[baseDoubleList.size()]; for (int i = 0; i < temperatureMap.size(); i++) { timeArray[i] = baseLongList.get(i); tempArray[i] = baseDoubleList.get(i); }/*from w w w . j a v a2 s . c om*/ outState.putLong(SAVED_CURRENT_TIME, currentTime); outState.putLong(SAVED_CURRENT_TIME_MINUS_12, currentTimeMinus12h); outState.putLong(SAVED_CURRENT_TIME_MINUS_24, currentTimeMinus24h); outState.putLongArray(SAVED_TIME_ARRAY, timeArray); outState.putDoubleArray(SAVED_TEMP_ARRAY, tempArray); outState.putBoolean(SAVED_CURRENT_GAINED, currentIsGained); outState.putBoolean(SAVED_HISTORY_GAINED, historyIsGained); outState.putBoolean(SAVED_LOADER_VISIBILITY, llLoader.getVisibility() == View.VISIBLE); outState.putString(SAVED_DIALOG_APPID, registerDialog.getEtAppId().getText().toString()); outState.putBoolean(SAVED_DIALOG_VISIBILITY, registerDialog.isVisible()); }
From source file:com.android.mail.ui.AnimatedAdapter.java
public void onSaveInstanceState(Bundle outState) { long[] lastDeleting = new long[mLastDeletingItems.size()]; for (int i = 0; i < lastDeleting.length; i++) { lastDeleting[i] = mLastDeletingItems.get(i); }//from ww w. ja v a2 s. c o m outState.putLongArray(LAST_DELETING_ITEMS, lastDeleting); if (hasLeaveBehinds()) { if (mLastLeaveBehind != -1) { outState.putParcelable(LEAVE_BEHIND_ITEM_DATA, mLeaveBehindItems.get(mLastLeaveBehind).getLeaveBehindData()); outState.putLong(LEAVE_BEHIND_ITEM_ID, mLastLeaveBehind); } for (LeaveBehindItem item : mLeaveBehindItems.values()) { if (mLastLeaveBehind == -1 || item.getData().id != mLastLeaveBehind) { item.commit(); } } } }
From source file:nuclei.task.TaskScheduler.java
private void onSchedulePreL(Context context) { Task.Builder builder;/*from ww w .ja v a2s . co m*/ switch (mBuilder.mTaskType) { case TASK_ONE_OFF: OneoffTask.Builder oneOffBuilder = new OneoffTask.Builder(); builder = oneOffBuilder; if (mBuilder.mWindowStartDelaySecondsSet || mBuilder.mWindowEndDelaySecondsSet) oneOffBuilder.setExecutionWindow(mBuilder.mWindowStartDelaySeconds, mBuilder.mWindowEndDelaySeconds); break; case TASK_PERIODIC: builder = new PeriodicTask.Builder().setFlex(mBuilder.mFlexInSeconds) .setPeriod(mBuilder.mPeriodInSeconds); break; default: throw new IllegalArgumentException(); } ArrayMap<String, Object> map = new ArrayMap<>(); mBuilder.mTask.serialize(map); Bundle extras = new Bundle(); for (Map.Entry<String, Object> entry : map.entrySet()) { Object v = entry.getValue(); if (v == null) continue; if (v instanceof Integer) extras.putInt(entry.getKey(), (int) v); else if (v instanceof Double) extras.putDouble(entry.getKey(), (double) v); else if (v instanceof Long) extras.putLong(entry.getKey(), (long) v); else if (v instanceof String) extras.putString(entry.getKey(), (String) v); else if (v instanceof String[]) extras.putStringArray(entry.getKey(), (String[]) v); else if (v instanceof boolean[]) extras.putBooleanArray(entry.getKey(), (boolean[]) v); else if (v instanceof double[]) extras.putDoubleArray(entry.getKey(), (double[]) v); else if (v instanceof long[]) extras.putLongArray(entry.getKey(), (long[]) v); else if (v instanceof int[]) extras.putIntArray(entry.getKey(), (int[]) v); else if (v instanceof Parcelable) extras.putParcelable(entry.getKey(), (Parcelable) v); else if (v instanceof Serializable) extras.putSerializable(entry.getKey(), (Serializable) v); else throw new IllegalArgumentException("Invalid Type: " + entry.getKey()); } extras.putString(TASK_NAME, mBuilder.mTask.getClass().getName()); builder.setExtras(extras).setPersisted(mBuilder.mPersisted).setRequiresCharging(mBuilder.mRequiresCharging) .setService(TaskGcmService.class).setTag(mBuilder.mTask.getTaskTag()) .setUpdateCurrent(mBuilder.mUpdateCurrent); switch (mBuilder.mNetworkState) { case NETWORK_STATE_ANY: builder.setRequiredNetwork(Task.NETWORK_STATE_ANY); break; case NETWORK_STATE_CONNECTED: builder.setRequiredNetwork(Task.NETWORK_STATE_CONNECTED); break; case NETWORK_STATE_UNMETERED: builder.setRequiredNetwork(Task.NETWORK_STATE_UNMETERED); break; } GcmNetworkManager.getInstance(context).schedule(builder.build()); }
From source file:org.totschnig.myexpenses.fragment.CategoryList.java
@Override public boolean dispatchCommandMultiple(int command, SparseBooleanArray positions, Long[] itemIds) { ManageCategories ctx = (ManageCategories) getActivity(); ArrayList<Long> idList; switch (command) { case R.id.DELETE_COMMAND: int mappedTransactionsCount = 0, mappedTemplatesCount = 0, hasChildrenCount = 0; idList = new ArrayList<>(); for (int i = 0; i < positions.size(); i++) { Cursor c;/*from www . ja v a 2 s . com*/ if (positions.valueAt(i)) { boolean deletable = true; int position = positions.keyAt(i); long pos = mListView.getExpandableListPosition(position); int type = ExpandableListView.getPackedPositionType(pos); int group = ExpandableListView.getPackedPositionGroup(pos), child = ExpandableListView.getPackedPositionChild(pos); if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { c = mAdapter.getChild(group, child); c.moveToPosition(child); } else { c = mGroupCursor; c.moveToPosition(group); } long itemId = c.getLong(c.getColumnIndex(KEY_ROWID)); Bundle extras = ctx.getIntent().getExtras(); if ((extras != null && extras.getLong(KEY_ROWID) == itemId) || c.getInt(c.getColumnIndex(DatabaseConstants.KEY_MAPPED_TRANSACTIONS)) > 0) { mappedTransactionsCount++; deletable = false; } else if (c.getInt(c.getColumnIndex(DatabaseConstants.KEY_MAPPED_TEMPLATES)) > 0) { mappedTemplatesCount++; deletable = false; } if (deletable) { if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP && c.getInt(c.getColumnIndex(KEY_CHILD_COUNT)) > 0) { hasChildrenCount++; } idList.add(itemId); } } } if (!idList.isEmpty()) { Long[] objectIds = idList.toArray(new Long[idList.size()]); if (hasChildrenCount > 0) { MessageDialogFragment .newInstance(R.string.dialog_title_warning_delete_main_category, getResources().getQuantityString(R.plurals.warning_delete_main_category, hasChildrenCount, hasChildrenCount), new MessageDialogFragment.Button(android.R.string.yes, R.id.DELETE_COMMAND_DO, objectIds), null, new MessageDialogFragment.Button(android.R.string.no, R.id.CANCEL_CALLBACK_COMMAND, null)) .show(ctx.getSupportFragmentManager(), "DELETE_CATEGORY"); } else { ctx.dispatchCommand(R.id.DELETE_COMMAND_DO, objectIds); } } if (mappedTransactionsCount > 0 || mappedTemplatesCount > 0) { String message = ""; if (mappedTransactionsCount > 0) message += getResources().getQuantityString(R.plurals.not_deletable_mapped_transactions, mappedTransactionsCount, mappedTransactionsCount); if (mappedTemplatesCount > 0) message += getResources().getQuantityString(R.plurals.not_deletable_mapped_templates, mappedTemplatesCount, mappedTemplatesCount); Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show(); } return true; case R.id.SELECT_COMMAND_MULTIPLE: ArrayList<String> labelList = new ArrayList<>(); for (int i = 0; i < positions.size(); i++) { Cursor c; if (positions.valueAt(i)) { int position = positions.keyAt(i); long pos = mListView.getExpandableListPosition(position); int type = ExpandableListView.getPackedPositionType(pos); int group = ExpandableListView.getPackedPositionGroup(pos), child = ExpandableListView.getPackedPositionChild(pos); if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { c = mAdapter.getChild(group, child); c.moveToPosition(child); } else { c = mGroupCursor; c.moveToPosition(group); } labelList.add(c.getString(c.getColumnIndex(KEY_LABEL))); } } Intent intent = new Intent(); intent.putExtra(KEY_CATID, ArrayUtils.toPrimitive(itemIds)); intent.putExtra(KEY_LABEL, TextUtils.join(",", labelList)); ctx.setResult(ManageCategories.RESULT_FIRST_USER, intent); ctx.finish(); return true; case R.id.MOVE_COMMAND: final Long[] excludedIds; final boolean inGroup = expandableListSelectionType == ExpandableListView.PACKED_POSITION_TYPE_GROUP; if (inGroup) { excludedIds = itemIds; } else { idList = new ArrayList<>(); for (int i = 0; i < positions.size(); i++) { if (positions.valueAt(i)) { int position = positions.keyAt(i); long pos = mListView.getExpandableListPosition(position); int group = ExpandableListView.getPackedPositionGroup(pos); mGroupCursor.moveToPosition(group); idList.add(mGroupCursor.getLong(mGroupCursor.getColumnIndex(KEY_ROWID))); } } excludedIds = idList.toArray(new Long[idList.size()]); } Bundle args = new Bundle(3); args.putBoolean(SelectMainCategoryDialogFragment.KEY_WITH_ROOT, !inGroup); args.putLongArray(SelectMainCategoryDialogFragment.KEY_EXCLUDED_ID, ArrayUtils.toPrimitive(excludedIds)); args.putLongArray(TaskExecutionFragment.KEY_OBJECT_IDS, ArrayUtils.toPrimitive(itemIds)); SelectMainCategoryDialogFragment.newInstance(args).show(getFragmentManager(), "SELECT_TARGET"); return true; } return false; }
From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java
@Override public void onSaveInstanceState(final Bundle outState) { outState.putLongArray(EXTRA_ACCOUNT_IDS, mSendAccountIds); outState.putParcelableArrayList(EXTRA_MEDIAS, new ArrayList<Parcelable>(getMediasList())); outState.putBoolean(EXTRA_IS_POSSIBLY_SENSITIVE, mIsPossiblySensitive); outState.putParcelable(EXTRA_STATUS, mInReplyToStatus); outState.putLong(EXTRA_STATUS_ID, mInReplyToStatusId); outState.putParcelable(EXTRA_USER, mMentionUser); outState.putParcelable(EXTRA_DRAFT, mDraftItem); outState.putBoolean(EXTRA_SHOULD_SAVE_ACCOUNTS, mShouldSaveAccounts); outState.putString(EXTRA_ORIGINAL_TEXT, mOriginalText); outState.putParcelable(EXTRA_TEMP_URI, mTempPhotoUri); super.onSaveInstanceState(outState); }
From source file:org.sufficientlysecure.keychain.ui.EncryptFileActivity.java
private Bundle createEncryptBundle() { // fill values for this action Bundle data = new Bundle(); data.putInt(KeychainIntentService.SOURCE, KeychainIntentService.IO_URIS); data.putParcelableArrayList(KeychainIntentService.ENCRYPT_INPUT_URIS, mInputUris); data.putInt(KeychainIntentService.TARGET, KeychainIntentService.IO_URIS); data.putParcelableArrayList(KeychainIntentService.ENCRYPT_OUTPUT_URIS, mOutputUris); data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, Preferences.getPreferences(this).getDefaultFileCompression()); // Always use armor for messages data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, mUseArmor); if (isModeSymmetric()) { Log.d(Constants.TAG, "Symmetric encryption enabled!"); String passphrase = mPassphrase; if (passphrase.length() == 0) { passphrase = null;/*from w ww .j av a2s . co m*/ } data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase); } else { data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_MASTER_ID, mSigningKeyId); data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptionKeyIds); } return data; }
From source file:org.getlantern.firetweet.activity.support.ComposeActivity.java
@Override public void onSaveInstanceState(final Bundle outState) { outState.putLongArray(EXTRA_ACCOUNT_IDS, mAccountsAdapter.getSelectedAccountIds()); outState.putParcelableArrayList(EXTRA_MEDIA, new ArrayList<Parcelable>(getMediaList())); outState.putBoolean(EXTRA_IS_POSSIBLY_SENSITIVE, mIsPossiblySensitive); outState.putParcelable(EXTRA_STATUS, mInReplyToStatus); outState.putLong(EXTRA_STATUS_ID, mInReplyToStatusId); outState.putParcelable(EXTRA_USER, mMentionUser); outState.putParcelable(EXTRA_DRAFT, mDraftItem); outState.putBoolean(EXTRA_SHOULD_SAVE_ACCOUNTS, mShouldSaveAccounts); outState.putString(EXTRA_ORIGINAL_TEXT, mOriginalText); outState.putParcelable(EXTRA_TEMP_URI, mTempPhotoUri); super.onSaveInstanceState(outState); }
From source file:me.xiaopan.android.inject.sample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); listView = new ListView(getBaseContext()); setContentView(listView);/*w ww .j a v a2s.c o m*/ // SharedPreferences? PreferenceUtils.putBoolean(getBaseContext(), KEY_BOOLEAN, true); PreferenceUtils.putFloat(getBaseContext(), KEY_FLOAT, 10000f); PreferenceUtils.putInt(getBaseContext(), KEY_INT, 2000); PreferenceUtils.putLong(getBaseContext(), KEY_LONG, 50000); PreferenceUtils.putString(getBaseContext(), KEY_STRING, "Preference String"); Set<String> stringSet = new HashSet<String>(); stringSet.add("String Set 1"); stringSet.add("String Set 2"); stringSet.add("String Set 3"); stringSet.add("String Set 4"); PreferenceUtils.putStringSet(getBaseContext(), KEY_STRING_SET, stringSet); MyBean bean2 = new MyBean(); bean2.setEmail("sky@xiaopan.me2"); bean2.setName("?2"); bean2.setSex("2"); PreferenceUtils.putObject(getBaseContext(), KEY_JSON, bean2); PreferenceUtils.putString(getBaseContext(), KEY_ENUM, Sex.WOMAN.name()); // ?? String[] items = new String[] { "", "?", "FragmentDialog", "InjectAdapter", "InjectExpandableListAdapter" }; listView.setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1, android.R.id.text1, items)); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position <= 2) { Bundle bundle = new Bundle(); bundle.putBoolean(MainActivity.PARAM_BOOLEAN, true); bundle.putBooleanArray(MainActivity.PARAM_BOOLEAN_ARRAY, new boolean[] { true, false, true }); bundle.putByte(MainActivity.PARAM_BYTE, (byte) 110); bundle.putByteArray(MainActivity.PARAM_BYTE_ARRAY, new byte[] { 111, 112, 113 }); bundle.putChar(MainActivity.PARAM_CHAR, 'R'); bundle.putCharArray(MainActivity.PARAM_CHAR_ARRAY, new char[] { 'c', 'h', 'a', 'r' }); bundle.putCharSequence(MainActivity.PARAM_CHAR_SEQUENCE, "CharSequence"); bundle.putCharSequenceArray(MainActivity.PARAM_CHAR_SEQUENCE_ARRAY, new CharSequence[] { "Char", " ", "Sequence" }); bundle.putDouble(MainActivity.PARAM_DOUBLE, 12.00d); bundle.putDoubleArray(MainActivity.PARAM_DOUBLE_ARRAY, new double[] { 12.01d, 12.02d, 12.03d }); bundle.putFloat(MainActivity.PARAM_FLOAT, 13.00f); bundle.putFloatArray(MainActivity.PARAM_FLOAT_ARRAY, new float[] { 13.01f, 13.02f, 13.03f }); bundle.putInt(MainActivity.PARAM_INT, 120); bundle.putIntArray(MainActivity.PARAM_INT_ARRAY, new int[] { 121, 122, 123, }); bundle.putLong(MainActivity.PARAM_LONG, 12345); bundle.putLongArray(MainActivity.PARAM_LONG_ARRAY, new long[] { 12346, 12347, 12348 }); bundle.putShort(MainActivity.PARAM_SHORT, (short) 2); bundle.putShortArray(MainActivity.PARAM_SHORT_ARRAY, new short[] { 3, 4, 5 }); bundle.putString(MainActivity.PARAM_STRING, "String"); bundle.putStringArray(MainActivity.PARAM_STRING_ARRAY, new String[] { "String1", "String2", "String3" }); // ??JSONBundle MyBean bean = new MyBean(); bean.setEmail("sky@xiaopan.me"); bean.setName("?"); bean.setSex(""); bundle.putString(PARAM_STRING_JSON, new Gson().toJson(bean)); bundle.putString(MainActivity.PARAM_STRING_ENUM, Sex.WOMAN.name()); // ArrayList<String> stringList = new ArrayList<String>(); stringList.add("ArrayList String 1"); stringList.add("ArrayList String 2"); stringList.add("ArrayList String 3"); bundle.putStringArrayList(MainActivity.PARAM_STRING_ARRAY_LIST, stringList); switch (position) { case 0: Second.SECOND_CHRONOGRAPH.lap(); Intent intent = new Intent(getBaseContext(), InjectTestActivity.class); intent.putExtras(bundle); startActivity(intent); break; case 1: Second.SECOND_CHRONOGRAPH.lap(); Intent intent2 = new Intent(getBaseContext(), NormalActivity.class); intent2.putExtras(bundle); startActivity(intent2); break; case 2: Second.SECOND_CHRONOGRAPH.lap(); new TestDialogFragment().show(getSupportFragmentManager(), ""); break; } } else { Class<?> targetClass = null; if (position == 3) { targetClass = InjectAdapterActivity.class; } else if (position == 4) { targetClass = InjectExpandableListAdapterActivity.class; } if (targetClass != null) { startActivity(new Intent(getBaseContext(), targetClass)); } } } }); }
From source file:org.totschnig.myexpenses.fragment.TransactionList.java
@Override public boolean dispatchCommandMultiple(int command, SparseBooleanArray positions, Long[] itemIds) { MyExpenses ctx = (MyExpenses) getActivity(); FragmentManager fm = ctx.getSupportFragmentManager(); switch (command) { case R.id.DELETE_COMMAND: boolean hasReconciled = false, hasNotVoid = false; for (int i = 0; i < positions.size(); i++) { if (positions.valueAt(i)) { mTransactionsCursor.moveToPosition(positions.keyAt(i)); CrStatus status;//www .j a v a 2s.co m try { status = CrStatus.valueOf(mTransactionsCursor.getString(columnIndexCrStatus)); } catch (IllegalArgumentException ex) { status = CrStatus.UNRECONCILED; } if (status == CrStatus.RECONCILED) { hasReconciled = true; } if (status != CrStatus.VOID) { hasNotVoid = true; } if (hasNotVoid && hasReconciled) break; } } String message = getResources().getQuantityString(R.plurals.warning_delete_transaction, itemIds.length, itemIds.length); if (hasReconciled) { message += " " + getString(R.string.warning_delete_reconciled); } Bundle b = new Bundle(); b.putInt(ConfirmationDialogFragment.KEY_TITLE, R.string.dialog_title_warning_delete_transaction); b.putString(ConfirmationDialogFragment.KEY_MESSAGE, message); b.putInt(ConfirmationDialogFragment.KEY_COMMAND_POSITIVE, R.id.DELETE_COMMAND_DO); b.putInt(ConfirmationDialogFragment.KEY_COMMAND_NEGATIVE, R.id.CANCEL_CALLBACK_COMMAND); b.putInt(ConfirmationDialogFragment.KEY_POSITIVE_BUTTON_LABEL, R.string.menu_delete); if (hasNotVoid) { b.putInt(ConfirmationDialogFragment.KEY_CHECKBOX_LABEL, R.string.mark_void_instead_of_delete); } b.putLongArray(TaskExecutionFragment.KEY_OBJECT_IDS, ArrayUtils.toPrimitive(itemIds)); ConfirmationDialogFragment.newInstance(b).show(getFragmentManager(), "DELETE_TRANSACTION"); return true; /* case R.id.CLONE_TRANSACTION_COMMAND: ctx.startTaskExecution( TaskExecutionFragment.TASK_CLONE, itemIds, null, 0); break;*/ case R.id.SPLIT_TRANSACTION_COMMAND: ctx.contribFeatureRequested(ContribFeature.SPLIT_TRANSACTION, itemIds); break; case R.id.UNDELETE_COMMAND: ctx.startTaskExecution(TaskExecutionFragment.TASK_UNDELETE_TRANSACTION, itemIds, null, 0); break; //super is handling deactivation of mActionMode } return super.dispatchCommandMultiple(command, positions, itemIds); }