android.os.Bundle.getLongArray()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中android.os.Bundle.getLongArray()方法的一些代码示例,展示了Bundle.getLongArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.getLongArray()方法的具体详情如下:
包路径:android.os.Bundle
类名称:Bundle
方法名:getLongArray

Bundle.getLongArray介绍

暂无

代码示例

代码示例来源:origin: k9mail/k-9

/**
 * Restore selected messages from a {@link Bundle}.
 */
private void restoreSelectedMessages(Bundle savedInstanceState) {
  long[] selected = savedInstanceState.getLongArray(STATE_SELECTED_MESSAGES);
  if (selected != null) {
    for (long id : selected) {
      this.selected.add(id);
    }
  }
}

代码示例来源:origin: facebook/facebook-android-sdk

/**
 * Gets an array of long values out of the object.
 * @param key The key for the value.
 * @return The long values.
 */
@Nullable
public long[] getLongArray(final String key) {
  return this.bundle.getLongArray(key);
}

代码示例来源:origin: mikepenz/FastAdapter

@Override
public void withSavedInstanceState(@Nullable Bundle savedInstanceState, String prefix) {
  if (savedInstanceState == null) {
    return;
  }
  long[] selectedItems = savedInstanceState.getLongArray(BUNDLE_SELECTIONS + prefix);
  if (selectedItems != null) {
    for (long id : selectedItems) {
      selectByIdentifier(id, false, true);
    }
  }
}

代码示例来源:origin: naman14/Timber

@Override
  public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
    long[] songs = getArguments().getLongArray("songs");
    if (which == 0) {
      CreatePlaylistDialog.newInstance(songs).show(getActivity().getSupportFragmentManager(), "CREATE_PLAYLIST");
      return;
    }
    MusicPlayer.addToPlaylist(getActivity(), songs, playlists.get(which - 1).id);
    dialog.dismiss();
  }
}).build();

代码示例来源:origin: naman14/Timber

@Override
  public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
    long[] songs = getArguments().getLongArray("songs");
    long playistId = MusicPlayer.createPlaylist(getActivity(), input.toString());
    if (playistId != -1) {
      if (songs != null && songs.length != 0)
        MusicPlayer.addToPlaylist(getActivity(), songs, playistId);
      else
        Toast.makeText(getActivity(), "Created playlist", Toast.LENGTH_SHORT).show();
      if (getParentFragment() instanceof PlaylistFragment) {
        ((PlaylistFragment) getParentFragment()).updatePlaylists(playistId);
      }
    } else {
      Toast.makeText(getActivity(), "Unable to create playlist", Toast.LENGTH_SHORT).show();
    }
  }
}).build();

代码示例来源:origin: robolectric/robolectric

@Test
public void longArray() {
 long [] arr = new long[] { 23, 11 };
 bundle.putLongArray("foo", arr);
 assertThat(bundle.getLongArray("foo")).isEqualTo(arr);
 assertThat(bundle.getLongArray("bar")).isNull();
}

代码示例来源:origin: konmik/nucleus

when(bundle.getLongArray(anyString())).thenAnswer(get);

代码示例来源:origin: aa112901/remusic

musicId = getArguments().getLongArray("songs");

代码示例来源:origin: robolectric/robolectric

@Test
public void getWrongType() {
 bundle.putFloat("foo", 5f);
 assertThat(bundle.getCharArray("foo")).isNull();
 assertThat(bundle.getInt("foo")).isEqualTo(0);
 assertThat(bundle.getIntArray("foo")).isNull();
 assertThat(bundle.getIntegerArrayList("foo")).isNull();
 assertThat(bundle.getShort("foo")).isEqualTo((short) 0);
 assertThat(bundle.getShortArray("foo")).isNull();
 assertThat(bundle.getBoolean("foo")).isFalse();
 assertThat(bundle.getBooleanArray("foo")).isNull();
 assertThat(bundle.getLong("foo")).isEqualTo(0);
 assertThat(bundle.getLongArray("foo")).isNull();
 assertThat(bundle.getFloatArray("foo")).isNull();
 assertThat(bundle.getDouble("foo")).isEqualTo(0.0);
 assertThat(bundle.getDoubleArray("foo")).isNull();
 assertThat(bundle.getString("foo")).isNull();
 assertThat(bundle.getStringArray("foo")).isNull();
 assertThat(bundle.getStringArrayList("foo")).isNull();
 assertThat(bundle.getBundle("foo")).isNull();
 assertThat((Parcelable) bundle.getParcelable("foo")).isNull();
 assertThat(bundle.getParcelableArray("foo")).isNull();
 assertThat(bundle.getParcelableArrayList("foo")).isNull();
 bundle.putInt("foo", 1);
 assertThat(bundle.getFloat("foo")).isEqualTo(0.0f);
}

