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:it.scoppelletti.mobilepower.widget.DateControl.java

protected void onSaveInstanceState(Bundle outState) {
    if (!StringUtils.isBlank(myDialogTag)) {
        outState.putString(DateControl.STATE_DIALOGTAG, myDialogTag);
    }/*from ww w.ja  va2s.c o m*/
    if (myIsEmptyAllowed) {
        outState.putBoolean(DateControl.STATE_ISEMPTYALLOWED, true);
    }
    if (myIsResetEnabled) {
        outState.putBoolean(DateControl.STATE_ISRESETENABLED, true);
    }
    if (!ValueTools.isNullOrEmpty(myValue)) {
        outState.putParcelable(DateControl.STATE_VALUE, myValue);
    }
    if (myValueControl.getError() != null) {
        outState.putCharSequence(DateControl.STATE_ERROR, myValueControl.getError());
    }
}

From source file:ch.citux.td.ui.TDActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);//from ww  w.j ava2  s. co  m
    ButterKnife.inject(this);

    Context contextThemeWrapper = new ContextThemeWrapper(this, R.style.Theme_TD_Light);
    LayoutInflater inflater = LayoutInflater.from(this).cloneInContext(contextThemeWrapper);
    refreshView = inflater.inflate(R.layout.action_refresh, null);

    initNavigation();
    updateUser();

    if (favoritesFragment == null) {
        Bundle args = new Bundle();
        args.putBoolean(TDConfig.SETTINGS_CHANNEL_NAME, hasUsername);

        favoritesFragment = new FavoritesFragment();
        favoritesFragment.setArgs(args);

        getSupportFragmentManager().beginTransaction().add(R.id.content, favoritesFragment).commit();
    } else {
        replaceFragment(favoritesFragment);
    }
}

From source file:com.friedran.appengine.dashboard.client.AppEngineDashboardClient.java

/**
 * Send an authenticated GetChart request asynchronously and return its results to the given callback.
 *//*from   w  w w.jav a 2 s  .  co m*/
public void executeGetChartUrl(String appID, int chartTypeID, int chartWindowID,
        final PostExecuteCallback postGetChartUrlCallback) {

    String url = String.format("https://appengine.google.com/dashboard/stats?app_id=s~%s&type=%d&window=%d",
            appID, chartTypeID, chartWindowID);

    new AuthenticatedRequestTask(url, new AuthenticatedRequestTaskBackgroundCallback() {
        @Override
        public Bundle run(final HttpEntity httpResponseEntity) {
            Bundle result = new Bundle();

            try {
                JSONObject jsonData = new JSONObject(EntityUtils.toString(httpResponseEntity));
                String chart_url = jsonData.getString("chart_url");

                result.putBoolean(KEY_RESULT, true);
                result.putString(KEY_CHART_URL, chart_url);

            } catch (Exception e) {
                LogUtils.e("AppEngineDashboardClient#onPostExecuteGetChartURL",
                        "Exception caught when tried to parse result", e);
                e.printStackTrace();
                result.putBoolean(KEY_RESULT, false);
            }

            return result;
        }
    }, postGetChartUrlCallback).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
}

