Example usage for android.os Bundle putLongArray

List of usage examples for android.os Bundle putLongArray

Introduction

In this page you can find the example usage for android.os Bundle putLongArray.

Prototype

public void putLongArray(@Nullable String key, @Nullable long[] value) 

Source Link

Document

Inserts a long array value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.abcvoipsip.ui.calllog.CallLogListFragment.java

@Override
public void viewDetails(int position, long[] callIds) {
    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);// w  ww  .  j a v  a2  s. c  om
        // 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);
    }
}

From source file:com.bydavy.card.receipts.ReceiptListAdapter.java

public void save(Bundle outState) {
    final long[] arrayIds = new long[mSelectedSet.size()];
    int i = 0;/* w  w  w.j  a v a2 s  .c om*/
    for (final Long id : mSelectedSet) {
        arrayIds[i++] = id;
    }
    outState.putLongArray(STATE_SELECTED_IDS, arrayIds);
}

From source file:com.example.newfragmentstatepageradapter.NewFragmentStatePagerAdapter.java

@Override
public Parcelable saveState() {
    Bundle state = new Bundle();
    if (mItemIds.length > 0) {
        state.putLongArray("itemids", mItemIds);
    }//from  w w  w. j a v  a 2  s .  c o  m
    if (mSavedState.size() > 0) {
        Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
        mSavedState.toArray(fss);
        state.putParcelableArray("states", fss);
    }
    for (int i = 0; i < mFragments.size(); i++) {
        Fragment f = mFragments.get(i);
        if (f != null) {
            String key = "f" + i;
            mFragmentManager.putFragment(state, key, f);
        }
    }
    return state;
}

From source file:org.mariotaku.twidere.extension.timescape.ExtensionSettingsActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    final int ids_size = mSelectedIds.size();
    final long[] ids = new long[ids_size];
    for (int i = 0; i < ids_size; i++) {
        ids[i] = mSelectedIds.get(i);/*w w  w. ja  v a2  s. co  m*/
    }
    outState.putLongArray(Twidere.INTENT_KEY_IDS, ids);
    super.onSaveInstanceState(outState);
}

From source file:com.btmura.android.reddit.app.FragmentStateItemPagerAdapter.java

@Override
public Parcelable saveState() {
    Bundle state = null;
    if (mItemIds != null && mItemIds.length > 0) {
        state = new Bundle();
        state.putLongArray("itemIds", mItemIds);
    }//from   ww w .ja va 2  s  . co  m
    if (mSavedState.size() > 0) {
        if (state == null) {
            state = new Bundle();
        }
        Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
        mSavedState.toArray(fss);
        state.putParcelableArray("states", fss);
    }
    for (int i = 0; i < mFragments.size(); i++) {
        Fragment f = mFragments.get(i);
        if (f != null) {
            if (state == null) {
                state = new Bundle();
            }
            String key = "f" + i;
            mFragmentManager.putFragment(state, key, f);
        }
    }
    return state;
}

From source file:com.dwdesign.tweetings.activity.SelectAccountActivity.java

@Override
public void onSaveInstanceState(final Bundle outState) {
    final int ids_size = mActivatedUsersId.size();
    final long[] ids = new long[ids_size];
    for (int i = 0; i < ids_size; i++) {
        ids[i] = mActivatedUsersId.get(i);
    }/*  w  w  w  .  j a va2s. c  o  m*/
    outState.putLongArray(Constants.INTENT_KEY_IDS, ids);
    super.onSaveInstanceState(outState);
}

From source file:com.dwdesign.tweetings.activity.SelectAccountActivity.java

@Override
public void onBackPressed() {
    if (mActivatedUsersId.size() <= 0) {
        Toast.makeText(this, R.string.no_account_selected, Toast.LENGTH_SHORT).show();
        return;/*from w  w  w  .j  a  va  2  s. c om*/
    }
    final Bundle bundle = new Bundle();
    final long[] ids = new long[mActivatedUsersId.size()];
    int i = 0;
    for (final Long id_long : mActivatedUsersId) {
        ids[i] = id_long;
        i++;
    }
    bundle.putLongArray(INTENT_KEY_IDS, ids);
    setResult(RESULT_OK, new Intent().putExtras(bundle));
    finish();
}

From source file:de.vanita5.twittnuker.activity.support.DraftsActivity.java