代码示例来源:origin: facebook/facebook-android-sdk

assertArrayEquals(originalBundle.getIntArray(INT_ARRAY_KEY), cachedBundle.getIntArray(INT_ARRAY_KEY));
assertEquals(originalBundle.getLong(LONG_KEY), cachedBundle.getLong(LONG_KEY));
assertArrayEquals(originalBundle.getLongArray(LONG_ARRAY_KEY), cachedBundle.getLongArray(LONG_ARRAY_KEY));
assertEquals(originalBundle.getFloat(FLOAT_KEY), cachedBundle.getFloat(FLOAT_KEY), TestUtils.DOUBLE_EQUALS_DELTA);
assertArrayEquals(originalBundle.getFloatArray(FLOAT_ARRAY_KEY), cachedBundle.getFloatArray(FLOAT_ARRAY_KEY));

代码示例来源:origin: stackoverflow.com

protected void onRestoreInstanceState(Bundle state) {
  super.onRestoreInstanceState(state);
  long[] expandedIds = state.getLongArray("ExpandedIds");
  if (expandedIds != null) {
    restoreExpandedState(expandedIds);

代码示例来源:origin: kayoSun/Tack

public long[] getLongs(String key){
  if (mBundle != null) {
    return  mBundle.getLongArray(key);
  }
  return null;
}

代码示例来源:origin: fengdai/FragmentMaster

/**
 * Retrieve extended data from the request.
 *
 * @param name The name of the desired item.
 * @return the value of an item that previously added with putExtra() or
 * null if no long array value was found.
 * @see #putExtra(String, long[])
 */
public long[] getLongArrayExtra(String name) {
  return mExtras == null ? null : mExtras.getLongArray(name);
}

代码示例来源:origin: stackoverflow.com

public void onRestoreInstanceState(Bundle savedInstanceState) {
 super.onRestoreInstanceState(savedInstanceState);
 Long [] arr = savedInstanceState.getLongArray("mycheck");
}

代码示例来源:origin: curtis2/SuperVideoPlayer

mOnCachingUpdateListener.onCachingNotAvailable(mMediaPlayer, msg.getData().getInt(MEDIA_CACHING_INFO));
} else if (cacheType == CACHE_TYPE_UPDATE) {
 mOnCachingUpdateListener.onCachingUpdate(mMediaPlayer, msg.getData().getLongArray(MEDIA_CACHING_SEGMENTS));
} else if (cacheType == CACHE_TYPE_SPEED) {
 mOnCachingUpdateListener.onCachingSpeed(mMediaPlayer, msg.getData().getInt(MEDIA_CACHING_INFO));

代码示例来源:origin: Doist/RecyclerViewExtensions

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;
    }
  }
}

代码示例来源:origin: GeoODK/collect

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
  super.onRestoreInstanceState(savedInstanceState);
  long[] selectedArray = savedInstanceState.getLongArray(SELECTED);
  for (int i = 0; i < selectedArray.length; i++) {
    mSelected.add(selectedArray[i]);
  }
  mDeleteButton.setEnabled(selectedArray.length > 0);
}

代码示例来源:origin: MCMrARM/revolution-irc

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();
}

代码示例来源:origin: rohanoid5/Muzesto

@Override
  public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
    long[] songs = getArguments().getLongArray("songs");
    if (which == 0) {
      CreatePlaylistDialog.newInstance(songs).show(getActivity().getSupportFragmentManager(), "CREATE_PLAYLIST");
      return;
    }
    MusicPlayer.addToPlaylist(getActivity(), songs, playlists.get(which - 1).id);
    dialog.dismiss();
  }
}).build();

代码示例来源:origin: cbeyls/fosdem-companion-android

@Override
public void onActivityCreated(Bundle savedInstanceState) {
  super.onActivityCreated(savedInstanceState);
  setAdapter(adapter);
  setEmptyText(getString(R.string.no_bookmark));
  setProgressBarVisible(true);
  long[] bookmarkIds = getArguments().getLongArray(ARG_BOOKMARK_IDS);
  final ExternalBookmarksViewModel viewModel = ViewModelProviders.of(this).get(ExternalBookmarksViewModel.class);
  viewModel.setBookmarkIds(bookmarkIds);
  viewModel.getBookmarks().observe(getViewLifecycleOwner(), this);
}

相关文章

Bundle类方法