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:com.github.colorchief.colorchief.MainActivity.java

@Override
public void onSaveInstanceState(Bundle toSave) {
    super.onSaveInstanceState(toSave);

    TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
    toSave.putInt("Active Tab", tabHost.getCurrentTab());

    toSave.putIntArray("Color LUT", colorLUT.getColorLutArray());

}

From source file:com.alibaba.android.layoutmanager.layoutmanager.StaggeredGridLayoutHelper.java

@Override
public void onSaveState(Bundle bundle) {
    super.onSaveState(bundle);
    bundle.putIntArray(LOOKUP_BUNDLE_KEY, mLazySpanLookup.mData);
    // TODO: store span info
}

From source file:com.nachiket.titan.LibraryPagerAdapter.java

@Override
public Parcelable saveState() {
    Bundle out = new Bundle(10);
    if (mAlbumAdapter != null)
        out.putSerializable("limiter_albums", mAlbumAdapter.getLimiter());
    if (mSongAdapter != null)
        out.putSerializable("limiter_songs", mSongAdapter.getLimiter());
    if (mFilesAdapter != null)
        out.putSerializable("limiter_files", mFilesAdapter.getLimiter());

    int[] savedPositions = new int[MAX_ADAPTER_COUNT];
    ListView[] lists = mLists;/*www .  j a  v a2  s . c  o m*/
    for (int i = MAX_ADAPTER_COUNT; --i != -1;) {
        if (lists[i] != null) {
            savedPositions[i] = lists[i].getFirstVisiblePosition();
        }
    }
    out.putIntArray("pos", savedPositions);
    return out;
}

From source file:nuclei.task.TaskScheduler.java

private void onSchedulePreL(Context context) {
    Task.Builder builder;//from  w  ww  .ja v  a  2  s.  co m

    switch (mBuilder.mTaskType) {
    case TASK_ONE_OFF:
        OneoffTask.Builder oneOffBuilder = new OneoffTask.Builder();
        builder = oneOffBuilder;
        if (mBuilder.mWindowStartDelaySecondsSet || mBuilder.mWindowEndDelaySecondsSet)
            oneOffBuilder.setExecutionWindow(mBuilder.mWindowStartDelaySeconds,
                    mBuilder.mWindowEndDelaySeconds);
        break;
    case TASK_PERIODIC:
        builder = new PeriodicTask.Builder().setFlex(mBuilder.mFlexInSeconds)
                .setPeriod(mBuilder.mPeriodInSeconds);
        break;
    default:
        throw new IllegalArgumentException();
    }

    ArrayMap<String, Object> map = new ArrayMap<>();
    mBuilder.mTask.serialize(map);
    Bundle extras = new Bundle();
    for (Map.Entry<String, Object> entry : map.entrySet()) {
        Object v = entry.getValue();
        if (v == null)
            continue;
        if (v instanceof Integer)
            extras.putInt(entry.getKey(), (int) v);
        else if (v instanceof Double)
            extras.putDouble(entry.getKey(), (double) v);
        else if (v instanceof Long)
            extras.putLong(entry.getKey(), (long) v);
        else if (v instanceof String)
            extras.putString(entry.getKey(), (String) v);
        else if (v instanceof String[])
            extras.putStringArray(entry.getKey(), (String[]) v);
        else if (v instanceof boolean[])
            extras.putBooleanArray(entry.getKey(), (boolean[]) v);
        else if (v instanceof double[])
            extras.putDoubleArray(entry.getKey(), (double[]) v);
        else if (v instanceof long[])
            extras.putLongArray(entry.getKey(), (long[]) v);
        else if (v instanceof int[])
            extras.putIntArray(entry.getKey(), (int[]) v);
        else if (v instanceof Parcelable)
            extras.putParcelable(entry.getKey(), (Parcelable) v);
        else if (v instanceof Serializable)
            extras.putSerializable(entry.getKey(), (Serializable) v);
        else
            throw new IllegalArgumentException("Invalid Type: " + entry.getKey());
    }
    extras.putString(TASK_NAME, mBuilder.mTask.getClass().getName());

    builder.setExtras(extras).setPersisted(mBuilder.mPersisted).setRequiresCharging(mBuilder.mRequiresCharging)
            .setService(TaskGcmService.class).setTag(mBuilder.mTask.getTaskTag())
            .setUpdateCurrent(mBuilder.mUpdateCurrent);

    switch (mBuilder.mNetworkState) {
    case NETWORK_STATE_ANY:
        builder.setRequiredNetwork(Task.NETWORK_STATE_ANY);
        break;
    case NETWORK_STATE_CONNECTED:
        builder.setRequiredNetwork(Task.NETWORK_STATE_CONNECTED);
        break;
    case NETWORK_STATE_UNMETERED:
        builder.setRequiredNetwork(Task.NETWORK_STATE_UNMETERED);
        break;
    }

    GcmNetworkManager.getInstance(context).schedule(builder.build());
}