@Override
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_DELETE: {
        final DeleteDraftsConfirmDialogFragment f = new DeleteDraftsConfirmDialogFragment();
        final Bundle args = new Bundle();
        args.putLongArray(EXTRA_IDS, mListView.getCheckedItemIds());
        f.setArguments(args);/*  ww w  . j  a v  a2s.co m*/
        f.show(getSupportFragmentManager(), "delete_drafts_confirm");
        break;
    }
    case MENU_SEND: {
        final Cursor c = mAdapter.getCursor();
        if (c == null || c.isClosed())
            return false;
        final SparseBooleanArray checked = mListView.getCheckedItemPositions();
        final List<DraftItem> list = new ArrayList<DraftItem>();
        final DraftItem.CursorIndices indices = new DraftItem.CursorIndices(c);
        for (int i = 0, j = checked.size(); i < j; i++) {
            if (checked.valueAt(i) && c.moveToPosition(checked.keyAt(i))) {
                list.add(new DraftItem(c, indices));
            }
        }
        if (sendDrafts(list)) {
            final Where where = Where.in(new Column(Drafts._ID),
                    new RawItemArray(mListView.getCheckedItemIds()));
            mResolver.delete(Drafts.CONTENT_URI, where.getSQL(), null);
        }
        break;
    }
    default: {
        return false;
    }
    }
    mode.finish();
    return true;
}

From source file:org.getlantern.firetweet.activity.support.DraftsActivity.java

@Override
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_DELETE: {
        final DeleteDraftsConfirmDialogFragment f = new DeleteDraftsConfirmDialogFragment();
        final Bundle args = new Bundle();
        args.putLongArray(EXTRA_IDS, mListView.getCheckedItemIds());
        f.setArguments(args);//from  w w w.j a v  a  2s  . c o m
        f.show(getSupportFragmentManager(), "delete_drafts_confirm");
        break;
    }
    case MENU_SEND: {
        final Cursor c = mAdapter.getCursor();
        if (c == null || c.isClosed())
            return false;
        final SparseBooleanArray checked = mListView.getCheckedItemPositions();
        final List<DraftItem> list = new ArrayList<>();
        final DraftItem.CursorIndices indices = new DraftItem.CursorIndices(c);
        for (int i = 0, j = checked.size(); i < j; i++) {
            if (checked.valueAt(i) && c.moveToPosition(checked.keyAt(i))) {
                list.add(new DraftItem(c, indices));
            }
        }
        if (sendDrafts(list)) {
            final Expression where = Expression.in(new Column(Drafts._ID),
                    new RawItemArray(mListView.getCheckedItemIds()));
            mResolver.delete(Drafts.CONTENT_URI, where.getSQL(), null);
        }
        break;
    }
    default: {
        return false;
    }
    }
    mode.finish();
    return true;
}

From source file:org.mariotaku.twidere.fragment.support.DraftsFragment.java

@Override
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_DELETE: {
        final DeleteDraftsConfirmDialogFragment f = new DeleteDraftsConfirmDialogFragment();
        final Bundle args = new Bundle();
        args.putLongArray(EXTRA_IDS, mListView.getCheckedItemIds());
        f.setArguments(args);/*from   w  w  w  . ja  v a2s . com*/
        f.show(getChildFragmentManager(), "delete_drafts_confirm");
        break;
    }
    case MENU_SEND: {
        final Cursor c = mAdapter.getCursor();
        if (c == null || c.isClosed())
            return false;
        final SparseBooleanArray checked = mListView.getCheckedItemPositions();
        final List<DraftItem> list = new ArrayList<>();
        final DraftItem.CursorIndices indices = new DraftItem.CursorIndices(c);
        for (int i = 0, j = checked.size(); i < j; i++) {
            if (checked.valueAt(i) && c.moveToPosition(checked.keyAt(i))) {
                list.add(new DraftItem(c, indices));
            }
        }
        if (sendDrafts(list)) {
            final Expression where = Expression.in(new Column(Drafts._ID),
                    new RawItemArray(mListView.getCheckedItemIds()));
            mResolver.delete(Drafts.CONTENT_URI, where.getSQL(), null);
        }
        break;
    }
    default: {
        return false;
    }
    }
    mode.finish();
    return true;
}