Example usage for android.os Bundle putIntArray

List of usage examples for android.os Bundle putIntArray

Introduction

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

Prototype

public void putIntArray(@Nullable String key, @Nullable int[] value) 

Source Link

Document

Inserts an int array value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:Main.java

public static void onSaveInstanceState(Bundle outState) {
    outState.putIntArray("drawables", menuItems);
    outState.putBoolean("isShowing", isShowing);
}

From source file:com.grokkingandroid.sampleapp.samples.about.AboutFragment.java

public static AboutFragment newInstance(int[] resourceIds, boolean useDefaultLibs) {
    AboutFragment f = new AboutFragment();
    Bundle bundle = new Bundle();
    bundle.putIntArray(KEY_RESOURCE_IDS, resourceIds);
    bundle.putBoolean(KEY_ADD_DEFAULT_LIBS, useDefaultLibs);
    f.setArguments(bundle);// w  ww . j  a  v  a 2s  . c  om
    return f;
}

From source file:eu.geopaparazzi.library.core.dialogs.ZoomlevelDialogFragment.java

/**
 * Create a dialog instance.//from  www  . j  av  a  2s  . com
 *
 * @param minMaxZoomlevels object holding zoomlevel info.
 * @return the instance.
 */
public static ZoomlevelDialogFragment newInstance(int[] minMaxZoomlevels) {
    ZoomlevelDialogFragment f = new ZoomlevelDialogFragment();
    if (minMaxZoomlevels != null) {
        Bundle args = new Bundle();
        args.putIntArray(PREFS_KEY_ZOOMLEVELPROPERTIES, minMaxZoomlevels);
        f.setArguments(args);
    }
    return f;
}

From source file:com.kiwi.auready.util.view.ColorPickerDialog.java

public static ColorPickerDialog newInstance(int titleResId, int[] colors, int selectedColor, int columns,
        int size) {
    ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
    Bundle bundle = new Bundle();
    bundle.putInt(KEY_TITLE_ID, titleResId);
    bundle.putIntArray(KEY_COLORS, colors);
    bundle.putInt(KEY_SELECTED_COLOR, selectedColor);
    bundle.putInt(KEY_COLUMNS, columns);
    bundle.putInt(KEY_SIZE, size);/*from www . j  av  a  2  s.  c o m*/
    colorPickerDialog.setArguments(bundle);

    return colorPickerDialog;
}

From source file:com.dm.material.dashboard.candybar.fragments.dialog.InAppBillingFragment.java

private static InAppBillingFragment newInstance(int type, String key, String[] productId, int[] productCount) {
    InAppBillingFragment fragment = new InAppBillingFragment();
    Bundle bundle = new Bundle();
    bundle.putInt(TYPE, type);//w  ww.j  a  v a2s.  co m
    bundle.putString(KEY, key);
    bundle.putStringArray(PRODUCT_ID, productId);
    if (productCount != null)
        bundle.putIntArray(PRODUCT_COUNT, productCount);
    fragment.setArguments(bundle);
    return fragment;
}

From source file:org.chromium.chrome.browser.preferences.privacy.ConfirmImportantSitesDialogFragment.java

/**
 * Constructs a new instance of the important sites dialog fragment.
 * @param importantDomains The list of important domains to display.
 * @param importantDomainReasons The reasons for choosing each important domain.
 * @param faviconURLs The list of favicon urls that correspond to each importantDomains.
 * @return An instance of ConfirmImportantSitesDialogFragment with the bundle arguments set.
 *//* w ww .ja v  a 2 s.  co  m*/
public static ConfirmImportantSitesDialogFragment newInstance(String[] importantDomains,
        int[] importantDomainReasons, String[] faviconURLs) {
    ConfirmImportantSitesDialogFragment dialogFragment = new ConfirmImportantSitesDialogFragment();
    Bundle bundle = new Bundle();
    bundle.putStringArray(IMPORTANT_DOMAINS_TAG, importantDomains);
    bundle.putIntArray(IMPORTANT_DOMAIN_REASONS_TAG, importantDomainReasons);
    bundle.putStringArray(FAVICON_URLS_TAG, faviconURLs);
    dialogFragment.setArguments(bundle);
    return dialogFragment;
}

From source file:Main.java

