android.os.Bundle#putLongArray ( )源码实例Demo

下面列出了android.os.Bundle#putLongArray ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SimpleDialogFragments   文件: CustomListDialog.java
@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;
}
 
源代码2 项目: talkback   文件: KeyComboPreference.java
@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;
}
 
源代码3 项目: SimpleDialogFragments   文件: CustomListDialog.java
@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;
}
 
源代码4 项目: FairEmail   文件: StorageStrategy.java
@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;
}
 
源代码5 项目: BambooPlayer   文件: MediaPlayer.java
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);
  }
}
 
源代码6 项目: DeviceConnect-Android   文件: AbstractSpec.java
/**
 * ベンダー拡張を 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);
            }
        }
    }
}
 
源代码7 项目: video-player   文件: MediaPlayer.java
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);
  }
}
 
源代码8 项目: geopaparazzi   文件: PdfExportDialogFragment.java
/**
 * 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;
}
 
源代码9 项目: Silence   文件: RecipientPreferenceActivity.java
@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);
}
 
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);
}
 
源代码11 项目: NetEasyNews   文件: MediaPlayer.java
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);
  }
}
 
源代码12 项目: cathode   文件: CommentsAdapter.java
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;
}
 
源代码13 项目: revolution-irc   文件: ChatPagerAdapter.java
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);
}
 
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;
}
 
源代码15 项目: mOrgAnd   文件: OutlineListView.java
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());
}
 
源代码16 项目: Silence   文件: DirectShareService.java
@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();
  }
}
 
源代码17 项目: android_external_GmsLib   文件: DataMap.java
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;
}
 
源代码18 项目: MRouter   文件: MainActivity.java
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;
}
 
源代码19 项目: lyra   文件: LongArrayCoder.java
/**
 * 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);
}
 
源代码20 项目: FireFiles   文件: MultiSelectionUtil.java
/**
 * 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());
    }
}