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:org.mariotaku.twidere.activity.TwitterLoginActivity.java

@Override
public void onLoadFinished(final Loader<LoginResponse> loader,
        final TwitterLoginActivity.LoginResponse result) {
    if (result.succeed) {
        final ContentValues values = makeAccountContentValues(result.conf, result.basic_password,
                result.access_token, result.user, result.auth_type, result.color);
        if (values != null) {
            mResolver.insert(Accounts.CONTENT_URI, values);
        }//from   w  w  w . j  av  a 2s .  c om
        mPreferences.edit().putBoolean(PREFERENCE_KEY_API_UPGRADE_CONFIRMED, true).commit();
        final Intent intent = new Intent(INTENT_ACTION_HOME);
        final Bundle bundle = new Bundle();
        bundle.putLongArray(INTENT_KEY_IDS, new long[] { mLoggedId });
        intent.putExtras(bundle);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(intent);
        finish();
    } else if (result.already_logged_in) {
        Toast.makeText(TwitterLoginActivity.this, R.string.error_already_logged_in, Toast.LENGTH_SHORT).show();
    } else {
        if (result.exception instanceof CallbackURLException) {
            showErrorToast(TwitterLoginActivity.this, getString(R.string.cannot_get_callback_url), true);
        } else {
            showErrorToast(TwitterLoginActivity.this, result.exception, true);
        }
    }
    setSupportProgressBarIndeterminateVisibility(false);
    mEditPassword.setEnabled(true);
    mEditUsername.setEnabled(true);
    mSignInButton.setEnabled(true);
    mSignUpButton.setEnabled(true);
    mSetColorButton.setEnabled(true);
}

From source file:com.roamprocess1.roaming4world.ui.calllog.CallLogListFragment.java

@Override
public void viewDetails(int position, long[] callIds) {
    ListView lv = getListView();//ww w  . j a v a2s . co m
    if (mMode != null) {
        lv.setItemChecked(position, !lv.isItemChecked(position));
        mMode.invalidate();
        // Don't see details in this case

        System.out.println("CallLogListFragment Step 12");
        return;
    }

    if (mDualPane) {

        System.out.println("CallLogListFragment  === mDualPane");

        System.out.println("CallLogListFragment Step 13");

        // 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.
        System.out.println("CallLogListFragment Step 14");

        try {

            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.replace(R.id.details, df, null);
            ft.addToBackStack(null);
            System.out.println("CallLogListFragment Step 15");
            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
            ft.commit();

        } catch (Exception e) {
            // TODO: handle exception
        }

        getListView().setItemChecked(position, true);
    } else {
        Intent it = new Intent(getActivity(), CallLogDetailsActivity.class);
        it.putExtra(CallLogDetailsFragment.EXTRA_CALL_LOG_IDS, callIds);
        System.out.println("CallLogListFragment Step 16");
        try {
            getActivity().startActivity(it);
        } catch (Exception e) {
            // TODO: handle exception
        }

    }
}

From source file:com.app.uafeed.fragment.EntryFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putParcelable(STATE_BASE_URI, mBaseUri);
    outState.putLongArray(STATE_ENTRIES_IDS, mEntriesIds);
    outState.putLong(STATE_INITIAL_ENTRY_ID, mInitialEntryId);
    outState.putInt(STATE_CURRENT_PAGER_POS, mCurrentPagerPos);
    outState.putFloat(STATE_SCROLL_PERCENTAGE, mEntryPagerAdapter.getScrollPercentage());

    super.onSaveInstanceState(outState);
}

From source file:com.android.contacts.SimImportFragment.java

private void saveAdapterSelectedStates(Bundle outState) {
    if (mAdapter == null) {
        return;//from  w  w  w.j a va  2s  .  c om
    }

    // Make sure the selections are up-to-date
    for (Map.Entry<AccountWithDataSet, long[]> entry : mPerAccountCheckedIds.entrySet()) {
        outState.putLongArray(entry.getKey().stringify() + KEY_SUFFIX_SELECTED_IDS, entry.getValue());
    }
}

From source file:com.example.craiger.nav.FragmentItemIdStatePagerAdapter.java

@Override
public Parcelable saveState() {
    Bundle state = null;
    if (mSavedState.size() > 0) {
        state = new Bundle();
        long[] itemIdsForState = new long[mSavedState.size()];
        Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
        for (int i = 0; i < mSavedState.size(); i++) {
            itemIdsForState[i] = mSavedState.keyAt(i);
            fss[i] = mSavedState.valueAt(i);
        }//  w  w  w  . j av  a 2  s .  c o  m
        state.putLongArray("itemIdsForState", itemIdsForState);
        state.putParcelableArray("states", fss);
    }
    for (Map.Entry<Fragment, Long> fragmentToIdEntry : mFragmentToItemIdMap.entrySet()) {
        Fragment f = fragmentToIdEntry.getKey();
        if (f != null && f.isAdded()) {
            if (state == null) {
                state = new Bundle();
            }
            Long itemId = fragmentToIdEntry.getValue();
            String bundleKey = KEY_FRAGMENT + itemId;
            mFragmentManager.putFragment(state, bundleKey, f);
        }
    }
    return state;
}

