Java Code Examples for android.os.Bundle#putLongArray()
The following examples show how to use
android.os.Bundle#putLongArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomListDialog.java From SimpleDialogFragments with Apache License 2.0 | 6 votes |
@Override protected Bundle onResult(int which) { Bundle result = new Bundle(); ArrayList<Integer> checked = mAdapter.getCheckedItemOriginalPositions(); ArrayList<Long> checkedIds = mAdapter.getCheckedItemIds(); if (getArguments().getInt(CHOICE_MODE) != NO_CHOICE) { result.putIntegerArrayList(SELECTED_POSITIONS, checked); long[] checkedIdsArray = new long[checkedIds.size()]; for (int i = 0; i < checkedIdsArray.length; i++) { checkedIdsArray[i] = checkedIds.get(i); } result.putLongArray(SELECTED_IDS, checkedIdsArray); } if (getArguments().getInt(CHOICE_MODE) == SINGLE_CHOICE || getArguments().getInt(CHOICE_MODE) == SINGLE_CHOICE_DIRECT) { if (checked.size() >= 1){ result.putInt(SELECTED_SINGLE_POSITION, checked.get(0)); } if (checkedIds.size() >= 1){ result.putLong(SELECTED_SINGLE_ID, checkedIds.get(0)); } } return result; }
Example 2
Source File: KeyComboPreference.java From talkback with Apache License 2.0 | 6 votes |
@Override protected Parcelable onSaveInstanceState() { Bundle state = new Bundle(); Parcelable superState = super.onSaveInstanceState(); state.putParcelable(KEY_SUPER_STATE, superState); if (keyCombos != null) { // Store keyCombos in the bundle. long[] keyComboArray = new long[keyCombos.size()]; Iterator<Long> keyComboIterator = keyCombos.iterator(); for (int i = 0; i < keyCombos.size(); i++) { keyComboArray[i] = keyComboIterator.next(); } state.putLongArray(KEY_KEY_COMBOS, keyComboArray); } return state; }
Example 3
Source File: CustomListDialog.java From SimpleDialogFragments with Apache License 2.0 | 6 votes |
@Override protected Bundle onResult(int which) { Bundle result = new Bundle(); ArrayList<Integer> checked = mAdapter.getCheckedItemOriginalPositions(); ArrayList<Long> checkedIds = mAdapter.getCheckedItemIds(); if (getArguments().getInt(CHOICE_MODE) != NO_CHOICE) { result.putIntegerArrayList(SELECTED_POSITIONS, checked); long[] checkedIdsArray = new long[checkedIds.size()]; for (int i = 0; i < checkedIdsArray.length; i++) { checkedIdsArray[i] = checkedIds.get(i); } result.putLongArray(SELECTED_IDS, checkedIdsArray); } if (getArguments().getInt(CHOICE_MODE) == SINGLE_CHOICE || getArguments().getInt(CHOICE_MODE) == SINGLE_CHOICE_DIRECT) { if (checked.size() >= 1){ result.putInt(SELECTED_SINGLE_POSITION, checked.get(0)); } if (checkedIds.size() >= 1){ result.putLong(SELECTED_SINGLE_ID, checkedIds.get(0)); } } return result; }
Example 4
Source File: DirectShareService.java From Silence with GNU General Public License v3.0 | 5 votes |
@Override public List<ChooserTarget> onGetChooserTargets(ComponentName targetActivityName, IntentFilter matchedFilter) { List<ChooserTarget> results = new LinkedList<>(); MasterSecret masterSecret = KeyCachingService.getMasterSecret(this); if (masterSecret == null) { return results; } ComponentName componentName = new ComponentName(this, ShareActivity.class); ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(this); Cursor cursor = threadDatabase.getDirectShareList(); try { ThreadDatabase.Reader reader = threadDatabase.readerFor(cursor, new MasterCipher(masterSecret)); ThreadRecord record; while ((record = reader.getNext()) != null && results.size() < 10) { Recipients recipients = RecipientFactory.getRecipientsForIds(this, record.getRecipients().getIds(), false); String name = recipients.toShortString(); Drawable drawable = recipients.getContactPhoto().asDrawable(this, recipients.getColor().toConversationColor(this)); Bitmap avatar = BitmapUtil.createFromDrawable(drawable, 500, 500); Bundle bundle = new Bundle(); bundle.putLong(ShareActivity.EXTRA_THREAD_ID, record.getThreadId()); bundle.putLongArray(ShareActivity.EXTRA_RECIPIENT_IDS, recipients.getIds()); bundle.putInt(ShareActivity.EXTRA_DISTRIBUTION_TYPE, record.getDistributionType()); results.add(new ChooserTarget(name, Icon.createWithBitmap(avatar), 1.0f, componentName, bundle)); } return results; } finally { if (cursor != null) cursor.close(); } }
Example 5
Source File: StorageStrategy.java From FairEmail with GNU General Public License v3.0 | 5 votes |
@Override public @NonNull Bundle asBundle(@NonNull Selection<Long> selection) { Bundle bundle = new Bundle(); bundle.putString(SELECTION_KEY_TYPE, getKeyTypeName()); long[] value = new long[selection.size()]; int i = 0; for (Long key : selection) { value[i++] = key; } bundle.putLongArray(SELECTION_ENTRIES, value); return bundle; }
Example 6
Source File: OutlineListView.java From mOrgAnd with GNU General Public License v2.0 | 5 votes |
public void saveState(Bundle outState) { outState.putLongArray(OUTLINE_NODES, adapter.getNodeState()); outState.putIntegerArrayList(OUTLINE_LEVELS, adapter.getLevelState()); outState.putBooleanArray(OUTLINE_EXPANDED, adapter.getExpandedState()); outState.putInt(OUTLINE_CHECKED_POS, getCheckedItemPosition()); outState.putInt(OUTLINE_SCROLL_POS, getFirstVisiblePosition()); }
Example 7
Source File: WishlistDataAddMultiDialogFragment.java From MonsterHunter4UDatabase with MIT License | 5 votes |
public static WishlistDataAddMultiDialogFragment newInstance(long[] ids) { Bundle args = new Bundle(); args.putLongArray(ARG_WISHLIST_DATA_IDS, ids); WishlistDataAddMultiDialogFragment f = new WishlistDataAddMultiDialogFragment(); f.setArguments(args); return f; }
Example 8
Source File: ChatPagerAdapter.java From revolution-irc with GNU General Public License v3.0 | 5 votes |
public void onSaveInstanceState(Bundle outBundle) { String[] keys = new String[channelIds.size()]; long[] values = new long[channelIds.size()]; Iterator<Map.Entry<String, Long>> it = channelIds.entrySet().iterator(); int i = 0; while (it.hasNext()) { Map.Entry<String, Long> e = it.next(); keys[i] = e.getKey(); values[i] = e.getValue(); ++i; } outBundle.putStringArray("channel_ids_keys", keys); outBundle.putLongArray("channel_ids_values", values); }
Example 9
Source File: CommentsAdapter.java From cathode with Apache License 2.0 | 5 votes |
public Bundle saveState() { Bundle state = new Bundle(); long[] revealed = new long[revealedSpoilers.size()]; int i = 0; for (Long id : revealedSpoilers) { revealed[i++] = id; } state.putLongArray(STATE_REVEALED_SPOILERS, revealed); return state; }
Example 10
Source File: MediaPlayer.java From NetEasyNews with GNU General Public License v3.0 | 5 votes |
private void updateCacheStatus(int type, int info, long[] segments) { if (mEventHandler != null) { Message m = mEventHandler.obtainMessage(MEDIA_CACHING_UPDATE); Bundle b = m.getData(); b.putInt(MEDIA_CACHING_TYPE, type); b.putInt(MEDIA_CACHING_INFO, info); b.putLongArray(MEDIA_CACHING_SEGMENTS, segments); mEventHandler.sendMessage(m); } }
Example 11
Source File: MultiChoiceAdapterHelperBase.java From MultiChoiceAdapter with Apache License 2.0 | 5 votes |
public void save(Bundle outState) { long[] array = new long[checkedItems.size()]; int i = 0; for (Long id : checkedItems) { array[i++] = id; } outState.putLongArray(BUNDLE_KEY, array); }
Example 12
Source File: RecipientPreferenceActivity.java From Silence with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle instanceState, @NonNull MasterSecret masterSecret) { setContentView(R.layout.recipient_preference_activity); long[] recipientIds = getIntent().getLongArrayExtra(RECIPIENTS_EXTRA); Recipients recipients = RecipientFactory.getRecipientsForIds(this, recipientIds, true); initializeToolbar(); setHeader(recipients); recipients.addListener(this); Bundle bundle = new Bundle(); bundle.putLongArray(RECIPIENTS_EXTRA, recipientIds); initFragment(R.id.preference_fragment, new RecipientPreferenceFragment(), masterSecret, null, bundle); }
Example 13
Source File: PdfExportDialogFragment.java From geopaparazzi with GNU General Public License v3.0 | 5 votes |
/** * Create a dialog instance. * * @param exportPath an optional path to which to export the kmz to. If null, a default path is chosen. * @param exportIds the ids of the notes to be exported. * @return the instance. */ public static PdfExportDialogFragment newInstance(String exportPath, long[] exportIds) { PdfExportDialogFragment f = new PdfExportDialogFragment(); Bundle args = new Bundle(); args.putString(PDF_PATH, exportPath); args.putLongArray(EXPORTIDS, exportIds); f.setArguments(args); return f; }
Example 14
Source File: MediaPlayer.java From video-player with MIT License | 5 votes |
private void updateCacheStatus(int type, int info, long[] segments) { if (mEventHandler != null) { Message m = mEventHandler.obtainMessage(MEDIA_CACHING_UPDATE); Bundle b = m.getData(); b.putInt(MEDIA_CACHING_TYPE, type); b.putInt(MEDIA_CACHING_INFO, info); b.putLongArray(MEDIA_CACHING_SEGMENTS, segments); mEventHandler.sendMessage(m); } }
Example 15
Source File: AbstractSpec.java From DeviceConnect-Android with MIT License | 5 votes |
/** * ベンダー拡張を Bundle に格納します. * * @param bundle ベンダー拡張を格納するBundle */ @SuppressWarnings("unchecked") protected void copyVendorExtensions(Bundle bundle) { if (mVendorExtensions != null && !mVendorExtensions.isEmpty()) { for (String key : mVendorExtensions.keySet()) { Object object = mVendorExtensions.get(key); if (object instanceof Integer) { bundle.putInt(key, (Integer) object); } else if (object instanceof int[]) { bundle.putIntArray(key, (int[]) object); } else if (object instanceof Long) { bundle.putLong(key, (Long) object); } else if (object instanceof long[]) { bundle.putLongArray(key, (long[]) object); } else if (object instanceof Short) { bundle.putShort(key, (Short) object); } else if (object instanceof short[]) { bundle.putShortArray(key, (short[]) object); } else if (object instanceof Byte) { bundle.putByte(key, (Byte) object); } else if (object instanceof byte[]) { bundle.putByteArray(key, (byte[]) object); } else if (object instanceof Boolean) { bundle.putBoolean(key, (Boolean) object); } else if (object instanceof String) { bundle.putString(key, (String) object); } else if (object instanceof String[]) { bundle.putStringArray(key, (String[]) object); } else if (object instanceof Bundle) { bundle.putParcelable(key, (Bundle) object); } else if (object instanceof ArrayList) { bundle.putParcelableArrayList(key, (ArrayList) object); } } } }
Example 16
Source File: MediaPlayer.java From BambooPlayer with Apache License 2.0 | 5 votes |
private void updateCacheStatus(int type, int info, long[] segments) { if (mEventHandler != null) { Message m = mEventHandler.obtainMessage(MEDIA_CACHING_UPDATE); Bundle b = m.getData(); b.putInt(MEDIA_CACHING_TYPE, type); b.putInt(MEDIA_CACHING_INFO, info); b.putLongArray(MEDIA_CACHING_SEGMENTS, segments); mEventHandler.sendMessage(m); } }
Example 17
Source File: DataMap.java From android_external_GmsLib with Apache License 2.0 | 4 votes |
public Bundle toBundle() { Bundle bundle = new Bundle(); for (String key : data.keySet()) { switch (types.get(key)) { case Asset: bundle.putParcelable(key, (Asset) data.get(key)); break; case Boolean: bundle.putBoolean(key, (Boolean) data.get(key)); break; case Byte: bundle.putByte(key, (Byte) data.get(key)); break; case ByteArray: bundle.putByteArray(key, (byte[]) data.get(key)); break; case DataMap: bundle.putBundle(key, ((DataMap) data.get(key)).toBundle()); break; case DataMapArrayList: ArrayList<Bundle> bundles = new ArrayList<Bundle>(); for (DataMap dataMap : ((ArrayList<DataMap>) data.get(key))) { bundles.add(dataMap.toBundle()); } bundle.putParcelableArrayList(key, bundles); break; case Double: bundle.putDouble(key, (Double) data.get(key)); break; case Float: bundle.putFloat(key, (Float) data.get(key)); break; case FloatArray: bundle.putFloatArray(key, (float[]) data.get(key)); break; case Integer: bundle.putInt(key, (Integer) data.get(key)); break; case IntegerArrayList: bundle.putIntegerArrayList(key, (ArrayList<Integer>) data.get(key)); break; case Long: bundle.putLong(key, (Long) data.get(key)); break; case LongArray: bundle.putLongArray(key, (long[]) data.get(key)); break; case String: bundle.putString(key, (String) data.get(key)); break; case StringArray: bundle.putStringArray(key, (String[]) data.get(key)); break; case StringArrayList: bundle.putStringArrayList(key, (ArrayList<String>) data.get(key)); break; } } return bundle; }
Example 18
Source File: MainActivity.java From MRouter with Apache License 2.0 | 4 votes |
public Bundle assembleBundle() { User user = new User(); user.setAge(90); user.setGender(1); user.setName("kitty"); Address address = new Address(); address.setCity("HangZhou"); address.setProvince("ZheJiang"); Bundle extras = new Bundle(); extras.putString("extra", "from extras"); ArrayList<String> stringList = new ArrayList<>(); stringList.add("Java"); stringList.add("C#"); stringList.add("Kotlin"); ArrayList<String> stringArrayList = new ArrayList<>(); stringArrayList.add("American"); stringArrayList.add("China"); stringArrayList.add("England"); ArrayList<Integer> intArrayList = new ArrayList<>(); intArrayList.add(100); intArrayList.add(101); intArrayList.add(102); ArrayList<Integer> intList = new ArrayList<>(); intList.add(10011); intList.add(10111); intList.add(10211); ArrayList<Address> addressList = new ArrayList<>(); addressList.add(new Address("JiangXi", "ShangRao", null)); addressList.add(new Address("ZheJiang", "NingBo", null)); Address[] addressArray = new Address[]{ new Address("Beijing", "Beijing", null), new Address("Shanghai", "Shanghai", null), new Address("Guangzhou", "Guangzhou", null) }; Bundle bundle = new Bundle(); bundle.putSerializable("user", user); bundle.putParcelable("address", address); bundle.putParcelableArrayList("addressList", addressList); bundle.putParcelableArray("addressArray", addressArray); bundle.putString("param", "chiclaim"); bundle.putStringArray("stringArray", new String[]{"a", "b", "c"}); bundle.putStringArrayList("stringArrayList", stringList); bundle.putStringArrayList("stringList", stringArrayList); bundle.putByte("byte", (byte) 2); bundle.putByteArray("byteArray", new byte[]{1, 2, 3, 4, 5}); bundle.putInt("age", 33); bundle.putIntArray("intArray", new int[]{10, 11, 12, 13}); bundle.putIntegerArrayList("intList", intList); bundle.putIntegerArrayList("intArrayList", intArrayList); bundle.putChar("chara", 'c'); bundle.putCharArray("charArray", "chiclaim".toCharArray()); bundle.putShort("short", (short) 1000000); bundle.putShortArray("shortArray", new short[]{(short) 10.9, (short) 11.9}); bundle.putDouble("double", 1200000); bundle.putDoubleArray("doubleArray", new double[]{1232, 9999, 8789, 3.1415926}); bundle.putLong("long", 999999999); bundle.putLongArray("longArray", new long[]{1000, 2000, 3000}); bundle.putFloat("float", 333); bundle.putFloatArray("floatArray", new float[]{12.9f, 234.9f}); bundle.putBoolean("boolean", true); bundle.putBooleanArray("booleanArray", new boolean[]{true, false, true}); return bundle; }
Example 19
Source File: LongArrayCoder.java From lyra with Apache License 2.0 | 2 votes |
/** * Write a field's value into the saved state {@link Bundle}. * * @param state {@link Bundle} used to save the state * @param key key retrieved from {@code fieldDeclaringClass#fieldName} * @param fieldValue value of field */ @Override public void serialize(@NonNull Bundle state, @NonNull String key, @NonNull long[] fieldValue) { state.putLongArray(key, fieldValue); }
Example 20
Source File: MultiSelectionUtil.java From FireFiles with Apache License 2.0 | 2 votes |
/** * This method should be called from * {@link AppCompatActivity#onSaveInstanceState(android.os.Bundle)} or * {@link android.support.v4.app.Fragment#onSaveInstanceState(android.os.Bundle) * Fragment.onSaveInstanceState(Bundle)} to allow the controller to save its instance * state. * * @param outState - The state passed to your Activity or Fragment. */ public void saveInstanceState(Bundle outState) { if (mActionMode != null && mListView.getAdapter().hasStableIds()) { outState.putLongArray(getStateKey(), mListView.getCheckedItemIds()); } }