Example usage for android.os Bundle putInt

List of usage examples for android.os Bundle putInt

Introduction

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

Prototype

public void putInt(@Nullable String key, int value) 

Source Link

Document

Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.andrewshu.android.reddit.threads.ThreadsListActivity.java

@Override
protected void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);
    state.putString(Constants.SUBREDDIT_KEY, mSubreddit);
    state.putString(Constants.ThreadsSort.SORT_BY_KEY, mSortByUrl);
    state.putString(Constants.JUMP_TO_THREAD_ID_KEY, mJumpToThreadId);
    state.putString(Constants.AFTER_KEY, mAfter);
    state.putString(Constants.BEFORE_KEY, mBefore);
    state.putInt(Constants.THREAD_COUNT_KEY, mCount);
    state.putString(Constants.LAST_AFTER_KEY, mLastAfter);
    state.putString(Constants.LAST_BEFORE_KEY, mLastBefore);
    state.putInt(Constants.THREAD_LAST_COUNT_KEY, mLastCount);
    state.putParcelable(Constants.VOTE_TARGET_THING_INFO_KEY, mVoteTargetThing);
}

From source file:com.irccloud.android.fragment.BuffersListFragment.java

@Override
public void onSaveInstanceState(Bundle state) {
    if (adapter != null && adapter.data != null && adapter.data.size() > 0) {
        ArrayList<Integer> expandedArchives = new ArrayList<Integer>();
        SparseArray<ServersDataSource.Server> servers = ServersDataSource.getInstance().getServers();
        for (int i = 0; i < servers.size(); i++) {
            ServersDataSource.Server s = servers.valueAt(i);
            if (mExpandArchives.get(s.cid, false))
                expandedArchives.add(s.cid);
        }/*  w w  w.java2 s  . co  m*/
        state.putIntegerArrayList("expandedArchives", expandedArchives);
        if (listView != null)
            state.putInt("scrollPosition", listView.getFirstVisiblePosition());
    }
}

