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.spoiledmilk.ibikecph.util.HttpUtils.java

public static Message JSONtoMessage(JsonNode result) {
    Message ret = new Message();
    Bundle data = new Bundle();
    if (result != null) {
        data.putBoolean("success", result.get("success").asBoolean());
        data.putString("info", result.get("info").asText());
        if (result.has("errors"))
            data.putString("errors", result.get("errors").asText());
        JsonNode dataNode = result.get("data");
        if (dataNode != null) {
            if (dataNode.has("id"))
                data.putInt("id", dataNode.get("id").asInt());
            if (dataNode.has("auth_token"))
                data.putString("auth_token", dataNode.get("auth_token").asText());
        }//www  . j a  v a 2  s .c  o m
    }
    ret.setData(data);
    return ret;
}

From source file:net.sf.sprockets.app.ui.SprocketsPreferenceFragment.java

/**
 * Display the preferences and send changes to analytics.
 *
 * @param trackChanges if true, {@link Trackers#use(Context, Tracker) Trackers.use} must have
 *                     already been called
 * @since 2.6.0//from  w w w .ja  v  a2 s .  c  o m
 */
public static SprocketsPreferenceFragment newInstance(int prefsResId, boolean trackChanges) {
    SprocketsPreferenceFragment frag = new SprocketsPreferenceFragment();
    Bundle args = Fragments.arguments(frag);
    args.putInt(PREFS, prefsResId);
    args.putBoolean(TRACK_CHANGES, trackChanges);
    return frag;
}

From source file:com.nextgis.mobile.map.RemoteTMSLayer.java

protected static void create(final MapBase map, String layerName, String layerUrl, int tmsType) {
    String sErr = map.getContext().getString(R.string.error_occurred);
    try {//from  w  ww.  j  a v  a2s  .c  o  m
        File outputPath = map.cretateLayerStorage();
        //create layer description file
        JSONObject oJSONRoot = new JSONObject();
        oJSONRoot.put(JSON_NAME_KEY, layerName);
        oJSONRoot.put(JSON_URL_KEY, layerUrl);
        oJSONRoot.put(JSON_VISIBILITY_KEY, true);
        oJSONRoot.put(JSON_TYPE_KEY, LAYERTYPE_TMS);
        oJSONRoot.put(JSON_TMSTYPE_KEY, tmsType);

        //send message to handler to show error or add new layer

        File file = new File(outputPath, LAYER_CONFIG);
        FileUtil.createDir(outputPath);
        FileUtil.writeToFile(file, oJSONRoot.toString());

        if (map.getMapEventsHandler() != null) {
            Bundle bundle = new Bundle();
            bundle.putBoolean(BUNDLE_HASERROR_KEY, false);
            bundle.putString(BUNDLE_MSG_KEY, map.getContext().getString(R.string.message_layer_added));
            bundle.putInt(BUNDLE_TYPE_KEY, MSGTYPE_LAYER_ADDED);
            bundle.putSerializable(BUNDLE_PATH_KEY, outputPath);

            Message msg = new Message();
            msg.setData(bundle);
            map.getMapEventsHandler().sendMessage(msg);
        }
        return;

    } catch (FileNotFoundException e) {
        Log.d(TAG, "Exception: " + e.getLocalizedMessage());
        sErr += ": " + e.getLocalizedMessage();
    } catch (JSONException e) {
        Log.d(TAG, "Exception: " + e.getLocalizedMessage());
        sErr += ": " + e.getLocalizedMessage();
    } catch (IOException e) {
        Log.d(TAG, "Exception: " + e.getLocalizedMessage());
        sErr += ": " + e.getLocalizedMessage();
    }
    //if we here something wrong occurred
    Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show();
}

From source file:at.maui.cheapcast.fragment.DonationsFragment.java

/**
 * Instantiate DonationsFragment./*from w ww. j a v a2 s.c o  m*/
 *
 * @param debug               You can use BuildConfig.DEBUG to propagate the debug flag from your app to the Donations library
 * @param paypalEnabled       Enable PayPal donations
 * @param paypalUser          Your PayPal email address
 * @param paypalCurrencyCode  Currency code like EUR. See here for other codes:
 *                            https://developer.paypal.com/webapps/developer/docs/classic/api/currency_codes/#id09A6G0U0GYK
 * @param paypalItemName      Display item name on PayPal, like "Donation for NTPSync"
 * @param flattrEnabled       Enable Flattr donations
 * @param flattrProjectUrl    The project URL used on Flattr
 * @param flattrUrl           The Flattr URL to your thing. NOTE: Enter without http://
 * @return DonationsFragment
 */
public static DonationsFragment newInstance(boolean debug, boolean paypalEnabled, String paypalUser,
        String paypalCurrencyCode, String paypalItemName, boolean flattrEnabled, String flattrProjectUrl,
        String flattrUrl) {
    DonationsFragment donationsFragment = new DonationsFragment();
    Bundle args = new Bundle();

    args.putBoolean(ARG_DEBUG, debug);

    args.putBoolean(ARG_PAYPAL_ENABLED, paypalEnabled);
    args.putString(ARG_PAYPAL_USER, paypalUser);
    args.putString(ARG_PAYPAL_CURRENCY_CODE, paypalCurrencyCode);
    args.putString(ARG_PAYPAL_ITEM_NAME, paypalItemName);

    args.putBoolean(ARG_FLATTR_ENABLED, flattrEnabled);
    args.putString(ARG_FLATTR_PROJECT_URL, flattrProjectUrl);
    args.putString(ARG_FLATTR_URL, flattrUrl);

    donationsFragment.setArguments(args);
    return donationsFragment;
}

