Example usage for android.os Bundle putBoolean

List of usage examples for android.os Bundle putBoolean

Introduction

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

Prototype

public void putBoolean(@Nullable String key, boolean value) 

Source Link

Document

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

Usage

From source file:cat.wuyingren.rorhelper.activities.MainActivity.java

/** Swaps fragments in the menu_main_complete content view */
private void selectItem(int position) {
    Fragment fragment = new GameListFragment();
    Bundle args = new Bundle();
    switch (position) {
    case 0://from w w  w.j  a va2  s .co m
    case 3:
    case 8:
        //Headers
        break;
    case 1:
        mTitle = getString(R.string.title_section1);
        fragment.setArguments(args);
        break;
    case 2:
        mTitle = getString(R.string.title_section2);
        fragment = new GameStatusFragment();
        args = new Bundle();
        args.putLong(GameStatusFragment.ARG_GAME_ID, currentGameId);
        fragment.setArguments(args);
        break;
    case 4:
        mTitle = getString(R.string.faction_imperials);
        fragment = prepareFactionFragment(dataSource.getFactionId(currentGameId, mTitle));
        break;
    case 5:
        mTitle = getString(R.string.faction_plutocrats);
        fragment = prepareFactionFragment(dataSource.getFactionId(currentGameId, mTitle));
        break;
    case 6:
        mTitle = getString(R.string.faction_conservatives);
        fragment = prepareFactionFragment(dataSource.getFactionId(currentGameId, mTitle));
        break;
    case 7:
        mTitle = getString(R.string.faction_populists);
        fragment = prepareFactionFragment(dataSource.getFactionId(currentGameId, mTitle));
        break;

    case 9:
        mTitle = getString(R.string.title_section3);
        fragment = new CardListFragment();
        args = new Bundle();
        args.putInt(CardListFragment.ARG_SCENARIO_ID, currentGame.getScenarioID());
        args.putBoolean(CardListFragment.ARG_STATEMEN_ENABLED, false);
        fragment.setArguments(args);
        break;
    case 10:
        mTitle = getString(R.string.title_section4);
        fragment = new CardListFragment();
        args = new Bundle();
        args.putInt(CardListFragment.ARG_SCENARIO_ID, currentGame.getScenarioID());
        args.putBoolean(CardListFragment.ARG_STATEMEN_ENABLED, true);
        fragment.setArguments(args);
        break;
    default:
        break;
    }

    // Insert the fragment by replacing any existing fragment
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    // Highlight the selected item, update the title, and close the drawer
    mDrawerList.setItemChecked(position, true);
    //getActionBar().setTitle((mOperationsSystem[position]));
    mDrawerLayout.closeDrawer(mDrawerLayout.findViewById(R.id.drawerRoot));
}

From source file:fr.cobaltians.cobalt.Cobalt.java