From source file:com.hybris.mobile.lib.commerce.provider.CatalogProvider.java

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SQLiteDatabase sqLiteDatabase = mDatabaseHelper.getWritableDatabase();
    String tableName;/*from w  ww  .j a va  2 s . c  om*/
    String where;
    String order = "";
    Bundle bundleSyncAdapter = new Bundle();
    String lastPathSegment = uri.getLastPathSegment();

    if (StringUtils.isNotBlank(sortOrder)) {
        order = " ORDER BY " + sortOrder;
    }

    switch (URI_MATCHER.match(uri)) {

    // Getting the content for a group (list of simple data)
    case CatalogContract.Provider.CODE_GROUP_ID:
        tableName = CatalogContract.DataBaseDataSimple.TABLE_NAME;
        where = CatalogContract.DataBaseDataLinkGroup.TABLE_NAME + "."
                + CatalogContract.DataBaseDataLinkGroup.ATT_GROUP_ID + "='" + lastPathSegment + "'";

        // Limit for the query on the sync adapter
        String currentPage = uri.getQueryParameter(CatalogContract.Provider.QUERY_PARAM_CURRENT_PAGE);
        String pageSize = uri.getQueryParameter(CatalogContract.Provider.QUERY_PARAM_PAGE_SIZE);

        // Bundle information for the syncing part
        bundleSyncAdapter.putString(CatalogSyncConstants.SYNC_PARAM_GROUP_ID, lastPathSegment);

        if (StringUtils.isNotBlank(currentPage) && StringUtils.isNotBlank(pageSize)) {
            bundleSyncAdapter.putInt(CatalogSyncConstants.SYNC_PARAM_CURRENT_PAGE,
                    Integer.valueOf(currentPage));
            bundleSyncAdapter.putInt(CatalogSyncConstants.SYNC_PARAM_PAGE_SIZE, Integer.valueOf(pageSize));
        }

        break;

    // Getting a specific data detail
    case CatalogContract.Provider.CODE_DATA_ID:
    case CatalogContract.Provider.CODE_DATA_DETAILS_ID:
        tableName = CatalogContract.DataBaseDataDetails.TABLE_NAME;
        where = CatalogContract.DataBaseDataDetails.TABLE_NAME + "."
                + CatalogContract.DataBaseDataDetails.ATT_DATA_ID + "='" + lastPathSegment + "'";

        // Bundle information for the syncing part
        bundleSyncAdapter.putString(CatalogSyncConstants.SYNC_PARAM_DATA_ID, lastPathSegment);

        // We don't load the variants for a specific data
        bundleSyncAdapter.putBoolean(CatalogSyncConstants.SYNC_PARAM_LOAD_VARIANTS, false);
        break;

    default:
        Log.e(TAG, "URI not recognized" + uri.toString());
        throw new IllegalArgumentException("URI not recognized" + uri.toString());

    }

    // We do the query by joining the data to the group
    Cursor cursor = sqLiteDatabase.rawQuery("SELECT * FROM " + tableName + " INNER JOIN "
            + CatalogContract.DataBaseDataLinkGroup.TABLE_NAME + " ON " + tableName + "."
            + CatalogContract.DataBaseData.ATT_DATA_ID + "=" + CatalogContract.DataBaseDataLinkGroup.TABLE_NAME
            + "." + CatalogContract.DataBaseDataLinkGroup.ATT_DATA_ID + " WHERE " + where + order, null);

    // Register the cursor to watch the uri for changes
    cursor.setNotificationUri(getContext().getContentResolver(), uri);

    // Existing data
    if (cursor.getCount() > 0) {
        // TODO - For now we check if one the items is out-of-sync and we sync all of them if this is the case
        // Future - Check every out-of-date items and sync them
        cursor.moveToLast();
        int status = cursor.getInt(cursor.getColumnIndex(CatalogContract.DataBaseData.ATT_STATUS));
        cursor.moveToFirst();

        // Data expired, we request a sync
        if (status == CatalogContract.SyncStatus.OUTOFDATE.getValue()) {
            Log.i(TAG, "Data for " + uri.toString() + " is out-of-date, requesting a sync");
            requestSync(bundleSyncAdapter);

            // TODO - the uptodate/outofdate should be done in the sync adapter
            // We up-to-date all the data in case the sync does not return any results (we base our out of sync on the last item of the cursor)
            if (URI_MATCHER.match(uri) == CatalogContract.Provider.CODE_GROUP_ID) {
                updateInternalDataSyncStatus(cursor, tableName, SyncStatus.UPTODATE);
            }
        }
        // Data updated, we invalidate the data
        else {
            Log.i(TAG, "Data for " + uri.toString() + " is up-of-date, invalidating it");
            updateInternalDataSyncStatus(cursor, tableName, SyncStatus.OUTOFDATE);
        }

    }
    // No data found, we request a sync if it's not already up-to-date
    else {
        boolean triggerSyncAdapter;

        switch (URI_MATCHER.match(uri)) {

        // Saving the sync info for the group
        case CatalogContract.Provider.CODE_GROUP_ID:
            triggerSyncAdapter = updateTrackSyncStatus(CatalogContract.Provider.getUriSyncGroup(authority),
                    CatalogContract.DataBaseSyncStatusGroup.ATT_GROUP_ID,
                    CatalogContract.DataBaseSyncStatusGroup.TABLE_NAME, lastPathSegment);

            break;

        // Saving the sync info for the data
        case CatalogContract.Provider.CODE_DATA_ID:
            triggerSyncAdapter = updateTrackSyncStatus(CatalogContract.Provider.getUriData(authority),
                    CatalogContract.DataBaseData.ATT_DATA_ID, CatalogContract.DataBaseDataSimple.TABLE_NAME,
                    lastPathSegment);
            break;

        // Saving the sync info for the data details
        case CatalogContract.Provider.CODE_DATA_DETAILS_ID:
            triggerSyncAdapter = updateTrackSyncStatus(CatalogContract.Provider.getUriDataDetails(authority),
                    CatalogContract.DataBaseData.ATT_DATA_ID, CatalogContract.DataBaseDataDetails.TABLE_NAME,
                    lastPathSegment);
            break;

        default:
            Log.e(TAG, "URI not recognized" + uri.toString());
            throw new IllegalArgumentException("URI not recognized" + uri.toString());

        }

        // Trigger the sync adapter
        if (triggerSyncAdapter) {
            Log.i(TAG, "No data found for " + uri.toString() + " and data out-of-date, requesting a sync");
            requestSync(bundleSyncAdapter);
        } else {
            Log.i(TAG, "No data found for " + uri.toString() + " and data up-to-date");
        }

    }

    return cursor;
}

From source file:de.sourcestream.movieDB.controller.CastDetails.java