From source file:com.facebook.LegacyTokenCacheTest.java

private static void putBoolean(String key, Bundle bundle) {
    bundle.putBoolean(key, random.nextBoolean());
}

From source file:dk.kk.ibikecphlib.util.HttpUtils.java

public static Message JSONtoUserDataMessage(JsonNode result, UserData userData) {
    Message ret = new Message();
    Bundle data = new Bundle();
    if (result != null) {
        data.putBoolean("success", result.get("success").asBoolean());
        data.putString("info", result.get("info").asText());
        if (result.has("invalid_token")) {
            if (result.get("invalid_token").asBoolean()) {
                data.putBoolean("invalid_token", result.get("invalid_token").asBoolean());
                IBikeApplication.logoutWrongToken();
            }//from w  ww .ja  v a  2  s .  c o m
        }
        if (result != null && result.has("data")) {
            JsonNode dataNode = result.get("data");
            if (dataNode != null) {
                data.putInt("id", dataNode.get("id").asInt());
                data.putString("name", dataNode.get("name").asText());
                data.putString("email", dataNode.get("email").asText());
                if (dataNode.has("image_url"))
                    data.putString("image_url", dataNode.get("image_url").asText());
            }
        }
        ret.setData(data);
    }
    return ret;
}

From source file:ca.rmen.android.networkmonitor.app.dialog.DialogFragmentFactory.java

/**
 * Show a visible dialog fragment to choose a folder or file
 *///from   w  w  w  .  j  ava 2 s  .co  m
public static void showFileChooserDialog(FragmentActivity activity, File initialFolder, boolean foldersOnly,
        int actionId) {
    Log.v(TAG, "showFileChooserDialog");
    Bundle arguments = new Bundle(3);
    arguments.putInt(EXTRA_ACTION_ID, actionId);
    if (initialFolder != null)
        arguments.putSerializable(FileChooserDialogFragment.EXTRA_FILE_CHOOSER_INITIAL_FOLDER, initialFolder);
    arguments.putBoolean(FileChooserDialogFragment.EXTRA_FILE_CHOOSER_FOLDERS_ONLY, foldersOnly);
    FileChooserDialogFragment result = new FileChooserDialogFragment();
    result.setArguments(arguments);
    result.show(activity.getSupportFragmentManager(), FileChooserDialogFragment.class.getSimpleName());
}

From source file:it.scoppelletti.mobilepower.app.ProgressDialogFragment.java

/**
 * Istanzia un frammento./* w  ww .  j av  a 2s. c  om*/
 * 
 * @param  titleId    Identificatore della risorsa del titolo.
 * @param  max        Valore massimo dell’indice di avanzamento. Se
 *                    è minore o uguale a {@code 0}, l’indice
 *                    di avanzamento è indeterminato.
 * @param  cancelable Indicatore di dialogo cancellabile.
 * @return            Frammento.
 */
public static ProgressDialogFragment newInstance(int titleId, int max, boolean cancelable) {
    Bundle args;
    ProgressDialogFragment fragment;

    args = new Bundle();
    args.putInt(ProgressDialogFragment.ARG_TITLEID, titleId);
    args.putInt(ProgressDialogFragment.ARG_MAX, max);
    args.putBoolean(ProgressDialogFragment.ARG_CANCELABLE, cancelable);

    fragment = new ProgressDialogFragment();
    fragment.setArguments(args);
    fragment.setCancelable(cancelable);

    return fragment;
}

From source file:Main.java

/**
 *  //from  ww  w .j ava  2s.  co m
 * @param bundle
 * @param key
 * @param object
 */
private static void putBundleObject(Bundle bundle, String key, Object object) {
    if (bundle != null && object != null && !TextUtils.isEmpty(key)) {
        if (object instanceof String) {
            bundle.putString(key, (String) object);
        } else if (object instanceof Boolean) {
            bundle.putBoolean(key, (Boolean) object);
        } else if (object instanceof Double) {
            bundle.putDouble(key, (Double) object);
        } else if (object instanceof Float) {
            Float value = (Float) object;
            bundle.putDouble(key, (double) value);
        } else if (object instanceof Integer) {
            bundle.putInt(key, (Integer) object);
        } else if (object instanceof Long) {
            bundle.putLong(key, (Long) object);
        } else if (object instanceof JSONObject) {
            object = parseBundle((JSONObject) object);
            bundle.putBundle(key, (Bundle) object);
        } else if (object instanceof JSONArray) {
            int elementQuantity = ((JSONArray) object).length();
            Bundle subBundle = new Bundle(elementQuantity);
            for (int i = 0; i < elementQuantity; i++) {
                Object subObject = getArrayValue((JSONArray) object, i, null);
                if (subObject != null) {
                    putBundleObject(subBundle, key, subObject);
                }
            }
        }
    }
}

From source file:com.miz.mizuu.fragments.RelatedMoviesFragment.java

public static RelatedMoviesFragment newInstance(String tmdbId, boolean setBackground) {
    RelatedMoviesFragment pageFragment = new RelatedMoviesFragment();
    Bundle bundle = new Bundle();
    bundle.putString("tmdbId", tmdbId);
    bundle.putBoolean("setBackground", setBackground);
    pageFragment.setArguments(bundle);/* w ww .  j a v a 2  s  .c  o  m*/
    return pageFragment;
}