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.ymt.demo1.plates.knowledge.KnowledgeItemListViewFragment.java

public static KnowledgeItemListViewFragment getNewInstance(int knowledgeType) {
    KnowledgeItemListViewFragment fragment = new KnowledgeItemListViewFragment();
    Bundle bundle = new Bundle();
    bundle.putInt("knowledge_type", knowledgeType);
    fragment.setArguments(bundle);//w  w  w . j av  a2s  .  c om
    return fragment;
}

From source file:Main.java

public static Intent mapToIntent(Context context, Class<?> clazz, Map<String, Object> map) {
    Intent intent = new Intent(context, clazz);
    Bundle bundle = new Bundle();
    if (map != null && map.size() > 0) {
        for (String key : map.keySet()) {
            if (map.get(key) instanceof String) {
                bundle.putString(key, (String) map.get(key));
            } else if (map.get(key) instanceof Integer) {
                bundle.putInt(key, (Integer) map.get(key));
            } else if (map.get(key) instanceof Boolean) {
                bundle.putBoolean(key, (Boolean) map.get(key));
            } else if (map.get(key) instanceof Double) {
                bundle.putDouble(key, (Double) map.get(key));
            } else if (map.get(key) instanceof Long) {
                bundle.putLong(key, (Long) map.get(key));
            } else if (map.get(key) instanceof Float) {
                bundle.putFloat(key, (Float) map.get(key));
            } else if (map.get(key) instanceof Double) {
                bundle.putDouble(key, (Double) map.get(key));
            } else if (map.get(key) instanceof Serializable) {
                bundle.putSerializable(key, (Serializable) map.get(key));
            } else if (map.get(key) instanceof Parcelable) {
                bundle.putParcelable(key, (Parcelable) map.get(key));
            }/*from  w  ww  .  ja va 2  s.  co m*/
        }
    }
    return intent.putExtras(bundle);
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static Bundle addMapToBundle(HashMap<String, ?> map, Bundle bundle) {
    for (String key : map.keySet()) {
        Object value = map.get(key);
        if (value instanceof String) {
            bundle.putString(key, (String) value);
        } else if (value instanceof Integer) {
            bundle.putInt(key, (Integer) value);
        } else if (value instanceof Double) {
            bundle.putDouble(key, ((Double) value));
        } else if (value instanceof Boolean) {
            bundle.putBoolean(key, (Boolean) value);
        } else if (value instanceof HashMap) {
            bundle.putBundle(key, addMapToBundle((HashMap<String, Object>) value, new Bundle()));
        } else if (value instanceof ArrayList) {
            putArray(key, (ArrayList) value, bundle);
        }/*w  ww.ja va2 s .co  m*/
    }
    return bundle;
}

From source file:com.facebook.LegacyTokenCacheTest.java

private static void putInt(String key, Bundle bundle) {
    bundle.putInt(key, random.nextInt());
}

From source file:com.sunho.nating.fragments.DetailUnivFragment.java

/**
 * Create a new instance of DetailFragment.
 *
 * @param resourceId The resource ID of the Drawable image to show
 * @param title The title of the image/*from  w  w  w  .j  ava 2 s. c  o  m*/
 * @param x The horizontal position of the grid item in pixel
 * @param y The vertical position of the grid item in pixel
 * @param width The width of the grid item in pixel
 * @param height The height of the grid item in pixel
 * @return a new instance of DetailFragment
 */
public static DetailUnivFragment newInstance(int resourceId, String title, int x, int y, int width, int height,
        int position, String locationLat, String locationLong) {
    myLocationLat = locationLat;
    myLocationLong = locationLong;
    intentPosition = position;
    DetailUnivFragment fragment = new DetailUnivFragment();
    Bundle args = new Bundle();
    args.putInt(ARG_RESOURCE_ID, resourceId);
    args.putString(ARG_TITLE, title);
    args.putInt(ARG_X, x);
    args.putInt(ARG_Y, y);
    args.putInt(ARG_WIDTH, width);
    args.putInt(ARG_HEIGHT, height);
    fragment.setArguments(args);
    return fragment;
}

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

/**
 * Istanzia un frammento./*from www . j a v  a2 s.c om*/
 * 
 * @param  mode    Modalit&agrave;.
 * @param  titleId Identificatore della risorsa del titolo.
 * @param  textId  Identificatore della risorsa del testo.
 * @param  prefKey Chiave della preferenza che indica se la Guida &egrave;
 *                 gi&agrave; stata visualizzata.
 * @return         Frammento.
 */
public static HelpDialogFragment newInstance(int mode, int titleId, int textId, String prefKey) {
    Bundle args;
    HelpDialogFragment fragment;

    if (StringUtils.isBlank(prefKey)) {
        throw new NullPointerException("Argument prefKey is null.");
    }

    args = new Bundle();
    args.putInt(HelpDialogFragment.ARG_MODE, mode);
    args.putInt(HelpDialogFragment.ARG_TITLEID, titleId);
    args.putInt(HelpDialogFragment.ARG_TEXTID, textId);
    args.putString(HelpDialogFragment.ARG_PREFKEY, prefKey);

    fragment = new HelpDialogFragment();
    fragment.setArguments(args);

    return fragment;
}

From source file:com.example.orangeweather.JSONWeatherParser.java

public static Bundle getWeather(JSONObject jObj) throws JSONException {
    Bundle bundle = new Bundle();

    JSONObject coordObj = getObject("coord", jObj);
    bundle.putString(CityTags.CITY_NAME, getString("name", jObj));
    bundle.putInt(CityTags.CITY_ID, getInt("id", jObj));
    bundle.putInt(WeatherTags.WEATHER_DT, getInt("dt", jObj));
    bundle.putString(CityTags.CITY_COORD,
            getDMSCoordinates(getFloat("lat", coordObj), getFloat("lon", coordObj)));

    JSONObject sysObj = getObject("sys", jObj);
    bundle.putString(CityTags.CITY_SYS_COUNTRY, getString("country", sysObj));

    if (sysObj.has("sunrise")) {
        bundle.putInt(WeatherTags.WEATHER_SYS_SUNRISE, getInt("sunrise", sysObj));
    }//  w w  w .j a  v  a  2  s  .  c o  m
    if (sysObj.has("sunset")) {
        bundle.putInt(WeatherTags.WEATHER_SYS_SUNSET, getInt("sunset", sysObj));
    }

    JSONArray jArr = jObj.getJSONArray("weather");

    JSONObject JSONWeather = jArr.getJSONObject(0);

    bundle.putString(WeatherTags.WEATHER_CONDITION_DESC, getString("description", JSONWeather));
    bundle.putString(WeatherTags.WEATHER_CONDITION_MAIN, getString("main", JSONWeather));

    JSONObject mainObj = getObject("main", jObj);
    bundle.putInt(WeatherTags.WEATHER_MAIN_HUMIDITY, getInt("humidity", mainObj));
    bundle.putInt(WeatherTags.WEATHER_MAIN_PRESSURE, getInt("pressure", mainObj));
    bundle.putString(WeatherTags.WEATHER_MAIN_TEMP_MAX, getTemperatureString(getFloat("temp_max", mainObj)));
    bundle.putString(WeatherTags.WEATHER_MAIN_TEMP_MIN, getTemperatureString(getFloat("temp_min", mainObj)));
    bundle.putString(WeatherTags.WEATHER_MAIN_TEMP, getTemperatureString(getFloat("temp", mainObj)));

    JSONObject wObj = getObject("wind", jObj);
    bundle.putFloat(WeatherTags.WEATHER_WIND_SPEED, getFloat("speed", wObj));
    bundle.putInt(WeatherTags.WEATHER_WIND_DEG, getInt("deg", wObj));

    if (wObj.has("var_beg")) {
        bundle.putInt(WeatherTags.WEATHER_WIND_VAR_BEG, getInt("var_beg", wObj));
    }
    if (wObj.has("var_end")) {
        bundle.putInt(WeatherTags.WEATHER_WIND_VAR_END, getInt("var_end", wObj));
    }

    JSONObject cObj = getObject("clouds", jObj);
    bundle.putInt(WeatherTags.WEATHER_CLOUDS_ALL, getInt("all", cObj));

    return bundle;
}

From source file:com.mercandalli.android.apps.files.file.cloud.FileCloudFragment.java

public static FileCloudFragment newInstance(final int positionInViewPager) {
    final FileCloudFragment fileCloudFragment = new FileCloudFragment();
    final Bundle args = new Bundle();
    args.putInt(ARG_POSITION_IN_VIEW_PAGER, positionInViewPager);
    fileCloudFragment.setArguments(args);
    return fileCloudFragment;
}

From source file:com.macmoim.pang.FoodListFragment.java

public static FoodListFragment GetInstance(int position) {
    //Construct the fragment
    FoodListFragment myFragment = new FoodListFragment();

    //New bundle instance
    Bundle args = new Bundle();

    //Passing in the Integer position of the fragment into the argument
    args.putInt("position", position);

    //Setting the argument of the fragment to be the position
    myFragment.setArguments(args);/* w ww .  j  ava2s.  c o  m*/

    REQ_TAG += position;

    //Return the fragment
    return myFragment;
}

From source file:com.ichi2.anki.dialogs.CustomStudyDialog.java

public static CustomStudyDialog newInstance(int id, long did, boolean jumpToReviewer) {
    CustomStudyDialog f = new CustomStudyDialog();
    Bundle args = new Bundle();
    args.putInt("id", id);
    args.putLong("did", did);
    args.putBoolean("jumpToReviewer", jumpToReviewer);
    f.setArguments(args);/*w ww  . ja va 2  s  .c  o m*/
    return f;
}