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:com.github.yuukis.businessmap.app.ContactsTaskFragment.java

private void showProgress() {
    String title = getString(R.string.title_geocoding);
    String message = getString(R.string.message_geocoding);
    int max = mGeocodingResultCache.size();

    Bundle args = new Bundle();
    args.putString(ProgressDialogFragment.TITLE, title);
    args.putString(ProgressDialogFragment.MESSAGE, message);
    args.putBoolean(ProgressDialogFragment.CANCELABLE, true);
    args.putInt(ProgressDialogFragment.MAX, max);
    final DialogFragment dialog = ProgressDialogFragment.newInstance();
    dialog.setArguments(args);/*from  ww  w. j a v  a  2s.  c  om*/
    if (getActivity() != null) {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                dialog.show(getActivity().getSupportFragmentManager(), ProgressDialogFragment.TAG);
            }
        });
    }
}

From source file:cn.hbm.superwechat.activity.ContactlistFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (((MainActivity) getActivity()).isConflict) {
        outState.putBoolean("isConflict", true);
    } else if (((MainActivity) getActivity()).getCurrentAccountRemoved()) {
        outState.putBoolean(Constant.ACCOUNT_REMOVED, true);
    }/*w w w .  j a v a  2 s  .  co  m*/

}

From source file:com.mirasense.scanditsdk.plugin.FullScreenPickerActivity.java

private Bundle manualSearchResultsToBundle(String entry) {
    Bundle bundle = new Bundle();
    if (mLegacyMode) {
        bundle.putString("barcode", entry.trim());
        bundle.putString("symbology", "UNKNOWN");
    } else {// w  w  w .  j a  v a 2s.  c om
        JSONArray args = Marshal.createEventArgs(ScanditSDK.DID_MANUAL_SEARCH_EVENT, entry);
        bundle.putString("jsonString", args.toString());
    }
    // no need to wait for result
    bundle.putBoolean("waitForResult", false);
    return bundle;
}

From source file:com.android.mail.browse.ConversationPagerAdapter.java

@Override
public Parcelable saveState() {
    LogUtils.d(LOG_TAG, "IN PagerAdapter.saveState. this=%s", this);
    Bundle state = (Bundle) super.saveState(); // superclass uses a Bundle
    if (state == null) {
        state = new Bundle();
    }// w w  w .ja  v  a  2 s . c  o m
    state.putBoolean(BUNDLE_DETACHED_MODE, mDetachedMode);
    return state;
}

From source file:com.easemob.chatuidemo.activity.ContactlistFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (((com.easemob.chatuidemo.activity.MainActivity) getActivity()).isConflict) {
        outState.putBoolean("isConflict", true);
    } else if (((com.easemob.chatuidemo.activity.MainActivity) getActivity()).getCurrentAccountRemoved()) {
        outState.putBoolean(Constant.ACCOUNT_REMOVED, true);
    }/*from w  w  w  . j a  v a  2  s.c o  m*/

}

From source file:com.facebook.SharedPreferencesTokenCache.java