private Bundle getConfigurationForController(String controller) {
    Bundle bundle = new Bundle();

    JSONObject configuration = getConfiguration();

    // Gets configuration
    try {/*  ww w.  jav  a  2 s . c o m*/
        JSONObject controllers = configuration.getJSONObject(kControllers);

        String activity;
        // TODO: uncomment for Bars
        //JSONObject actionBar;
        boolean enablePullToRefresh;
        boolean enableInfiniteScroll;
        int infiniteScrollOffset;
        // TODO: add enableGesture

        if (controller != null && controllers.has(controller)) {
            activity = controllers.getJSONObject(controller).getString(kAndroid);
            //actionBar = controllers.getJSONObject(controller).optJSONObject(kBars);
            enablePullToRefresh = controllers.getJSONObject(controller).optBoolean(kPullToRefresh);
            enableInfiniteScroll = controllers.getJSONObject(controller).optBoolean(kInfiniteScroll);
            infiniteScrollOffset = controllers.getJSONObject(controller).optInt(kInfiniteScrollOffset,
                    INFINITE_SCROLL_OFFSET_DEFAULT_VALUE);
        } else {
            activity = controllers.getJSONObject(kDefaultController).getString(kAndroid);
            //actionBar = controllers.getJSONObject(kDefaultController).optJSONObject(kBars);
            enablePullToRefresh = controllers.getJSONObject(kDefaultController).optBoolean(kPullToRefresh);
            enableInfiniteScroll = controllers.getJSONObject(kDefaultController).optBoolean(kInfiniteScroll);
            infiniteScrollOffset = controllers.getJSONObject(kDefaultController).optInt(kInfiniteScrollOffset,
                    INFINITE_SCROLL_OFFSET_DEFAULT_VALUE);
        }

        bundle.putString(kActivity, activity);
        //if (actionBar != null) bundle.putString(kBars, actionBar.toString());
        bundle.putBoolean(kPullToRefresh, enablePullToRefresh);
        bundle.putBoolean(kInfiniteScroll, enableInfiniteScroll);
        bundle.putInt(kInfiniteScrollOffset, infiniteScrollOffset);

        return bundle;
    } catch (JSONException exception) {
        if (Cobalt.DEBUG)
            Log.e(Cobalt.TAG,
                    TAG + " - getConfigurationForController: check cobalt.conf. Known issues: \n "
                            + "\t - controllers field not found or not a JSONObject \n " + "\t - " + controller
                            + " controller not found and no " + kDefaultController + " controller defined \n "
                            + "\t - " + controller + " or " + kDefaultController + "controller found but no "
                            + kAndroid + "defined \n ");
        exception.printStackTrace();
    }

    return bundle;
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static List<TabSpec> getTabs(final Context context) {
    if (context == null)
        return Collections.emptyList();
    final ArrayList<TabSpec> tabs = new ArrayList<TabSpec>();
    final ContentResolver resolver = context.getContentResolver();
    final Cursor cur = resolver.query(Tabs.CONTENT_URI, Tabs.COLUMNS, null, null, Tabs.DEFAULT_SORT_ORDER);
    if (cur != null) {
        cur.moveToFirst();//from ww  w .  j ava  2  s .  co m
        final int idx_name = cur.getColumnIndex(Tabs.NAME), idx_icon = cur.getColumnIndex(Tabs.ICON),
                idx_type = cur.getColumnIndex(Tabs.TYPE), idx_arguments = cur.getColumnIndex(Tabs.ARGUMENTS),
                idx_position = cur.getColumnIndex(Tabs.POSITION);
        while (!cur.isAfterLast()) {
            final int position = cur.getInt(idx_position) + HomeActivity.TAB_POSITION_MESSAGES + 1;
            final String icon_type = cur.getString(idx_icon);
            final String type = cur.getString(idx_type);
            final String name = cur.getString(idx_name);
            final Bundle args = parseArguments(cur.getString(idx_arguments));
            args.putBoolean(INTENT_KEY_IS_HOME_TAB, true);
            final Class<? extends Fragment> fragment = CUSTOM_TABS_FRAGMENT_MAP.get(type);
            if (name != null && fragment != null) {
                tabs.add(new TabSpec(name, getTabIconObject(icon_type), fragment, args, position));
            }
            cur.moveToNext();
        }
        cur.close();
    }
    return tabs;
}

From source file:se.leap.bitmaskclient.ProviderAPI.java

private Bundle getAndSetProviderJson(String provider_main_url, String provider_ca_cert_fingerprint) {
    Bundle result = new Bundle();

    if (go_ahead) {
        String provider_dot_json_string;

        if (provider_ca_cert_fingerprint.isEmpty())
            provider_dot_json_string = downloadWithCommercialCA(provider_main_url + "/provider.json");
        else//from w  w w . j a v a  2s  . c o m
            provider_dot_json_string = downloadWithCommercialCA(provider_main_url + "/provider.json",
                    provider_ca_cert_fingerprint);

        try {
            JSONObject provider_json = new JSONObject(provider_dot_json_string);
            provider_api_url = provider_json.getString(Provider.API_URL) + "/"
                    + provider_json.getString(Provider.API_VERSION);
            String name = provider_json.getString(Provider.NAME);
            //TODO setProviderName(name);

            preferences.edit().putString(Provider.KEY, provider_json.toString()).commit();
            preferences.edit()
                    .putBoolean(Constants.ALLOWED_ANON,
                            provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.ALLOWED_ANON))
                    .commit();
            preferences.edit().putBoolean(Constants.ALLOWED_REGISTERED,
                    provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.ALLOWED_REGISTERED))
                    .commit();

            result.putBoolean(RESULT_KEY, true);
        } catch (JSONException e) {
            //TODO Error message should be contained in that provider_dot_json_string
            String reason_to_fail = pickErrorMessage(provider_dot_json_string);
            result.putString(ERRORS, reason_to_fail);
            result.putBoolean(RESULT_KEY, false);
        }
    }
    return result;
}

