List of usage examples for android.os Bundle putBooleanArray
public void putBooleanArray(@Nullable String key, @Nullable boolean[] value)
From source file:com.billooms.harppedals.HarpPedalsActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { // Log.d(TAG, "HarpPedalsActivity.onSaveInstanceState"); super.onSaveInstanceState(outState); if (outState == null) { return;/*from w w w. j a v a2s .c om*/ } if (savedChordArray != null) { outState.putIntArray(ARG_CHORD, savedChordArray); } if (savedChordAddArray != null) { outState.putBooleanArray(ARG_CHORDADD, savedChordAddArray); } if (savedKey != null) { outState.putInt(ARG_KEY, savedKey.getKeySignature().ordinal()); outState.putInt(ARG_SCALE, savedKey.getScale().ordinal()); } }
From source file:mchs.neverforget.NeverForgetActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putBooleanArray(SELECTED_BOOKS, isBookSelected); }
From source file:com.hitkoDev.chemApp.fragment.SectionsFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); //To change body of generated methods, choose Tools | Templates. int i = expanded.size(); int[] k = new int[i]; boolean[] v = new boolean[i]; i = 0;//ww w. j a va 2s. c o m for (Entry<Integer, Boolean> e : expanded.entrySet()) { k[i] = e.getKey(); v[i] = e.getValue(); i++; } outState.putIntArray(EXPANDED_KEYS, k); outState.putBooleanArray(EXPANDED_VALUES, v); }
From source file:can.yrt.onebusaway.ArrivalsListFragment.java
private void showRoutesFilterDialog() { ObaArrivalInfoResponse response = getArrivalsLoader().getLastGoodResponse(); final List<ObaRoute> routes = response.getRoutes(mStop.getRouteIds()); final int len = routes.size(); final ArrayList<String> filter = mRoutesFilter; // mRouteIds = new ArrayList<String>(len); String[] items = new String[len]; boolean[] checks = new boolean[len]; // Go through all the stops, add them to the Ids and Names // For each stop, if it is in the enabled list, mark it as checked. for (int i = 0; i < len; ++i) { final ObaRoute route = routes.get(i); // final String id = route.getId(); // mRouteIds.add(i, id); items[i] = UIHelp.getRouteDisplayName(route); if (filter.contains(route.getId())) { checks[i] = true;//from w w w . j ava 2 s.com } } // Arguments Bundle args = new Bundle(); args.putStringArray(RoutesFilterDialog.ITEMS, items); args.putBooleanArray(RoutesFilterDialog.CHECKS, checks); RoutesFilterDialog frag = new RoutesFilterDialog(); frag.setArguments(args); frag.show(getActivity().getSupportFragmentManager(), ".RoutesFilterDialog"); }
From source file:org.epstudios.epcoding.ProcedureDetailFragment.java
@Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); // store check marks here boolean[] primaryCodeState = new boolean[primaryCheckBoxMap.size()]; int i = 0;/*ww w . j ava 2s .c om*/ for (Map.Entry<String, CodeCheckBox> entry : primaryCheckBoxMap.entrySet()) primaryCodeState[i++] = entry.getValue().isChecked(); i = 0; boolean[] secondaryCodeState = new boolean[secondaryCheckBoxMap.size()]; for (Map.Entry<String, CodeCheckBox> entry : secondaryCheckBoxMap.entrySet()) secondaryCodeState[i++] = entry.getValue().isChecked(); savedInstanceState.putBooleanArray("primary_codes", primaryCodeState); savedInstanceState.putBooleanArray("secondary_codes", secondaryCodeState); }
From source file:com.androidaq.AndroiDAQMain.java
private void updateFromPreferences() { //Log.e(TAG, "Update Preferences Fired"); Context context = getApplicationContext(); boolean[] isOutputCh = loadBooleanArray("isInput", context); boolean[] isDigCh = loadBooleanArray("isDig", context); boolean[] outputState = loadBooleanArray("outputState", context); boolean fromFreq = true; String[] desiredFreq = loadStringArray("desiredFreqs", context, fromFreq); fromFreq = false;/*from w ww . jav a 2 s .c om*/ String[] desiredDuty = loadStringArray("desiredDutys", context, fromFreq); Bundle myBundle = new Bundle(); myBundle.putBooleanArray("isInput", isOutputCh); myBundle.putBooleanArray("isDig", isDigCh); myBundle.putBooleanArray("outputState", outputState); myBundle.putStringArray("desiredFreqs", desiredFreq); myBundle.putStringArray("desiredDutys", desiredDuty); ((AndroiDAQAdapter) pager.getAdapter()).setUIStates(myBundle); /*Example countSecs = prefs.getInt("setTime", 5000); timeIsSet = prefs.getBoolean("timeSet", true); project = prefs.getString("project", "Project01");*/ }
From source file:com.androidaq.AndroiDAQTCPMain.java
private void updateFromPreferences() { //Log.e(TAG, "Update Preferences Fired"); Context context = getApplicationContext(); boolean[] isOutputCh = loadBooleanArray("isInput", context); boolean[] isDigCh = loadBooleanArray("isDig", context); boolean[] outputState = loadBooleanArray("outputState", context); boolean fromFreq = true; String[] desiredFreq = loadStringArray("desiredFreqs", context, fromFreq); fromFreq = false;//from w w w.j av a2 s. c o m String[] desiredDuty = loadStringArray("desiredDutys", context, fromFreq); Bundle myBundle = new Bundle(); myBundle.putBooleanArray("isInput", isOutputCh); myBundle.putBooleanArray("isDig", isDigCh); myBundle.putBooleanArray("outputState", outputState); myBundle.putStringArray("desiredFreqs", desiredFreq); myBundle.putStringArray("desiredDutys", desiredDuty); ((AndroiDAQTCPAdapter) pager.getAdapter()).setUIStates(myBundle); /*Example countSecs = prefs.getInt("setTime", 5000); timeIsSet = prefs.getBoolean("timeSet", true); project = prefs.getString("project", "Project01");*/ }
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 w w w.ja va 2 s .c om 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:nuclei.task.TaskScheduler.java
private void onSchedulePreL(Context context) { Task.Builder builder;/*from www . ja v a 2s. 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:com.facebook.LegacyTokenHelper.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 . ja v a 2 s . co 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); } else if (valueType.equals(TYPE_ENUM)) { try { String enumType = json.getString(JSON_VALUE_ENUM_TYPE); @SuppressWarnings({ "unchecked", "rawtypes" }) Class<? extends Enum> enumClass = (Class<? extends Enum>) Class.forName(enumType); @SuppressWarnings("unchecked") Enum<?> enumValue = Enum.valueOf(enumClass, json.getString(JSON_VALUE)); bundle.putSerializable(key, enumValue); } catch (ClassNotFoundException e) { } catch (IllegalArgumentException e) { } } }