Java Code Examples for android.os.Bundle.putLongArray()

The following are Jave code examples for showing how to use putLongArray() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: aliyun-cloudphotos-android-demo   File: MoveActivity.java   View Source Code Vote up 6 votes
public static void launch(Context context, FragmentType what, Long sourceId, List<Long> ids) {
    Intent i = new Intent(context, MoveActivity.class);
    Bundle bundle = new Bundle();
    bundle.putInt("what", what.ordinal());
    bundle.putLong("sourceId", sourceId);
    long[] array = new long[ids.size()];
    int idx = 0;
    for (Long id : ids) {
        array[idx] = id;
        ++ idx;
    }

    bundle.putLongArray("ids", array);
    i.putExtras(bundle);
    context.startActivity(i);
}
 
Example 2
Project: orgzly-android   File: TimestampDialogFragment.java   View Source Code Vote up 6 votes
public static TimestampDialogFragment getInstance(int id, int title, TreeSet<Long> noteIds, OrgDateTime time) {
    TimestampDialogFragment fragment = new TimestampDialogFragment();

    /* Set arguments for fragment. */
    Bundle bundle = new Bundle();

    bundle.putInt(ARG_DIALOG_ID, id);
    bundle.putInt(ARG_TITLE, title);
    bundle.putLongArray(ARG_NOTE_IDS, toArray(noteIds));

    if (time != null) {
        bundle.putString(ARG_TIME, time.toString());
    }

    fragment.setArguments(bundle);

    return fragment;
}
 
Example 3
Project: Cable-Android   File: RecipientPreferenceActivity.java   View Source Code Vote up 6 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();
  initializeReceivers();
  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 4
Project: PeSanKita-android   File: RecipientPreferenceActivity.java   View Source Code Vote up 6 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();
  initializeReceivers();
  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 5
Project: q-mail   File: MessageListFragment.java   View Source Code Vote up 5 votes
/**
 * Write the unique IDs of selected messages to a {@link Bundle}.
 */
private void saveSelectedMessages(Bundle outState) {
    long[] selected = new long[this.selected.size()];
    int i = 0;
    for (Long id : this.selected) {
        selected[i++] = id;
    }
    outState.putLongArray(STATE_SELECTED_MESSAGES, selected);
}
 
Example 6
Project: CSipSimple   File: CallLogListFragment.java   View Source Code Vote up 5 votes
@Override
public void viewDetails(int position, long[] callIds) {
    ListView lv = getListView();
    if(mMode != null) {
        lv.setItemChecked(position, !lv.isItemChecked(position));
        mMode.invalidate();
        // Don't see details in this case
        return;
    }
    
    if (mDualPane) {
        // If we are not currently showing a fragment for the new
        // position, we need to create and install a new one.
        CallLogDetailsFragment df = new CallLogDetailsFragment();
        Bundle bundle = new Bundle();
        bundle.putLongArray(CallLogDetailsFragment.EXTRA_CALL_LOG_IDS, callIds);
        df.setArguments(bundle);
        // Execute a transaction, replacing any existing fragment
        // with this one inside the frame.
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.details, df, null);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.commit();

        getListView().setItemChecked(position, true);
    } else {
        Intent it = new Intent(getActivity(), CallLogDetailsActivity.class);
        it.putExtra(CallLogDetailsFragment.EXTRA_CALL_LOG_IDS, callIds);
        getActivity().startActivity(it);
    }
}
 
Example 7
Project: Quran   File: TagBookmarkDialog.java   View Source Code Vote up 5 votes
public static TagBookmarkDialog newInstance(long[] bookmarkIds) {
  final Bundle args = new Bundle();
  args.putLongArray(EXTRA_BOOKMARK_IDS, bookmarkIds);
  final TagBookmarkDialog dialog = new TagBookmarkDialog();
  dialog.setArguments(args);
  return dialog;
}
 
Example 8
Project: Hello-Music-droid   File: CreatePlaylistDialog.java   View Source Code Vote up 5 votes
public static CreatePlaylistDialog newInstance(long[] songList) {
    CreatePlaylistDialog dialog = new CreatePlaylistDialog();
    Bundle bundle = new Bundle();
    bundle.putLongArray("songs", songList);
    dialog.setArguments(bundle);
    return dialog;
}
 
Example 9
Project: KomaMusic   File: NewPlaylistDialog.java   View Source Code Vote up 5 votes
public static NewPlaylistDialog newInstance(long[] songList) {
    NewPlaylistDialog dialog = new NewPlaylistDialog();
    Bundle bundle = new Bundle();
    bundle.putLongArray("songs", songList);
    dialog.setArguments(bundle);
    return dialog;
}
 