From source file:com.best.ui.Otpdescdetail.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    System.out.println("in onOptionsItemSelected of stops.java");
    // Handle item selection
    switch (item.getItemId()) {
    /*case com.best.ui.R.id.mnusearch:
        System.out.println("in mnusearch of stops.java");
        if(tripsDisplayed == false)//  w ww . j  a va 2  s .com
        {
            Intent intent = new Intent(m_context, Search.class);
            intent.putExtra( "callFromStops" , true );
            me.startActivityForResult( intent, 5 );
            return true;
        }
        else
        {
            Intent intent = new Intent(m_context, Search.class);
            intent.putExtra( "callFromStops" , false );
            me.startActivityForResult( intent, 5 );
            return true;
        } */

    case com.best.ui.R.id.map:
        if (NearTripRoute._stopLat != null && NearTripRoute._stopLon != null) {
            System.out.println("in map of stops.java");
            Bundle bundle1 = new Bundle();
            bundle1.putBoolean("showSingle", false);
            bundle1.putSerializable("StopsGeoX", NearTripRoute._stopLat);
            bundle1.putSerializable("StopsGeoY", NearTripRoute._stopLon);
            Intent intent1 = new Intent(m_context, Map.class);
            intent1.putExtras(bundle1);
            me.startActivityForResult(intent1, 5);
        }
        return true;

    default:
        System.out.println("in default of stops.java");
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.eutectoid.dosomething.picker.FriendPickerFragment.java

void saveSettingsToBundle(Bundle outState) {
    super.saveSettingsToBundle(outState);

    outState.putString(USER_ID_BUNDLE_KEY, userId);
    outState.putBoolean(MULTI_SELECT_BUNDLE_KEY, multiSelect);
}

From source file:cn.edu.wyu.documentviewer.RecentLoader.java

@Override
public DirectoryResult loadInBackground() {
    if (mFirstPassLatch == null) {
        // First time through we kick off all the recent tasks, and wait
        // around to see if everyone finishes quickly.

        final Collection<RootInfo> roots = mRoots.getMatchingRootsBlocking(mState);
        for (RootInfo root : roots) {
            if ((root.flags & Root.FLAG_SUPPORTS_RECENTS) != 0) {
                final RecentTask task = new RecentTask(root.authority, root.rootId);
                mTasks.put(root, task);/*from   w  w  w . ja  v a2s.c om*/
            }
        }

        mFirstPassLatch = new CountDownLatch(mTasks.size());
        for (RecentTask task : mTasks.values()) {
            ProviderExecutor.forAuthority(task.authority).execute(task);
        }

        try {
            mFirstPassLatch.await(MAX_FIRST_PASS_WAIT_MILLIS, TimeUnit.MILLISECONDS);
            mFirstPassDone = true;
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    final long rejectBefore = System.currentTimeMillis() - REJECT_OLDER_THAN;

    // Collect all finished tasks
    boolean allDone = true;
    List<Cursor> cursors = Lists.newArrayList();
    for (RecentTask task : mTasks.values()) {
        if (task.isDone()) {
            try {
                final Cursor cursor = task.get();
                if (cursor == null)
                    continue;

                final FilteringCursorWrapper filtered = new FilteringCursorWrapper(cursor, mState.acceptMimes,
                        RECENT_REJECT_MIMES, rejectBefore) {
                    @Override
                    public void close() {
                        // Ignored, since we manage cursor lifecycle internally
                    }
                };
                cursors.add(filtered);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            } catch (ExecutionException e) {
                // We already logged on other side
            }
        } else {
            allDone = false;
        }
    }

    if (LOGD) {
        Log.d(TAG, "Found " + cursors.size() + " of " + mTasks.size() + " recent queries done");
    }

    final DirectoryResult result = new DirectoryResult();
    result.sortOrder = SORT_ORDER_LAST_MODIFIED;

    // Hint to UI if we're still loading
    final Bundle extras = new Bundle();
    if (!allDone) {
        extras.putBoolean(DocumentsContract.EXTRA_LOADING, true);
    }

    final Cursor merged;
    if (cursors.size() > 0) {
        merged = new MergeCursor(cursors.toArray(new Cursor[cursors.size()]));
    } else {
        // Return something when nobody is ready
        merged = new MatrixCursor(new String[0]);
    }

    final SortingCursorWrapper sorted = new SortingCursorWrapper(merged, result.sortOrder) {
        @Override
        public Bundle getExtras() {
            return extras;
        }
    };

    result.cursor = sorted;

    return result;
}

From source file:com.nextgis.firereporter.ScanexHttpLogin.java

@Override
protected Void doInBackground(String... urls) {
    if (HttpGetter.IsNetworkAvailible(mContext)) {
        String sUser = urls[0];//from   w w  w .  j a v a2 s. co m
        String sPass = urls[1];

        try {

            // Create a new HttpClient
            HttpClient httpclient = new DefaultHttpClient();

            // step 1. open login dialog
            String sRedirect = "http://fires.kosmosnimki.ru/SAPI/oAuthCallback.html&authServer=MyKosmosnimki";
            String sURL = "http://fires.kosmosnimki.ru/SAPI/LoginDialog.ashx?redirect_uri="
                    + Uri.encode(sRedirect);
            HttpGet httpget = new HttpGet(sURL);
            HttpParams params = httpget.getParams();
            params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
            httpget.setParams(params);
            HttpResponse response = httpclient.execute(httpget);

            //2 get cookie and params            
            Header head = response.getFirstHeader("Set-Cookie");
            String sCookie = head.getValue();

            head = response.getFirstHeader("Location");
            String sLoc = head.getValue();

            Uri uri = Uri.parse(sLoc);
            String sClientId = uri.getQueryParameter("client_id");
            String sScope = uri.getQueryParameter("scope");
            String sState = uri.getQueryParameter("state");

            String sPostUri = "http://my.kosmosnimki.ru/Account/LoginDialog?redirect_uri="
                    + Uri.encode(sRedirect) + "&client_id=" + sClientId + "&scope=" + sScope + "&state="
                    + sState;

            HttpPost httppost = new HttpPost(sPostUri);

            params = httppost.getParams();
            params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
            httppost.setHeader("Cookie", sCookie);

            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("email", sUser));
            nameValuePairs.add(new BasicNameValuePair("password", sPass));
            nameValuePairs.add(new BasicNameValuePair("IsApproved", "true"));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            response = httpclient.execute(httppost);
            head = response.getFirstHeader("Set-Cookie");

            if (head == null) {
                mError = mContext.getString(R.string.noNetwork);
                return null;
            }

            sCookie += "; " + head.getValue();
            head = response.getFirstHeader("Location");
            sLoc = head.getValue();

            uri = Uri.parse(sLoc);
            String sCode = uri.getQueryParameter("code");
            sState = uri.getQueryParameter("state");

            //3 get 
            String sGetUri = "http://fires.kosmosnimki.ru/SAPI/Account/logon/?authServer=MyKosmosnimki&code="
                    + sCode + "&state=" + sState;
            httpget = new HttpGet(sGetUri);
            httpget.setHeader("Cookie", sCookie);
            params = httpget.getParams();
            params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
            httpget.setParams(params);
            response = httpclient.execute(httpget);

            head = response.getFirstHeader("Set-Cookie");
            if (head == null) {
                mError = mContext.getString(R.string.noNetwork);
                return null;
            }
            sCookie += "; " + head.getValue();

            Bundle bundle = new Bundle();
            if (sCookie.length() > 0) {
                //if(bGetCookie){
                bundle.putBoolean(GetFiresService.ERROR, false);
                bundle.putString(GetFiresService.JSON, sCookie);
                //bundle.putString("json", mContent);
            } else {
                bundle.putBoolean(GetFiresService.ERROR, true);
            }

            bundle.putInt(GetFiresService.SOURCE, mnType);
            Message msg = new Message();
            msg.setData(bundle);
            if (mEventReceiver != null) {
                mEventReceiver.sendMessage(msg);
            }

        } catch (ClientProtocolException e) {
            mError = e.getMessage();
            return null;
        } catch (IOException e) {
            mError = e.getMessage();
            return null;
        } catch (Exception e) {
            mError = e.getMessage();
            return null;
        }
    } else {
        Bundle bundle = new Bundle();
        bundle.putBoolean(GetFiresService.ERROR, true);
        bundle.putString(GetFiresService.ERR_MSG, mContext.getString(R.string.noNetwork));
        bundle.putInt(GetFiresService.SOURCE, mnType);

        Message msg = new Message();
        msg.setData(bundle);
        if (mEventReceiver != null) {
            mEventReceiver.sendMessage(msg);
        }
    }
    return null;
}

From source file:com.tassadar.multirommgr.installfragment.InstallCard.java

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

    if (m_view == null)
        return;/*from   w  w w  . j  a v  a  2s.c o m*/

    CheckBox b = (CheckBox) m_view.findViewById(R.id.install_multirom);
    outState.putBoolean("install_multirom", b.isChecked());

    b = (CheckBox) m_view.findViewById(R.id.install_recovery);
    outState.putBoolean("install_recovery", b.isChecked());

    b = (CheckBox) m_view.findViewById(R.id.install_kernel);
    if (!b.isChecked()) {
        outState.putString("install_kernel", "false");
    } else {
        Spinner s = (Spinner) m_view.findViewById(R.id.kernel_options);
        outState.putString("install_kernel", (String) s.getSelectedItem());
    }
}

From source file:ro.tudorluca.gpstracks.android.MainActivity.java

/**
 * Stores activity data in the Bundle.//from  w  w  w.java 2s.  c om
 */
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putBoolean(REQUESTING_LOCATION_UPDATES_KEY, mRequestingLocationUpdates);
    savedInstanceState.putParcelable(LOCATION_KEY, mCurrentLocation);
    savedInstanceState.putString(LAST_UPDATED_TIME_STRING_KEY, mLastUpdateTime);
    super.onSaveInstanceState(savedInstanceState);
}

From source file:android.support.car.app.menu.CarDrawerActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean(KEY_DRAWERSHOWING, mDrawerShowing);
    mUiController.onSaveInstanceState(outState);
}