/**
 * Called to ask the fragment to save its current dynamic state,
 * so it can later be reconstructed in a new instance of its process is restarted.
 *
 * @param outState Bundle in which to place your saved state.
 *//*  w  w  w.ja  v  a2s  .c o  m*/
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Used to avoid bug where we add item in the back stack
    // and if we change orientation twice the item from the back stack has null values
    if (save != null && save.getInt("timeOut") == 1)
        save = null;

    if (save != null) {
        outState.putBundle("save", save);
        if (addToBackStack) {
            activity.addCastDetailsBundle(save);
            addToBackStack = false;
        }

    } else {
        Bundle send = new Bundle();
        send.putInt("currentId", currentId);
        if (request != null && request.getStatus() == AsyncTask.Status.RUNNING) {
            timeOut = 1;
            request.cancel(true);
        }
        send.putInt("timeOut", timeOut);
        send.putString("title", title);
        if (timeOut == 0) {
            // HomePage
            send.putInt("homeIconCheck", homeIconCheck);
            if (homeIconCheck == 0)
                send.putString("homepage", homeIconUrl);

            // Gallery icon
            send.putInt("galleryIconCheck", galleryIconCheck);
            if (galleryIconCheck == 0)
                send.putStringArrayList("galleryList", galleryList);

            // More icon
            send.putInt("moreIconCheck", moreIconCheck);

            // Cast details info begins here
            if (castDetailsInfo != null) {
                // Name
                send.putString("name", castDetailsInfo.getName().getText().toString());

                // Poster path url
                if (castDetailsInfo.getProfilePath().getTag() != null)
                    send.putString("profilePathURL", castDetailsInfo.getProfilePath().getTag().toString());

                // Birth info
                send.putString("birthInfo", castDetailsInfo.getBirthInfo().getText().toString());

                // Also known as
                send.putString("alsoKnownAs", castDetailsInfo.getAlsoKnownAs().getText().toString());

                // Known list
                if (castDetailsInfo.getKnownList() != null && castDetailsInfo.getKnownList().size() > 0)
                    send.putParcelableArrayList("knownList", castDetailsInfo.getKnownList());

            }
            // Cast details info ends here

            // Credits  starts here
            if (castDetailsCredits != null)
                send.putParcelableArrayList("moviesList", moviesList);

            // Credits ends here

            // Overview
            if (castDetailsBiography != null)
                send.putString("biography", castDetailsBiography.getBiography().getText().toString());

        }

        outState.putBundle("save", send);
        save = send;
        if (addToBackStack) {
            activity.addCastDetailsBundle(send);
            addToBackStack = false;
        }
    }
}

From source file:com.ichi2.anki.CardEditor.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    // TODO//from   w  ww. j  a  v  a  2  s . c  o m
    // Log.i(AnkiDroidApp.TAG, "onSaveInstanceState: " + path);
    // outState.putString("deckFilename", path);
    outState.putBoolean("addFact", mAddNote);
    outState.putInt("caller", mCaller);
    Log.i(AnkiDroidApp.TAG, "onSaveInstanceState - Ending");
}

From source file:com.mantz_it.rfanalyzer.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putBoolean(getString(R.string.save_state_running), running);
    outState.putInt(getString(R.string.save_state_demodulatorMode), demodulationMode);
    if (analyzerSurface != null) {
        outState.putLong(getString(R.string.save_state_channelFrequency),
                analyzerSurface.getChannelFrequency());
        outState.putInt(getString(R.string.save_state_channelWidth), analyzerSurface.getChannelWidth());
        outState.putFloat(getString(R.string.save_state_squelch), analyzerSurface.getSquelch());
        outState.putLong(getString(R.string.save_state_virtualFrequency),
                analyzerSurface.getVirtualFrequency());
        outState.putInt(getString(R.string.save_state_virtualSampleRate),
                analyzerSurface.getVirtualSampleRate());
        outState.putFloat(getString(R.string.save_state_minDB), analyzerSurface.getMinDB());
        outState.putFloat(getString(R.string.save_state_maxDB), analyzerSurface.getMaxDB());
    }/*www.  j  ava 2 s. c  o  m*/
}

From source file:jp.mixi.android.sdk.MixiContainerImpl.java

/**
 * PaymentParameterintent?bundle??/*from   w ww .j  a v  a2s. c o  m*/
 * 
 * @param param
 * @return
 */