@SuppressWarnings("unchecked")
private static void putArray(String key, ArrayList arrayList, Bundle bundle) {
    if (arrayList.size() == 0) {
        bundle.putBooleanArray(key, new boolean[] {});
    } else {//w w w .j av  a 2  s.co m
        verifyArrayListIsSingleType(arrayList);
        if (arrayList.get(0) instanceof String) {
            bundle.putStringArray(key, toStringArray((ArrayList<String>) arrayList));
        } else if (arrayList.get(0) instanceof Integer) {
            bundle.putIntArray(key, toIntArray((ArrayList<Integer>) arrayList));
        } else if (arrayList.get(0) instanceof Float) {
            bundle.putFloatArray(key, toFloatArray((ArrayList<Float>) arrayList));
        } else if (arrayList.get(0) instanceof Double) {
            bundle.putDoubleArray(key, toDoubleArray((ArrayList<Double>) arrayList));
        } else if (arrayList.get(0) instanceof Boolean) {
            bundle.putBooleanArray(key, toBooleanArray((ArrayList<Boolean>) arrayList));
        } else if (arrayList.get(0) instanceof HashMap) {
            bundle.putParcelableArray(key, toBundleArray((ArrayList<HashMap>) arrayList));
        } else if (arrayList.get(0) instanceof ArrayList) {
            Log.w("RNNavigation",
                    "Arrays of arrays passed in props are converted to dictionaries with indexes as keys");
            Bundle innerArray = new Bundle();
            for (int i = 0; i < arrayList.size(); i++) {
                putArray(String.valueOf(i), (ArrayList) arrayList.get(i), innerArray);
            }
            bundle.putParcelable(key, innerArray);
        }
    }
}

From source file:com.facebook.LegacyTokenCacheTest.java

private static void putIntArray(String key, Bundle bundle) {
    int length = random.nextInt(50);
    int[] array = new int[length];
    for (int i = 0; i < length; i++) {
        array[i] = random.nextInt();//from  www  . j  av a 2s. c  om
    }
    bundle.putIntArray(key, array);
}

From source file:org.ohmage.reminders.notif.Notifier.java

private static void setRepeatAlarm(Context context, int trigId, int[] repeatDiffs) {

    if (repeatDiffs.length == 0) {
        //No more repeats in the list
        return;/*from  ww  w. j  ava  2  s .  c  o m*/
    }

    //Set a repeat reminder for the first item in the list
    //and prepare the new list by removing this item

    int[] newRepeats = new int[repeatDiffs.length - 1];
    System.arraycopy(repeatDiffs, 1, newRepeats, 0, repeatDiffs.length - 1);

    Bundle repeatBundle = new Bundle();
    repeatBundle.putIntArray(KEY_REPEAT_LIST, newRepeats);
    //Set the alarm for the first repeat item and attach the remaining list
    setAlarm(context, ACTION_REPEAT_ALM, repeatDiffs[0], repeatBundle);
}

From source file:com.QuarkLabs.BTCeClient.UpdateWidgetsTask.java

@Override
protected void onPostExecute(JSONObject jsonObject) {
    if (jsonObject != null) {
        try {// w  w  w.  ja  va2  s.c  o  m
            Context context = mContext.get();
            if (context == null) {
                return;
            }
            AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
            for (int x : mMap.keySet()) {
                RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_layout);
                double price = jsonObject.getJSONObject(mMap.get(x).replace("/", "_").toLowerCase(Locale.US))
                        .getDouble("last");
                String priceString;
                if (price > 1) {
                    priceString = (new DecimalFormat("#.##")).format(price);
                } else {
                    priceString = String.valueOf(price);
                }
                views.setTextViewText(R.id.widgetCurrencyValue, priceString);
                views.setTextViewText(R.id.widgetPair, mMap.get(x));
                String color = jsonObject.getJSONObject(mMap.get(x).replace("/", "_").toLowerCase(Locale.US))
                        .getString("color");
                int colorValue = color.equals("green") ? Color.GREEN : Color.RED;
                views.setTextColor(R.id.widgetCurrencyValue, colorValue);
                Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
                Bundle bundle = new Bundle();
                bundle.putIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS,
                        appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class)));
                intent.putExtras(bundle);
                PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                views.setOnClickPendingIntent(R.id.widgetContainer, pi);
                SimpleDateFormat df = new SimpleDateFormat("EEE HH:mm", Locale.US);
                Calendar calendar = Calendar.getInstance();
                views.setTextViewText(R.id.widgetDate, df.format(calendar.getTime()));
                appWidgetManager.updateAppWidget(x, views);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}