From source file:me.xiaopan.android.inject.sample.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    listView = new ListView(getBaseContext());
    setContentView(listView);/*from w ww  . ja v  a  2s .c om*/

    // SharedPreferences?
    PreferenceUtils.putBoolean(getBaseContext(), KEY_BOOLEAN, true);
    PreferenceUtils.putFloat(getBaseContext(), KEY_FLOAT, 10000f);
    PreferenceUtils.putInt(getBaseContext(), KEY_INT, 2000);
    PreferenceUtils.putLong(getBaseContext(), KEY_LONG, 50000);
    PreferenceUtils.putString(getBaseContext(), KEY_STRING, "Preference String");
    Set<String> stringSet = new HashSet<String>();
    stringSet.add("String Set 1");
    stringSet.add("String Set 2");
    stringSet.add("String Set 3");
    stringSet.add("String Set 4");
    PreferenceUtils.putStringSet(getBaseContext(), KEY_STRING_SET, stringSet);
    MyBean bean2 = new MyBean();
    bean2.setEmail("sky@xiaopan.me2");
    bean2.setName("?2");
    bean2.setSex("2");
    PreferenceUtils.putObject(getBaseContext(), KEY_JSON, bean2);
    PreferenceUtils.putString(getBaseContext(), KEY_ENUM, Sex.WOMAN.name());

    // ??
    String[] items = new String[] { "", "?", "FragmentDialog",
            "InjectAdapter", "InjectExpandableListAdapter" };
    listView.setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1,
            android.R.id.text1, items));
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position <= 2) {
                Bundle bundle = new Bundle();
                bundle.putBoolean(MainActivity.PARAM_BOOLEAN, true);
                bundle.putBooleanArray(MainActivity.PARAM_BOOLEAN_ARRAY, new boolean[] { true, false, true });
                bundle.putByte(MainActivity.PARAM_BYTE, (byte) 110);
                bundle.putByteArray(MainActivity.PARAM_BYTE_ARRAY, new byte[] { 111, 112, 113 });
                bundle.putChar(MainActivity.PARAM_CHAR, 'R');
                bundle.putCharArray(MainActivity.PARAM_CHAR_ARRAY, new char[] { 'c', 'h', 'a', 'r' });
                bundle.putCharSequence(MainActivity.PARAM_CHAR_SEQUENCE, "CharSequence");
                bundle.putCharSequenceArray(MainActivity.PARAM_CHAR_SEQUENCE_ARRAY,
                        new CharSequence[] { "Char", " ", "Sequence" });
                bundle.putDouble(MainActivity.PARAM_DOUBLE, 12.00d);
                bundle.putDoubleArray(MainActivity.PARAM_DOUBLE_ARRAY, new double[] { 12.01d, 12.02d, 12.03d });
                bundle.putFloat(MainActivity.PARAM_FLOAT, 13.00f);
                bundle.putFloatArray(MainActivity.PARAM_FLOAT_ARRAY, new float[] { 13.01f, 13.02f, 13.03f });
                bundle.putInt(MainActivity.PARAM_INT, 120);
                bundle.putIntArray(MainActivity.PARAM_INT_ARRAY, new int[] { 121, 122, 123, });
                bundle.putLong(MainActivity.PARAM_LONG, 12345);
                bundle.putLongArray(MainActivity.PARAM_LONG_ARRAY, new long[] { 12346, 12347, 12348 });
                bundle.putShort(MainActivity.PARAM_SHORT, (short) 2);
                bundle.putShortArray(MainActivity.PARAM_SHORT_ARRAY, new short[] { 3, 4, 5 });
                bundle.putString(MainActivity.PARAM_STRING, "String");
                bundle.putStringArray(MainActivity.PARAM_STRING_ARRAY,
                        new String[] { "String1", "String2", "String3" });

                // ??JSONBundle
                MyBean bean = new MyBean();
                bean.setEmail("sky@xiaopan.me");
                bean.setName("?");
                bean.setSex("");
                bundle.putString(PARAM_STRING_JSON, new Gson().toJson(bean));

                bundle.putString(MainActivity.PARAM_STRING_ENUM, Sex.WOMAN.name());

                // 
                ArrayList<String> stringList = new ArrayList<String>();
                stringList.add("ArrayList String 1");
                stringList.add("ArrayList String 2");
                stringList.add("ArrayList String 3");
                bundle.putStringArrayList(MainActivity.PARAM_STRING_ARRAY_LIST, stringList);
                switch (position) {
                case 0:
                    Second.SECOND_CHRONOGRAPH.lap();
                    Intent intent = new Intent(getBaseContext(), InjectTestActivity.class);
                    intent.putExtras(bundle);
                    startActivity(intent);
                    break;
                case 1:
                    Second.SECOND_CHRONOGRAPH.lap();
                    Intent intent2 = new Intent(getBaseContext(), NormalActivity.class);
                    intent2.putExtras(bundle);
                    startActivity(intent2);
                    break;
                case 2:
                    Second.SECOND_CHRONOGRAPH.lap();
                    new TestDialogFragment().show(getSupportFragmentManager(), "");
                    break;
                }
            } else {
                Class<?> targetClass = null;
                if (position == 3) {
                    targetClass = InjectAdapterActivity.class;
                } else if (position == 4) {
                    targetClass = InjectExpandableListAdapterActivity.class;
                }
                if (targetClass != null) {
                    startActivity(new Intent(getBaseContext(), targetClass));
                }
            }
        }
    });
}