private Bundle convertPaymentBundle(PaymentParameter param) {
    Bundle bundle = new Bundle();
    bundle.putString(PaymentParameter.CLIENT_ID_NAME, mClientId);
    bundle.putString(PaymentParameter.CALLBACK_URL_NAME, param.callbackUrl);
    bundle.putString(PaymentParameter.INVENTORY_CODE_NAME, param.inventoryCode);
    bundle.putBoolean(PaymentParameter.IS_TEST_NAME, param.isTest);
    bundle.putString(PaymentParameter.ITEM_ID_NAME, param.itemId);
    bundle.putString(PaymentParameter.ITEM_NAME_NAME, param.itemName);
    bundle.putInt(PaymentParameter.ITEM_PRICE_NAME, param.itemPrice);
    bundle.putString(PaymentParameter.SIGNATURE_NAME, param.signature);
    bundle.putInt(PaymentParameter.VERSION_NAME, param.getVertion());
    return bundle;
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

private void RunChoice() {

    storage = CachingStorage.getInstance();
    config = storage.loadScheduleConfig();
    // if config == null the app is not been activate and
    // no test can be run
    if (config == null) {
        // TODO Add an alert that the app has not been init yet
        config = new ScheduleConfig();
    }/*from www.  j  a  v  a  2s  . c  om*/
    testList = config.manual_tests;
    array_spinner = new String[testList.size() + 1];
    array_spinner_int = new int[testList.size() + 1];

    Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.choose_test));
    // dropdown setup

    for (int i = 0; i < testList.size(); i++) {
        TestDescription td = testList.get(i);
        array_spinner[i] = td.displayName;
        array_spinner_int[i] = td.testId;
    }
    array_spinner[testList.size()] = getString(R.string.all);
    array_spinner_int[testList.size()] = -1;

    builder.setItems(array_spinner, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            dialog.dismiss();

            Intent intent = new Intent(SamKnowsAggregateStatViewerActivity.this,
                    SamKnowsTestViewerActivity.class);
            Bundle b = new Bundle();
            b.putInt("testID", array_spinner_int[which]);
            intent.putExtras(b);
            startActivityForResult(intent, 1);
            overridePendingTransition(R.anim.transition_in, R.anim.transition_out);
        }
    });
    builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.owncloud.android.authentication.AuthenticatorActivity.java

/**
 * Saves relevant state before {@link #onPause()}
 * /*from   w  w  w .  java2  s  . c o  m*/
 * Do NOT save {@link #mNewCapturedUriFromOAuth2Redirection}; it keeps a
 * temporal flag, intended to defer the processing of the redirection caught
 * in {@link #onNewIntent(Intent)} until {@link #onResume()}
 * 
 * See {@link #loadSavedInstanceState(Bundle)}
 */
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    // / connection state and info
    outState.putInt(KEY_AUTH_MESSAGE_VISIBILITY, mAuthMessage.getVisibility());
    outState.putString(KEY_AUTH_MESSAGE_TEXT, mAuthMessage.getText().toString());
    outState.putInt(KEY_SERVER_STATUS_TEXT, mServerStatusText);
    outState.putInt(KEY_SERVER_STATUS_ICON, mServerStatusIcon);
    outState.putBoolean(KEY_SERVER_VALID, mServerIsValid);
    outState.putBoolean(KEY_SERVER_CHECKED, mServerIsChecked);
    outState.putBoolean(KEY_SERVER_CHECK_IN_PROGRESS, (!mServerIsValid && mOcServerChkOperation != null));
    outState.putBoolean(KEY_IS_SSL_CONN, mIsSslConn);
    outState.putBoolean(KEY_PASSWORD_VISIBLE, isPasswordVisible());
    outState.putInt(KEY_AUTH_STATUS_ICON, mAuthStatusIcon);
    outState.putInt(KEY_AUTH_STATUS_TEXT, mAuthStatusText);

    // / server data
    if (mDiscoveredVersion != null) {
        outState.putString(KEY_OC_VERSION, mDiscoveredVersion.toString());
    }
    outState.putString(KEY_HOST_URL_TEXT, mHostBaseUrl);

    // / account data, if updating
    if (mAccount != null) {
        outState.putParcelable(KEY_ACCOUNT, mAccount);
    }
    outState.putString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE, mAuthTokenType);

    // refresh button enabled
    outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE));

}

From source file:de.sourcestream.movieDB.controller.TVDetails.java