From source file:com.android.music.AlbumBrowserFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case PLAY_SELECTION: {
        // play the selected album
        long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
        MusicUtils.playAll(getActivity(), list, 0);
        return true;
    }//from  w w  w .  j  a  v  a  2  s . co m

    case QUEUE: {
        long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
        MusicUtils.addToCurrentPlaylist(getActivity(), list);
        return true;
    }

    case NEW_PLAYLIST: {
        Intent intent = new Intent();
        intent.setClass(getActivity(), CreatePlaylist.class);
        startActivityForResult(intent, NEW_PLAYLIST);
        return true;
    }

    case PLAYLIST_SELECTED: {
        long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
        long playlist = item.getIntent().getLongExtra("playlist", 0);
        MusicUtils.addToPlaylist(getActivity(), list, playlist);
        return true;
    }
    case DELETE_ITEM: {
        long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
        String f;
        if (android.os.Environment.isExternalStorageRemovable()) {
            f = getString(R.string.delete_album_desc);
        } else {
            f = getString(R.string.delete_album_desc_nosdcard);
        }
        String desc = String.format(f, mCurrentAlbumName);
        Bundle b = new Bundle();
        b.putString("description", desc);
        b.putLongArray("items", list);
        Intent intent = new Intent();
        intent.setClass(getActivity(), DeleteItems.class);
        intent.putExtras(b);
        startActivityForResult(intent, -1);
        return true;
    }
    case SEARCH:
        doSearch();
        return true;

    }
    return super.onContextItemSelected(item);
}

From source file:com.carlrice.reader.fragment.EntryFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putParcelable(STATE_BASE_URI, mBaseUri);
    outState.putLongArray(STATE_ENTRIES_IDS, mEntriesIds);
    outState.putLong(STATE_INITIAL_ENTRY_ID, mInitialEntryId);
    outState.putInt(STATE_CURRENT_PAGER_POS, mCurrentPagerPos);

    super.onSaveInstanceState(outState);
}

From source file:com.example.android.honeypad.ui.NoteListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putInt(KEY_CURRENT_ACTIVATED, mCurrentActivePosition);
    if (mCheckedItems != null && mCheckedItems.size() > 0) {
        long[] checked = new long[mCheckedItems.size()];
        final int N = mCheckedItems.size();
        for (int i = 0; i < N; i++) {
            checked[i] = mCheckedItems.get(i);
        }/*from   w  w  w  .  j a v a 2  s.com*/
        outState.putLongArray(KEY_CURRENT_CHECKED, checked);
    }
}

From source file:org.mariotaku.twidere.activity.SignInActivity.java

@Override
public void onLoadFinished(final Loader<LoginResponse> loader, final SignInActivity.LoginResponse result) {
    if (result != null) {
        if (result.succeed) {
            final ContentValues values = makeAccountContentValues(result.conf, result.basic_password,
                    result.access_token, result.user, result.auth_type, result.color);
            if (values != null) {
                mResolver.insert(Accounts.CONTENT_URI, values);
            }//  ww  w . j  a v  a  2 s  .co  m
            mPreferences.edit().putBoolean(PREFERENCE_KEY_API_UPGRADE_CONFIRMED, true).commit();
            final Intent intent = new Intent(INTENT_ACTION_HOME);
            final Bundle bundle = new Bundle();
            bundle.putLongArray(INTENT_KEY_IDS, new long[] { mLoggedId });
            intent.putExtras(bundle);
            intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            startActivity(intent);
            finish();
        } else if (result.already_logged_in) {
            Toast.makeText(SignInActivity.this, R.string.error_already_logged_in, Toast.LENGTH_SHORT).show();
        } else {
            if (result.exception instanceof CallbackURLException) {
                showErrorToast(this, getString(R.string.cannot_get_callback_url), true);
            } else {
                showErrorToast(this, getString(R.string.signing_in), result.exception, true);
            }
        }
    }
    setSupportProgressBarIndeterminateVisibility(false);
    mEditPassword.setEnabled(true);
    mEditUsername.setEnabled(true);
    mSignInButton.setEnabled(true);
    mSignUpButton.setEnabled(true);
    mBrowserSignInButton.setEnabled(true);
    mSetColorButton.setEnabled(true);
    setSignInButton();
}

From source file:org.gnucash.android.ui.transactions.TransactionsListFragment.java

/**
 * Prepares and displays the dialog for bulk moving transactions to another account
 *//*from  w w  w .  ja  v a  2s. c o m*/
protected void showBulkMoveDialog() {
    FragmentManager manager = getActivity().getSupportFragmentManager();
    FragmentTransaction ft = manager.beginTransaction();
    Fragment prev = manager.findFragmentByTag("bulk_move_dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    // Create and show the dialog.
    DialogFragment bulkMoveFragment = new BulkMoveDialogFragment();
    Bundle args = new Bundle();
    args.putLong(ORIGIN_ACCOUNT_ID, mAccountID);
    long[] selectedIds = new long[mSelectedIds.size()];
    int i = 0;
    for (long l : mSelectedIds.values()) {
        selectedIds[i++] = l;
    }
    args.putLongArray(SELECTED_TRANSACTION_IDS, selectedIds);
    bulkMoveFragment.setArguments(args);
    bulkMoveFragment.show(ft, "bulk_move_dialog");
}