From source file:com.hippo.ehviewer.ui.scene.FavoritesScene.java

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

    boolean hasFirstRefresh;
    if (mHelper != null && 1 == mHelper.getShownViewIndex()) {
        hasFirstRefresh = false;/*from www  .  j a v a 2  s.  c  om*/
    } else {
        hasFirstRefresh = mHasFirstRefresh;
    }
    outState.putBoolean(KEY_HAS_FIRST_REFRESH, hasFirstRefresh);
    outState.putParcelable(KEY_URL_BUILDER, mUrlBuilder);
    outState.putBoolean(KEY_SEARCH_MODE, mSearchMode);
    outState.putIntArray(KEY_FAV_COUNT_ARRAY, mFavCountArray);
}

From source file:com.googlecode.android_scripting.facade.AndroidFacade.java

private static void putNestedJSONObject(JSONObject jsonObject, Bundle bundle) throws JSONException {
    JSONArray names = jsonObject.names();
    for (int i = 0; i < names.length(); i++) {
        String name = names.getString(i);
        Object data = jsonObject.get(name);
        if (data == null) {
            continue;
        }/*from   w w  w.ja v a  2s  . com*/
        if (data instanceof Integer) {
            bundle.putInt(name, ((Integer) data).intValue());
        }
        if (data instanceof Float) {
            bundle.putFloat(name, ((Float) data).floatValue());
        }
        if (data instanceof Double) {
            bundle.putDouble(name, ((Double) data).doubleValue());
        }
        if (data instanceof Long) {
            bundle.putLong(name, ((Long) data).longValue());
        }
        if (data instanceof String) {
            bundle.putString(name, (String) data);
        }
        if (data instanceof Boolean) {
            bundle.putBoolean(name, ((Boolean) data).booleanValue());
        }
        // Nested JSONObject
        if (data instanceof JSONObject) {
            Bundle nestedBundle = new Bundle();
            bundle.putBundle(name, nestedBundle);
            putNestedJSONObject((JSONObject) data, nestedBundle);
        }
        // Nested JSONArray. Doesn't support mixed types in single array
        if (data instanceof JSONArray) {
            // Empty array. No way to tell what type of data to pass on, so skipping
            if (((JSONArray) data).length() == 0) {
                Log.e("Empty array not supported in nested JSONObject, skipping");
                continue;
            }
            // Integer
            if (((JSONArray) data).get(0) instanceof Integer) {
                int[] integerArrayData = new int[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    integerArrayData[j] = ((JSONArray) data).getInt(j);
                }
                bundle.putIntArray(name, integerArrayData);
            }
            // Double
            if (((JSONArray) data).get(0) instanceof Double) {
                double[] doubleArrayData = new double[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    doubleArrayData[j] = ((JSONArray) data).getDouble(j);
                }
                bundle.putDoubleArray(name, doubleArrayData);
            }
            // Long
            if (((JSONArray) data).get(0) instanceof Long) {
                long[] longArrayData = new long[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    longArrayData[j] = ((JSONArray) data).getLong(j);
                }
                bundle.putLongArray(name, longArrayData);
            }
            // String
            if (((JSONArray) data).get(0) instanceof String) {
                String[] stringArrayData = new String[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    stringArrayData[j] = ((JSONArray) data).getString(j);
                }
                bundle.putStringArray(name, stringArrayData);
            }
            // Boolean
            if (((JSONArray) data).get(0) instanceof Boolean) {
                boolean[] booleanArrayData = new boolean[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    booleanArrayData[j] = ((JSONArray) data).getBoolean(j);
                }
                bundle.putBooleanArray(name, booleanArrayData);
            }
        }
    }
}