/**
 * Called to ask the fragment to save its current dynamic state,
 * so it can later be reconstructed in a new instance of its process is restarted.
 *
 * @param outState Bundle in which to place your saved state.
 *//*w  ww  . j a v a 2 s  .  c om*/
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Used to avoid bug where we add item in the back stack
    // and if we change orientation twice the item from the back stack has null values
    if (save != null && save.getInt("timeOut") == 1)
        save = null;
    save = null;

    if (save != null) {
        if (tvDetailsCast != null)
            save.putInt("lastVisitedPerson", tvDetailsCast.getLastVisitedPerson());
        outState.putBundle("save", save);
        if (addToBackStack) {
            activity.addTvDetailsBundle(save);
            addToBackStack = false;
        }
    } else {
        Bundle send = new Bundle();
        send.putInt("currentId", currentId);
        if (request != null && request.getStatus() == AsyncTask.Status.RUNNING) {
            timeOut = 1;
            request.cancel(true);
        }
        send.putInt("timeOut", timeOut);
        send.putString("title", title);
        if (timeOut == 0) {
            // HomePage
            send.putInt("homeIconCheck", homeIconCheck);
            if (homeIconCheck == 0)
                send.putString("homepage", homeIconUrl);

            // Gallery icon
            send.putInt("galleryIconCheck", galleryIconCheck);
            if (galleryIconCheck == 0)
                send.putStringArrayList("galleryList", galleryList);

            // More icon
            send.putInt("moreIconCheck", moreIconCheck);
            // used to pass the data to the castList view
            send.putParcelableArrayList("seasonList", seasonList);

        }

        // TV details info begins here
        if (tvDetailsInfo != null) {
            // Backdrop path
            send.putInt("backDropCheck", tvDetailsInfo.getBackDropCheck());
            if (tvDetailsInfo.getBackDropCheck() == 0 && tvDetailsInfo.getBackDropPath().getTag() != null)
                send.putString("backDropUrl", tvDetailsInfo.getBackDropPath().getTag().toString());

            // Poster path url
            if (tvDetailsInfo.getPosterPath().getTag() != null)
                send.putString("posterPathURL", tvDetailsInfo.getPosterPath().getTag().toString());

            // Rating
            send.putFloat("rating", tvDetailsInfo.getRatingBar().getRating());
            send.putString("voteCount", tvDetailsInfo.getVoteCount().getText().toString());

            // Title
            send.putString("titleText", tvDetailsInfo.getTitle().getText().toString());

            // Status
            send.putString("status", tvDetailsInfo.getStatusText().getText().toString());

            // Type
            send.putString("typeText", tvDetailsInfo.getTypeText().getText().toString());

            // Episode runtime
            send.putString("episodeRuntime", tvDetailsInfo.getEpisodeRuntime().getText().toString());

            // Number of episodes
            send.putString("numberOfEpisodesText",
                    tvDetailsInfo.getNumberOfEpisodesText().getText().toString());

            // Number of seasons
            send.putString("numberOfSeasonsText", tvDetailsInfo.getNumberOfSeasonsText().getText().toString());

            // First air date
            send.putString("firstAirDateText", tvDetailsInfo.getFirstAirDateText().getText().toString());

            // Last air date
            send.putString("lastAirDateText", tvDetailsInfo.getLastAirDateText().getText().toString());

            // Genres
            send.putString("genres", tvDetailsInfo.getGenres().getText().toString());

            // Production countries
            send.putString("productionCountries", tvDetailsInfo.getCountries().getText().toString());

            // Production companies
            send.putString("productionCompanies", tvDetailsInfo.getCompanies().getText().toString());

            // Similar list
            if (tvDetailsInfo.getSimilarList() != null && tvDetailsInfo.getSimilarList().size() > 0)
                send.putParcelableArrayList("similarList", tvDetailsInfo.getSimilarList());

        }
        // TV details info ends here

        // TV details cast starts here
        if (tvDetailsCast != null) {
            send.putParcelableArrayList("castList", castList);
            send.putInt("lastVisitedPerson", tvDetailsCast.getLastVisitedPerson());
        }
        // TV details cast ends here

        if (tvDetailsOverview != null)
            send.putString("overview", tvDetailsOverview.getOverview().getText().toString());

        outState.putBundle("save", send);
        save = send;
        if (addToBackStack) {
            activity.addTvDetailsBundle(send);
            addToBackStack = false;
        }
    }

}