From source file:cgeo.geocaching.CacheListActivity.java

@Override
public void onSaveInstanceState(final Bundle savedInstanceState) {
    // Always call the superclass so it can save the view hierarchy state
    super.onSaveInstanceState(savedInstanceState);

    // Save the current Filter
    savedInstanceState.putParcelable(STATE_FILTER, currentFilter);
    savedInstanceState.putBoolean(STATE_INVERSE_SORT, adapter.getInverseSort());
    savedInstanceState.putInt(STATE_LIST_TYPE, type.ordinal());
    savedInstanceState.putInt(STATE_LIST_ID, listId);
}

From source file:com.tweetlanes.android.core.view.TweetFeedFragment.java

@Override
public void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);

    if (mTwitterStatusIdWhenRefreshed != null)
        state.putLong("TwitterStatusIdWhenRefreshed", mTwitterStatusIdWhenRefreshed);

    if (mLastTwitterStatusIdSeen != null)
        state.putLong("LastTwitterStatusIdSeen", mLastTwitterStatusIdSeen);

    state.putInt("NewStatuses", mNewStatuses);
    state.putBoolean("HidingListHeading", mHidingListHeading);

    mSelectedItems.clear();//from   w ww .  j a  v a 2s.com
    android.util.SparseBooleanArray items = mTweetFeedListView.getRefreshableView().getCheckedItemPositions();
    for (int i = 0; i < items.size(); i++) {
        int key = items.keyAt(i);
        mTweetFeedListView.getRefreshableView().setItemChecked(key, false);
    }

}

From source file:com.amaze.filemanager.fragments.MainFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    int index;//from   w ww. j a  v a2 s.co m
    View vi;
    if (listView != null) {
        if (IS_LIST) {
            index = (mLayoutManager).findFirstVisibleItemPosition();
            vi = listView.getChildAt(0);
        } else {
            index = (mLayoutManagerGrid).findFirstVisibleItemPosition();
            vi = listView.getChildAt(0);
        }

        int top = (vi == null) ? 0 : vi.getTop();

        outState.putInt("index", index);
        outState.putInt("top", top);
        outState.putParcelableArrayList("list", LIST_ELEMENTS);
        outState.putString("CURRENT_PATH", CURRENT_PATH);
        outState.putBoolean("selection", selection);
        outState.putInt("openMode", openMode.ordinal());
        outState.putInt("folder_count", folder_count);
        outState.putInt("file_count", file_count);

        if (selection) {
            outState.putIntegerArrayList("position", adapter.getCheckedItemsIndex());
        }

        outState.putBoolean("results", results);

        if (openMode == OpenMode.SMB) {
            outState.putString("SmbPath", smbPath);
        }
    }
}

From source file:com.vegnab.vegnab.MainVNActivity.java