From source file:com.andrewshu.android.reddit.user.ProfileActivity.java

@Override
protected void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);
    state.putString(Constants.USERNAME_KEY, mUsername);
    state.putString(Constants.CommentsSort.SORT_BY_KEY, mSortByUrl);
    state.putString(Constants.JUMP_TO_THREAD_ID_KEY, mJumpToThreadId);
    state.putString(Constants.AFTER_KEY, mAfter);
    state.putString(Constants.BEFORE_KEY, mBefore);
    state.putInt(Constants.THREAD_COUNT_KEY, mCount);
    state.putString(Constants.LAST_AFTER_KEY, mLastAfter);
    state.putString(Constants.LAST_BEFORE_KEY, mLastBefore);
    state.putInt(Constants.THREAD_LAST_COUNT_KEY, mLastCount);
    state.putIntArray(Constants.KARMA_KEY, mKarma);
    state.putParcelable(Constants.VOTE_TARGET_THING_INFO_KEY, mVoteTargetThingInfo);
}

From source file:com.df.app.procedures.CarRecogniseLayout.java

/**
 * ??/*from w  ww. j  a va2  s .c o  m*/
 */
private void recogniseLicense() {
    //
    String selectPath = AppCommon.licensePhotoPath;
    boolean cutBoolean = cut;

    try {
        Intent intent = new Intent("wintone.idcard");
        Bundle bundle = new Bundle();
        int nSubID[] = null;
        bundle.putInt("nTypeInitIDCard", 0); //?0??
        bundle.putString("lpFileName", selectPath);//?
        bundle.putInt("nTypeLoadImageToMemory", 0);//0???1??24
        bundle.putInt("nMainID", nMainID); //?6?2????????ID?????
        bundle.putIntArray("nSubID", nSubID); //????ID????????nSubID[0]=nullnMainID?

        //sn
        File file = new File(AppCommon.licenseUtilPath);
        String snString = null;
        if (file.exists()) {
            String filePATH = AppCommon.licenseUtilPath + "/IdCard.sn";
            File newFile = new File(filePATH);
            if (newFile.exists()) {
                BufferedReader bfReader = new BufferedReader(new FileReader(newFile));
                snString = bfReader.readLine().toUpperCase();
                bfReader.close();
            } else {
                bundle.putString("sn", "");
            }
            if (snString != null && !snString.equals("")) {
                bundle.putString("sn", snString);
            } else {
                bundle.putString("sn", "");
            }
        } else {
            bundle.putString("sn", "");
        }

        bundle.putString("authfile", ""); //?  /mnt/sdcard/AndroidWT/357816040594713_zj.txt
        bundle.putString("logo", ""); //logologo??
        bundle.putBoolean("isCut", cutBoolean); //??
        bundle.putString("returntype", "withvalue");//?withvalue???
        intent.putExtras(bundle);
        ((Activity) getContext()).startActivityForResult(intent, 8);
    } catch (Exception e) {
        Toast.makeText(getContext(), "?" + "wintone.idcard", Toast.LENGTH_SHORT).show();
    }
}