Example 10
Project: TPlayer   File: MediaPlayer.java   View Source Code Vote up 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
Project: ucar-weex-core   File: ArgumentsUtil.java   View Source Code Vote up 5 votes
public static void fromArrayToBundle(Bundle bundle, String key, Object array) {
    if (bundle != null && !TextUtils.isEmpty(key) && array != null) {
        if (array instanceof String[]) {
            bundle.putStringArray(key, (String[]) ((String[]) array));
        } else if (array instanceof byte[]) {
            bundle.putByteArray(key, (byte[]) ((byte[]) array));
        } else if (array instanceof short[]) {
            bundle.putShortArray(key, (short[]) ((short[]) array));
        } else if (array instanceof int[]) {
            bundle.putIntArray(key, (int[]) ((int[]) array));
        } else if (array instanceof long[]) {
            bundle.putLongArray(key, (long[]) ((long[]) array));
        } else if (array instanceof float[]) {
            bundle.putFloatArray(key, (float[]) ((float[]) array));
        } else if (array instanceof double[]) {
            bundle.putDoubleArray(key, (double[]) ((double[]) array));
        } else if (array instanceof boolean[]) {
            bundle.putBooleanArray(key, (boolean[]) ((boolean[]) array));
        } else if (array instanceof char[]) {
            bundle.putCharArray(key, (char[]) ((char[]) array));
        } else {
            if (!(array instanceof JSONArray)) {
                throw new IllegalArgumentException("Unknown array type " + array.getClass());
            }

            ArrayList arraylist = new ArrayList();
            JSONArray jsonArray = (JSONArray) array;
            Iterator it = jsonArray.iterator();

            while (it.hasNext()) {
                JSONObject object = (JSONObject) it.next();
                arraylist.add(fromJsonToBundle(object));
            }

            bundle.putParcelableArrayList(key, arraylist);
        }

    }
}
 
Example 12
Project: orgzly-android   File: Selection.java   View Source Code Vote up 5 votes
/**
 * Save selected items.
 * Restored with {@link Selection#restoreIds(android.os.Bundle)}.
 */
public void saveIds(Bundle bundle) {
    if (getCount() > 0) {
        long[] idsArray = new long[mSelectedIds.size()];
        int i = 0;
        for (long id: mSelectedIds) {
            idsArray[i++] = id;
        }
        bundle.putLongArray(SAVED_BUNDLE_KEY, idsArray);
    } else {
        bundle.remove(SAVED_BUNDLE_KEY);
    }
}
 
Example 13
Project: GitHub   File: Injector.java   View Source Code Vote up 4 votes
public void putLongArray(Bundle state, String key, long[] x) {
    state.putLongArray(key + baseKey, x);
}
 
Example 14
Project: IPCInvoker   File: ParameterHelper.java   View Source Code Vote up 4 votes
public static void put(Bundle bundle, String key, Object value) {
        if (value instanceof Integer) {
            bundle.putInt(key, (Integer) value);
        } else if (value instanceof Float) {
            bundle.putFloat(key, (Float) value);
        } else if (value instanceof Character) {
            bundle.putChar(key, (Character) value);
        } else if (value instanceof CharSequence) {
            bundle.putCharSequence(key, (CharSequence) value);
        } else if (value instanceof Long) {
            bundle.putLong(key, (Long) value);
        } else if (value instanceof Short) {
            bundle.putShort(key, (Short) value);
        } else if (value instanceof Byte) {
            bundle.putByte(key, (Byte) value);
        } else if (value instanceof Boolean) {
            bundle.putBoolean(key, (Boolean) value);
        } else if (value instanceof Double) {
            bundle.putDouble(key, (Double) value);
        } else if (value instanceof Parcelable) {
            bundle.putParcelable(key, (Parcelable) value);
        } else if (value instanceof Bundle) {
            bundle.putBundle(key, (Bundle) value);
        } else if (value instanceof int[]) {
            bundle.putIntArray(key, (int[]) value);
        } else if (value instanceof byte[]) {
            bundle.putByteArray(key, (byte[]) value);
        } else if (value instanceof float[]) {
            bundle.putFloatArray(key, (float[]) value);
        } else if (value instanceof double[]) {
            bundle.putDoubleArray(key, (double[]) value);
        } else if (value instanceof boolean[]) {
            bundle.putBooleanArray(key, (boolean[]) value);
        } else if (value instanceof long[]) {
            bundle.putLongArray(key, (long[]) value);
        } else if (value instanceof Parcelable[]) {
            bundle.putParcelableArray(key, (Parcelable[]) value);
        } else if (value instanceof short[]) {
            bundle.putShortArray(key, (short[]) value);
        } else if (value instanceof String[]) {
            bundle.putStringArray(key, (String[]) value);
        } else {
//            bundle.putString(key, String.valueOf(value));
        }
    }
 
Example 15
Project: MRouter   File: MainActivity.java   View Source Code Vote up 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 16
Project: MagicBox   File: LongArrayWriter.java   View Source Code Vote up 4 votes
@Override
public void write(Bundle bundle, Object to, StateField field) throws IllegalAccessException {
    Field propertyField = field.getField();
    propertyField.setAccessible(true);
    bundle.putLongArray(field.getBundleKey(), (long[]) propertyField.get(to));
}
 
Example 17
Project: simple-share-android   File: MultiSelectionUtil.java   View Source Code Vote up 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());
    }
}
 
Example 18
Project: easyfilemanager   File: MultiSelectionUtil.java   View Source Code Vote up 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());
    }
}
 
Example 19
Project: FireFiles   File: MultiSelectionUtil.java   View Source Code Vote up 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());
    }
}
 
Example 20
Project: Lyra   File: LongArrayCoder.java   View Source Code Vote up 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);
}