private void deserializeKey(String key, Bundle bundle) throws JSONException {
    String jsonString = cache.getString(key, "{}");
    JSONObject json = new JSONObject(jsonString);

    String valueType = json.getString(JSON_VALUE_TYPE);

    if (valueType.equals(TYPE_BOOLEAN)) {
        bundle.putBoolean(key, json.getBoolean(JSON_VALUE));
    } else if (valueType.equals(TYPE_BOOLEAN_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        boolean[] array = new boolean[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = jsonArray.getBoolean(i);
        }//from ww w  .  j a v a  2 s .  c  o m
        bundle.putBooleanArray(key, array);
    } else if (valueType.equals(TYPE_BYTE)) {
        bundle.putByte(key, (byte) json.getInt(JSON_VALUE));
    } else if (valueType.equals(TYPE_BYTE_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        byte[] array = new byte[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = (byte) jsonArray.getInt(i);
        }
        bundle.putByteArray(key, array);
    } else if (valueType.equals(TYPE_SHORT)) {
        bundle.putShort(key, (short) json.getInt(JSON_VALUE));
    } else if (valueType.equals(TYPE_SHORT_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        short[] array = new short[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = (short) jsonArray.getInt(i);
        }
        bundle.putShortArray(key, array);
    } else if (valueType.equals(TYPE_INTEGER)) {
        bundle.putInt(key, json.getInt(JSON_VALUE));
    } else if (valueType.equals(TYPE_INTEGER_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        int[] array = new int[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = jsonArray.getInt(i);
        }
        bundle.putIntArray(key, array);
    } else if (valueType.equals(TYPE_LONG)) {
        bundle.putLong(key, json.getLong(JSON_VALUE));
    } else if (valueType.equals(TYPE_LONG_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        long[] array = new long[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = jsonArray.getLong(i);
        }
        bundle.putLongArray(key, array);
    } else if (valueType.equals(TYPE_FLOAT)) {
        bundle.putFloat(key, (float) json.getDouble(JSON_VALUE));
    } else if (valueType.equals(TYPE_FLOAT_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        float[] array = new float[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = (float) jsonArray.getDouble(i);
        }
        bundle.putFloatArray(key, array);
    } else if (valueType.equals(TYPE_DOUBLE)) {
        bundle.putDouble(key, json.getDouble(JSON_VALUE));
    } else if (valueType.equals(TYPE_DOUBLE_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        double[] array = new double[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = jsonArray.getDouble(i);
        }
        bundle.putDoubleArray(key, array);
    } else if (valueType.equals(TYPE_CHAR)) {
        String charString = json.getString(JSON_VALUE);
        if (charString != null && charString.length() == 1) {
            bundle.putChar(key, charString.charAt(0));
        }
    } else if (valueType.equals(TYPE_CHAR_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        char[] array = new char[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            String charString = jsonArray.getString(i);
            if (charString != null && charString.length() == 1) {
                array[i] = charString.charAt(0);
            }
        }
        bundle.putCharArray(key, array);
    } else if (valueType.equals(TYPE_STRING)) {
        bundle.putString(key, json.getString(JSON_VALUE));
    } else if (valueType.equals(TYPE_STRING_LIST)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        int numStrings = jsonArray.length();
        ArrayList<String> stringList = new ArrayList<String>(numStrings);
        for (int i = 0; i < numStrings; i++) {
            Object jsonStringValue = jsonArray.get(i);
            stringList.add(i, jsonStringValue == JSONObject.NULL ? null : (String) jsonStringValue);
        }
        bundle.putStringArrayList(key, stringList);
    }
}

From source file:edu.cnu.PowerTutor.ui.PowerViewer.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean("collecting", collecting);
    outState.putStringArray("componentNames", componentNames);
    outState.putInt("noUidMask", noUidMask);
}

From source file:com.xorcode.andtweet.TweetListActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putBoolean(BUNDLE_KEY_IS_LOADING, mIsLoading);
    super.onSaveInstanceState(outState);
}

From source file:at.jclehner.rxdroid.NotificationReceiver.java

private void scheduleNextBeginOrEndAlarm(DoseTimeInfo dtInfo, boolean scheduleEnd) {
    final int doseTime = scheduleEnd ? dtInfo.activeDoseTime() : dtInfo.nextDoseTime();
    final Calendar time = dtInfo.currentTime();
    final Date doseTimeDate = scheduleEnd ? dtInfo.activeDate() : dtInfo.nextDoseTimeDate();

    final Bundle alarmExtras = new Bundle();
    alarmExtras.putSerializable(EXTRA_DATE, doseTimeDate);
    alarmExtras.putInt(EXTRA_DOSE_TIME, doseTime);
    alarmExtras.putBoolean(EXTRA_IS_DOSE_TIME_END, scheduleEnd);
    alarmExtras.putBoolean(EXTRA_SILENT, false);

    long offset;/*  w  ww .j a  v a 2s . c  o m*/

    if (scheduleEnd)
        offset = Settings.getMillisUntilDoseTimeEnd(time, doseTime);
    else
        offset = Settings.getMillisUntilDoseTimeBegin(time, doseTime);

    long triggerAtMillis = time.getTimeInMillis() + offset;

    final long alarmRepeatMins = Settings.getStringAsInt(Settings.Keys.ALARM_REPEAT, 0);
    final long alarmRepeatMillis = alarmRepeatMins == -1 ? 10000 : alarmRepeatMins * 60000;

    if (alarmRepeatMillis > 0) {
        alarmExtras.putBoolean(EXTRA_FORCE_UPDATE, true);

        final long base = dtInfo.activeDate().getTime();
        int i = 0;

        while (base + (i * alarmRepeatMillis) < time.getTimeInMillis())
            ++i;

        // We must tell the receiver whether the alarm is an actual dose time's
        // end or begin, or merely a repetition.

        final long triggerAtMillisWithRepeatedAlarm = base + i * alarmRepeatMillis;
        if (triggerAtMillisWithRepeatedAlarm < triggerAtMillis) {
            triggerAtMillis = triggerAtMillisWithRepeatedAlarm;
            alarmExtras.putBoolean(EXTRA_IS_ALARM_REPETITION, true);
        }

        //triggerAtMillis = base + (i * alarmRepeatMillis);
    }

    final long triggerDiffFromNow = triggerAtMillis - System.currentTimeMillis();
    if (triggerDiffFromNow < 0) {
        if (triggerDiffFromNow < -50000)
            Log.w(TAG, "Alarm time is in the past by less than 5 seconds.");
        else {
            Log.w(TAG, "Alarm time is in the past. Ignoring...");
            return;
        }
    }

    if (alarmExtras.getBoolean(EXTRA_IS_ALARM_REPETITION))
        Log.i(TAG, "Scheduling next alarm for " + DateTime.toString(triggerAtMillis));
    else {
        Log.i(TAG, "Scheduling " + (scheduleEnd ? "end" : "begin") + " of doseTime " + doseTime + " on date "
                + DateTime.toDateString(doseTimeDate) + " for " + DateTime.toString(triggerAtMillis));
    }

    Log.i(TAG, "Alarm will go off in " + Util.millis(triggerDiffFromNow));

    mAlarmMgr.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, createOperation(alarmExtras));
}

From source file:au.org.ala.fielddata.mobile.CollectSurveyData.java

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

    outState.putBoolean(GPS_TRACKING_BUNDLE_KEY, gpsTrackingOn);
    outState.putInt(GPS_TIMEOUT_BUNDLE_KEY, gpsTimeoutCount);
}