Java Code Examples for android.os.bundle#getLongArray()
The following examples show how to use
android.os.bundle#getLongArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OutlineListView.java From mOrgAnd with GNU General Public License v2.0 | 6 votes |
public void loadState(Bundle savedInstanceState) { long[] state = savedInstanceState.getLongArray(OUTLINE_NODES); ArrayList<Integer> levels = savedInstanceState.getIntegerArrayList(OUTLINE_LEVELS); boolean[] expanded = savedInstanceState.getBooleanArray(OUTLINE_EXPANDED); if(state != null) { try { this.adapter.setState(state, levels, expanded); } catch (IllegalStateException ex) { this.adapter.init(); } } int checkedPos= savedInstanceState.getInt(OUTLINE_CHECKED_POS, 0); setItemChecked(checkedPos, true); int scrollPos = savedInstanceState.getInt(OUTLINE_SCROLL_POS, 0); setSelection(scrollPos); }
Example 2
Source File: SimpleColorDialog.java From SimpleDialogFragments with Apache License 2.0 | 6 votes |
@Override protected Bundle onResult(int which) { Bundle b = super.onResult(which); int color = (int) b.getLong(SELECTED_SINGLE_ID); if (color == PICKER){ b.putInt(COLOR, mCustomColor); } else { b.putInt(COLOR, color); } long[] ids = b.getLongArray(SELECTED_IDS); if (ids != null) { int[] colors = new int[ids.length]; for (int i = 0; i < ids.length; i++) { if (ids[i] == PICKER) { colors[i] = mCustomColor; } else { colors[i] = (int) ids[i]; } } b.putIntArray(COLORS, colors); } return b; }
Example 3
Source File: KeyComboPreference.java From talkback with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("argument.type.incompatible") protected void onRestoreInstanceState(Parcelable state) { Bundle bundle = (Bundle) state; if (bundle.containsKey(KEY_KEY_COMBOS)) { // Read keyCombos from the bundle and update the list adapter. if (keyCombos == null) { keyCombos = new HashSet<>(); } else { keyCombos.clear(); } long[] keyComboArray = bundle.getLongArray(KEY_KEY_COMBOS); if (keyComboArray != null) { for (long keyCombo : keyComboArray) { keyCombos.add(keyCombo); } } KeyAssignmentUtils.updateKeyListAdapter(keyListAdapter, keyCombos, getContext()); } super.onRestoreInstanceState(bundle.getParcelable(KEY_SUPER_STATE)); }
Example 4
Source File: SimpleColorDialog.java From SimpleDialogFragments with Apache License 2.0 | 6 votes |
@Override protected Bundle onResult(int which) { Bundle b = super.onResult(which); int color = (int) b.getLong(SELECTED_SINGLE_ID); if (color == PICKER){ b.putInt(COLOR, mCustomColor); } else { b.putInt(COLOR, color); } long[] ids = b.getLongArray(SELECTED_IDS); if (ids != null) { int[] colors = new int[ids.length]; for (int i = 0; i < ids.length; i++) { if (ids[i] == PICKER) { colors[i] = mCustomColor; } else { colors[i] = (int) ids[i]; } } b.putIntArray(COLORS, colors); } return b; }
Example 5
Source File: StorageStrategy.java From FairEmail with GNU General Public License v3.0 | 6 votes |
@Override public @Nullable Selection<Long> asSelection(@NonNull Bundle state) { String keyType = state.getString(SELECTION_KEY_TYPE, null); if (keyType == null || !keyType.equals(getKeyTypeName())) { return null; } @Nullable long[] stored = state.getLongArray(SELECTION_ENTRIES); if (stored == null) { return null; } Selection<Long> selection = new Selection<>(); for (long key : stored) { selection.mSelection.add(key); } return selection; }
Example 6
Source File: UpdatableFragmentPagerAdapter.java From UpdatableFragmentStatePagerAdapter with Apache License 2.0 | 5 votes |
@Override public void restoreState(@Nullable Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader); long[] fss = bundle.getLongArray("states"); mSavedStates.clear(); mFragments.clear(); if (fss != null) { for (long fs : fss) { mSavedStates.put(fs, (Fragment.SavedState) bundle.getParcelable(Long.toString(fs))); } } Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith("f")) { Fragment f = mFragmentManager.getFragment(bundle, key); if (f != null) { f.setMenuVisibility(false); mFragments.put(Long.parseLong(key.substring(1)), f); } else { Log.w(TAG, "Bad fragment at key " + key); } } } } }
Example 7
Source File: MultiChoiceAdapterHelperBase.java From MultiChoiceAdapter with Apache License 2.0 | 5 votes |
public void restoreSelectionFromSavedInstanceState(Bundle savedInstanceState) { if (savedInstanceState == null) { return; } long[] array = savedInstanceState.getLongArray(BUNDLE_KEY); checkedItems.clear(); if (array != null) { for (long id : array) { checkedItems.add(id); } } }
Example 8
Source File: Selector.java From RecyclerViewExtensions with MIT License | 5 votes |
public void onRestoreInstanceState(@Nullable Bundle savedInstanceState) { if (savedInstanceState != null) { long[] selectedIds = savedInstanceState.getLongArray(KEY_SELECTOR_SELECTED_IDS); if (selectedIds != null) { mNotifyItemChanges = false; for (long selectedId : selectedIds) { setSelected(selectedId, true); } mNotifyItemChanges = true; } } }
Example 9
Source File: MultiSelectionUtil.java From FireFiles with Apache License 2.0 | 5 votes |
/** * This method should be called from your {@link AppCompatActivity} or * {@link android.support.v4.app.Fragment Fragment} to allow the controller to restore any * instance state. * * @param savedInstanceState - The state passed to your Activity or Fragment. */ public void restoreInstanceState(Bundle savedInstanceState) { if (savedInstanceState != null) { long[] checkedIds = savedInstanceState.getLongArray(getStateKey()); if (checkedIds != null && checkedIds.length > 0) { HashSet<Long> idsToCheckOnRestore = new HashSet<Long>(); for (long id : checkedIds) { idsToCheckOnRestore.add(id); } tryRestoreInstanceState(idsToCheckOnRestore); } } }
Example 10
Source File: MultiSelectionUtil.java From FireFiles with Apache License 2.0 | 5 votes |
/** * This method should be called from your {@link AppCompatActivity} or * {@link android.support.v4.app.Fragment Fragment} to allow the controller to restore any * instance state. * * @param savedInstanceState - The state passed to your Activity or Fragment. */ public void restoreInstanceState(Bundle savedInstanceState) { if (savedInstanceState != null) { long[] checkedIds = savedInstanceState.getLongArray(getStateKey()); if (checkedIds != null && checkedIds.length > 0) { HashSet<Long> idsToCheckOnRestore = new HashSet<Long>(); for (long id : checkedIds) { idsToCheckOnRestore.add(id); } tryRestoreInstanceState(idsToCheckOnRestore); } } }
Example 11
Source File: MultiSelectionUtil.java From FireFiles with Apache License 2.0 | 5 votes |
/** * This method should be called from your {@link AppCompatActivity} or * {@link android.support.v4.app.Fragment Fragment} to allow the controller to restore any * instance state. * * @param savedInstanceState - The state passed to your Activity or Fragment. */ public void restoreInstanceState(Bundle savedInstanceState) { if (savedInstanceState != null) { long[] checkedIds = savedInstanceState.getLongArray(getStateKey()); if (checkedIds != null && checkedIds.length > 0) { HashSet<Long> idsToCheckOnRestore = new HashSet<Long>(); for (long id : checkedIds) { idsToCheckOnRestore.add(id); } tryRestoreInstanceState(idsToCheckOnRestore); } } }
Example 12
Source File: ChatPagerAdapter.java From revolution-irc with GNU General Public License v3.0 | 5 votes |
public void onRestoreInstanceState(Bundle bundle) { String[] keys = bundle.getStringArray("channel_ids_keys"); long[] values = bundle.getLongArray("channel_ids_values"); if (keys != null && values != null && keys.length == values.length) { for (int i = keys.length - 1; i >= 0; --i) { channelIds.put(keys[i], values[i]); nextChannelId = Math.max(nextChannelId, values[i] + 1); } } updateChannelList(); }
Example 13
Source File: UpdatableFragmentPagerAdapter.java From Dainty with Apache License 2.0 | 5 votes |
@Override public void restoreState(@Nullable Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader); long[] fss = bundle.getLongArray("states"); mSavedStates.clear(); mFragments.clear(); if (fss != null) { for (long fs : fss) { mSavedStates.put(fs, (Fragment.SavedState) bundle.getParcelable(Long.toString(fs))); } } Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith("f")) { Fragment f = mFragmentManager.getFragment(bundle, key); if (f != null) { f.setMenuVisibility(false); mFragments.put(Long.parseLong(key.substring(1)), f); } else { Log.w(TAG, "Bad fragment at key " + key); } } } } }
Example 14
Source File: PlaylistDialog.java From mobile-manager-tool with MIT License | 4 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(new LinearLayout(this)); action = getIntent().getAction(); mRenameId = icicle != null ? icicle.getLong(INTENT_KEY_RENAME) : getIntent().getLongExtra( INTENT_KEY_RENAME, -1); mList = icicle != null ? icicle.getLongArray(INTENT_PLAYLIST_LIST) : getIntent() .getLongArrayExtra(INTENT_PLAYLIST_LIST); if (INTENT_RENAME_PLAYLIST.equals(action)) { mOriginalName = nameForId(mRenameId); mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME) : mOriginalName; } else if (INTENT_CREATE_PLAYLIST.equals(action)) { mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME) : makePlaylistName(); mOriginalName = mDefaultName; } DisplayMetrics dm = new DisplayMetrics(); dm = getResources().getDisplayMetrics(); mPlaylistDialog = new AlertDialog.Builder(this).create(); mPlaylistDialog.setVolumeControlStream(AudioManager.STREAM_MUSIC); if (action != null && mRenameId >= 0 && mOriginalName != null || mDefaultName != null) { mPlaylist = new EditText(this); mPlaylist.setSingleLine(true); mPlaylist.setText(mDefaultName); mPlaylist.setSelection(mDefaultName.length()); mPlaylist.addTextChangedListener(this); mPlaylistDialog.setIcon(android.R.drawable.ic_dialog_info); String promptformat; String prompt = ""; if (INTENT_RENAME_PLAYLIST.equals(action)) { promptformat = getString(R.string.rename_playlist); prompt = String.format(promptformat, mOriginalName, mDefaultName); } else if (INTENT_CREATE_PLAYLIST.equals(action)) { promptformat = getString(R.string.new_playlist); prompt = String.format(promptformat, mDefaultName); } mPlaylistDialog.setTitle(prompt); mPlaylistDialog.setView(mPlaylist, (int)(8 * dm.density), (int)(8 * dm.density), (int)(8 * dm.density), (int)(4 * dm.density)); if (INTENT_RENAME_PLAYLIST.equals(action)) { mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), mRenamePlaylistListener); mPlaylistDialog.setOnShowListener(this); } else if (INTENT_CREATE_PLAYLIST.equals(action)) { mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), mCreatePlaylistListener); } mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); mPlaylistDialog.setOnCancelListener(this); mPlaylistDialog.show(); } else { Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show(); finish(); } }
Example 15
Source File: DConnectServiceSpecTest.java From DeviceConnect-Android with MIT License | 4 votes |
/** * OpenAPIParser#parse(String) に testEnum.json を渡して解析を行う。 * * parameter の type と異なる enum の宣言が存在する testEnum.json をよみこむ。 * <pre> * 【期待する動作】 * ・Swagger オブジェクトが取得できること。 * ・parameter の enum が取得できること。 * </pre> */ @Test public void testEnum() throws JSONException { DevicePluginContext pluginContext = Mockito.mock(DevicePluginContext.class); String jsonString = FileLoader.readString("parser/testEnum.json"); DConnectServiceSpec spec = new DConnectServiceSpec(pluginContext); spec.addProfileSpec("testEnum", jsonString); Bundle swagger = spec.findProfileSpec("testEnum").toBundle(); assertThat(swagger, is(notNullValue())); Bundle paths = swagger.getBundle("paths"); assertThat(paths, is(notNullValue())); assertThat(paths.size(), is(1)); Bundle a0 = paths.getBundle("/a0"); assertThat(a0, is(notNullValue())); Bundle a0Get = a0.getBundle("get"); assertThat(a0Get, is(notNullValue())); Parcelable[] parameters = a0Get.getParcelableArray("parameters"); assertThat(parameters, is(notNullValue())); assertThat(parameters.length, is(7)); Bundle stringInt = (Bundle) parameters[1]; assertThat(stringInt.getString("type"), is("string")); String[] stringIntEnum = stringInt.getStringArray("enum"); assertThat(stringIntEnum, is(notNullValue())); assertThat(stringIntEnum[0], is("1")); assertThat(stringIntEnum[1], is("2")); assertThat(stringIntEnum[2], is("3")); assertThat(stringIntEnum[3], is("4")); Bundle stringNumber = (Bundle) parameters[2]; assertThat(stringNumber.getString("type"), is("string")); String[] stringNumberEnum = stringNumber.getStringArray("enum"); assertThat(stringNumberEnum, is(notNullValue())); assertThat(stringNumberEnum[0], is("1.1")); assertThat(stringNumberEnum[1], is("2.2")); assertThat(stringNumberEnum[2], is("3.3")); assertThat(stringNumberEnum[3], is("4.4")); Bundle intString = (Bundle) parameters[3]; assertThat(intString.getString("type"), is("integer")); assertThat(intString.getString("format"), is("int32")); int[] intStringEnum = intString.getIntArray("enum"); assertThat(intStringEnum, is(notNullValue())); assertThat(intStringEnum[0], is(1)); assertThat(intStringEnum[1], is(2)); assertThat(intStringEnum[2], is(3)); assertThat(intStringEnum[3], is(4)); Bundle longString = (Bundle) parameters[4]; assertThat(longString.getString("type"), is("integer")); assertThat(longString.getString("format"), is("int64")); long[] longStringEnum = longString.getLongArray("enum"); assertThat(longStringEnum, is(notNullValue())); assertThat(longStringEnum[0], is(1L)); assertThat(longStringEnum[1], is(2L)); assertThat(longStringEnum[2], is(3L)); assertThat(longStringEnum[3], is(4L)); Bundle floatString = (Bundle) parameters[5]; assertThat(floatString.getString("type"), is("number")); assertThat(floatString.getString("format"), is("float")); float[] floatStringEnum = floatString.getFloatArray("enum"); assertThat(floatStringEnum, is(notNullValue())); assertThat(floatStringEnum[0], is(1.1F)); assertThat(floatStringEnum[1], is(2.2F)); assertThat(floatStringEnum[2], is(3.3F)); assertThat(floatStringEnum[3], is(4.4F)); Bundle doubleString = (Bundle) parameters[6]; assertThat(doubleString.getString("type"), is("number")); assertThat(doubleString.getString("format"), is("double")); double[] doubleStringEnum = doubleString.getDoubleArray("enum"); assertThat(doubleStringEnum, is(notNullValue())); assertThat(doubleStringEnum[0], is(1.1D)); assertThat(doubleStringEnum[1], is(2.2D)); assertThat(doubleStringEnum[2], is(3.3D)); assertThat(doubleStringEnum[3], is(4.4D)); }
Example 16
Source File: InjectionHelper.java From android-state with Eclipse Public License 1.0 | 4 votes |
public long[] getLongArray(Bundle state, String key) { return state.getLongArray(key + mBaseKey); }
Example 17
Source File: CommentsAdapter.java From cathode with Apache License 2.0 | 4 votes |
public void restoreState(Bundle state) { long[] revealed = state.getLongArray(STATE_REVEALED_SPOILERS); for (long id : revealed) { revealedSpoilers.add(id); } }