@Override
public void onNewItemButtonClicked(int screenToReturnTo, long visitId, long subplotId, boolean presenceOnly) {
    // presenceOnly is not used by Species Select, but passed along to Edit Species
    SelectSpeciesFragment selSppFrag = new SelectSpeciesFragment();
    Bundle args = new Bundle();

    // screenTag can serve both as this fn's switch and the tag name of the fragment instance
    // args.putString(SelectSpeciesFragment.ARG_TAG_ID, screenTag);

    // provide Visit and Subplot IDs, so selector can check for duplicate codes
    args.putLong(SelectSpeciesFragment.ARG_VISIT_ID, visitId);
    args.putLong(SelectSpeciesFragment.ARG_SUBPLOT_TYPE_ID, subplotId);
    // presenceOnly not used by SppSelect, but passed along to Edit Spp
    args.putBoolean(SelectSpeciesFragment.ARG_PRESENCE_ONLY_SUBPLOT, presenceOnly);
    args.putLong(SelectSpeciesFragment.ARG_PROJECT_ID, mProjectId);
    args.putLong(SelectSpeciesFragment.ARG_NAMER_ID, mNamerId);

    selSppFrag.setArguments(args);// w w  w  .  ja  v  a2 s . c o m
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    // replace the fragment in the fragment container with this new fragment and
    // put the present fragment on the backstack so the user can navigate back to it
    // the tag is for the fragment now being added, not the one replaced
    transaction.replace(R.id.fragment_container, selSppFrag, Tags.SELECT_SPECIES);
    transaction.addToBackStack(null);
    transaction.commit();
}

From source file:com.test.onesignal.GenerateNotificationRunner.java

@Test
public void shouldUpdateNormalNotificationDisplayWhenReplacingANotification() throws Exception {
    // Setup - init
    OneSignal.setInFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification);
    OneSignal.init(blankActivity, "123456789", "b2f7f966-d8cc-11e4-bed1-df8f05be55ba");
    threadAndTaskWait();//from   w  w  w. j  ava2  s .c o  m

    // Setup - Display 2 notifications with the same group and collapse_id
    Bundle bundle = getBaseNotifBundle("UUID1");
    bundle.putString("grp", "test1");
    bundle.putString("collapse_key", "1");
    NotificationBundleProcessor_ProcessFromGCMIntentService(blankActivity, bundle, null);

    bundle = getBaseNotifBundle("UUID2");
    bundle.putString("grp", "test1");
    bundle.putString("collapse_key", "1");
    NotificationBundleProcessor_ProcessFromGCMIntentService(blankActivity, bundle, null);

    // Test - Summary created and sub notification. Summary will look the same as the normal notification.
    Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
    Iterator<Map.Entry<Integer, PostedNotification>> postedNotifsIterator = postedNotifs.entrySet().iterator();
    Assert.assertEquals(2, postedNotifs.size());
    PostedNotification postedSummaryNotification = postedNotifsIterator.next().getValue();
    Assert.assertEquals(notifMessage, postedSummaryNotification.getShadow().getContentText());
    Assert.assertEquals(Notification.FLAG_GROUP_SUMMARY,
            postedSummaryNotification.notif.flags & Notification.FLAG_GROUP_SUMMARY);

    int lastNotifId = postedNotifsIterator.next().getValue().id;
    ShadowRoboNotificationManager.notifications.clear();

    // Setup - Restore
    bundle = getBaseNotifBundle("UUID2");
    bundle.putString("grp", "test1");
    bundle = createInternalPayloadBundle(bundle);
    bundle.putInt("android_notif_id", lastNotifId);
    bundle.putBoolean("restoring", true);
    NotificationBundleProcessor_ProcessFromGCMIntentService_NoWrap(blankActivity, bundle, null);

    // Test - Restored notifications display exactly the same as they did when recevied.
    postedNotifs = ShadowRoboNotificationManager.notifications;
    postedNotifsIterator = postedNotifs.entrySet().iterator();
    // Test - 1 notifi + 1 summary
    Assert.assertEquals(2, postedNotifs.size());
    Assert.assertEquals(notifMessage, postedSummaryNotification.getShadow().getContentText());
    Assert.assertEquals(Notification.FLAG_GROUP_SUMMARY,
            postedSummaryNotification.notif.flags & Notification.FLAG_GROUP_SUMMARY);
}