本文整理汇总了Java中android.os.Bundle.putParcelableArray方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.putParcelableArray方法的具体用法?Java Bundle.putParcelableArray怎么用?Java Bundle.putParcelableArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Bundle
的用法示例。
在下文中一共展示了Bundle.putParcelableArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void onSaveInstanceState(Bundle outState) {
Value[] items = valueAdapter.getItems();
Log.i("ListValuesFragment", "Number of items: " + items.length);
if (items.length > 0) {
outState.putParcelableArray(BUNDLE_KEY, items);
}
super.onSaveInstanceState(outState);
}
示例2: saveState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public Parcelable saveState() {
Bundle state = new Bundle();
if (mSavedState.size() > 0) {
Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
mSavedState.toArray(fss);
state.putParcelableArray("states", fss);
}
for (int i = 0; i < mFragments.size(); i++) {
Fragment f = mFragments.get(i);
if (f != null && f.isAdded()) {
String key = "f" + i;
mFragmentManager.putFragment(state, key, f);
}
}
state.putString("mode", this.mode);
return state;
}
示例3: e
import android.os.Bundle; //导入方法依赖的package包/类
public Bundle e() {
Bundle bundle = new Bundle();
bundle.putString("ext_ele_name", this.a);
bundle.putString("ext_ns", this.b);
bundle.putString("ext_text", this.e);
Bundle bundle2 = new Bundle();
if (this.c != null && this.c.length > 0) {
for (int i = 0; i < this.c.length; i++) {
bundle2.putString(this.c[i], this.d[i]);
}
}
bundle.putBundle("attributes", bundle2);
if (this.f != null && this.f.size() > 0) {
bundle.putParcelableArray("children", a(this.f));
}
return bundle;
}
示例4: onSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
protected void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(KEY_INSTANCE_STATE_PENDING_REQUEST, mPendingRequest);
if (mPendingRequest == REQUEST_ADD_ACCOUNT) {
outState.putParcelableArray(KEY_INSTANCE_STATE_EXISTING_ACCOUNTS, mExistingAccounts);
}
if (mSelectedItemIndex != SELECTED_ITEM_NONE) {
if (mSelectedItemIndex == mAccounts.size()) {
outState.putBoolean(KEY_INSTANCE_STATE_SELECTED_ADD_ACCOUNT, true);
} else {
outState.putBoolean(KEY_INSTANCE_STATE_SELECTED_ADD_ACCOUNT, false);
outState.putString(KEY_INSTANCE_STATE_SELECTED_ACCOUNT_NAME,
mAccounts.get(mSelectedItemIndex).name);
}
}
outState.putParcelableArrayList(KEY_INSTANCE_STATE_ACCOUNT_LIST, mAccounts);
}
示例5: onSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
protected void onSaveInstanceState(Bundle outState) {
Parcelable[] achievementsConverted = null;
if (achievementsToShow != null) {
Object[] achievements = achievementsToShow.toArray();
achievementsConverted = Arrays.copyOf(achievements, achievements.length, Parcelable[].class);
}
super.onSaveInstanceState(outState);
outState.putBoolean(KEY_ACHIEVEMENT_OPEN, isAchievementOpen);
outState.putBoolean(KEY_START_GUIDE_OPEN, isStartGuideOpen);
outState.putBoolean(KEY_UPDATE_NOTIFIER_OPEN, isUpdateNotifierOpen);
outState.putBoolean(KEY_INSTANT_FEEDBACK_OPEN, isInstantFeedbackOpen);
outState.putBoolean(KEY_INSTANT_FEEDBACK_SHOWN, wasInstantFeedbackShown);
outState.putBoolean(KEY_ALL_ACHIEVEMENTS_SHOWN, wereAllAchievementsShown);
outState.putBoolean(KEY_START_GUIDE_SHOWN, wasStartGuideShown);
outState.putBoolean(KEY_UPDATE_NOTIFIER_SHOWN, wasUpdateNotifierShown);
outState.putParcelableArray(KEY_ALL_ACHIEVEMENTS, achievementsConverted);
}
示例6: query
import android.os.Bundle; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
String path = uri.getEncodedPath();
if (!path.startsWith("/font/")
|| selectionArgs == null || selectionArgs[0] == null) {
return null;
}
String name = path.substring("/font/".length());
String[] w = selectionArgs[0].split(",");
int[] weight = new int[w.length];
for (int i = 0; i < w.length; i++) {
weight[i] = Integer.parseInt(w[i]);
}
FontFamily[] families = FontManager.getFontFamily(getContext(), name, weight);
Bundle bundle = new Bundle();
bundle.putParcelableArray("data", families);
AbstractCursor cursor = new SimpleCursor();
cursor.setExtras(bundle);
return cursor;
}
示例7: create
import android.os.Bundle; //导入方法依赖的package包/类
protected static <T extends Parcelable> ListDialogFragment<T> create(
List<Selection<T>> options, Selection<T> current) {
Bundle args = new Bundle();
// Split value pairs to store them (since Selection does not implement Parcelable)
String[] names = new String[options.size()];
//noinspection unchecked
T[] values = (T[]) new Parcelable[options.size()];
for (int i = 0; i < options.size(); i++) {
names[i] = options.get(i).getName();
values[i] = options.get(i).getValue();
}
args.putStringArray(KEY_SELECTION_NAMES, names);
args.putParcelableArray(KEY_SELECTION_VALUES, values);
args.putInt(KEY_SELECTION_CURRENT, options.indexOf(current));
ListDialogFragment<T> fragment = new ListDialogFragment<>();
fragment.setArguments(args);
return fragment;
}
示例8: toBundle
import android.os.Bundle; //导入方法依赖的package包/类
private static Bundle toBundle(JSONObject node) throws JSONException {
Bundle bundle = new Bundle();
@SuppressWarnings("unchecked")
Iterator<String> fields = node.keys();
while (fields.hasNext()) {
String key = fields.next();
Object value;
value = node.get(key);
if (value instanceof JSONObject) {
bundle.putBundle(key, toBundle((JSONObject) value));
} else if (value instanceof JSONArray) {
JSONArray valueArr = (JSONArray) value;
if (valueArr.length() == 0) {
bundle.putStringArray(key, new String[0]);
} else {
Object firstNode = valueArr.get(0);
if (firstNode instanceof JSONObject) {
Bundle[] bundles = new Bundle[valueArr.length()];
for (int i = 0; i < valueArr.length(); i++) {
bundles[i] = toBundle(valueArr.getJSONObject(i));
}
bundle.putParcelableArray(key, bundles);
} else if (firstNode instanceof JSONArray) {
// we don't support nested arrays
throw new FacebookException("Nested arrays are not supported.");
} else { // just use the string value
String[] arrValues = new String[valueArr.length()];
for (int i = 0; i < valueArr.length(); i++) {
arrValues[i] = valueArr.get(i).toString();
}
bundle.putStringArray(key, arrValues);
}
}
} else {
bundle.putString(key, value.toString());
}
}
return bundle;
}
示例9: saveState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public Parcelable saveState() {
Bundle bundle = (Bundle) super.saveState();
// Never maintain any states from the base class, just null it out
if(bundle != null)
bundle.putParcelableArray("states", null);
return bundle;
}
示例10: getBundleForUnreadConversation
import android.os.Bundle; //导入方法依赖的package包/类
static Bundle getBundleForUnreadConversation(UnreadConversation uc) {
if (uc == null) {
return null;
}
Bundle b = new Bundle();
String author = null;
if (uc.getParticipants() != null && uc.getParticipants().length > 1) {
author = uc.getParticipants()[0];
}
Parcelable[] messages = new Parcelable[uc.getMessages().length];
for (int i = 0; i < messages.length; i++) {
Bundle m = new Bundle();
m.putString("text", uc.getMessages()[i]);
m.putString(KEY_AUTHOR, author);
messages[i] = m;
}
b.putParcelableArray(KEY_MESSAGES, messages);
RemoteInput remoteInput = uc.getRemoteInput();
if (remoteInput != null) {
b.putParcelable(KEY_REMOTE_INPUT, fromCompatRemoteInput(remoteInput));
}
b.putParcelable(KEY_ON_REPLY, uc.getReplyPendingIntent());
b.putParcelable(KEY_ON_READ, uc.getReadPendingIntent());
b.putStringArray(KEY_PARTICIPANTS, uc.getParticipants());
b.putLong(KEY_TIMESTAMP, uc.getLatestTimestamp());
return b;
}
示例11: newInstance
import android.os.Bundle; //导入方法依赖的package包/类
public static AspectRatioFragment newInstance(Set<AspectRatio> ratios,
AspectRatio currentRatio) {
final AspectRatioFragment fragment = new AspectRatioFragment();
final Bundle args = new Bundle();
args.putParcelableArray(ARG_ASPECT_RATIOS,
ratios.toArray(new AspectRatio[ratios.size()]));
args.putParcelable(ARG_CURRENT_ASPECT_RATIO, currentRatio);
fragment.setArguments(args);
return fragment;
}
示例12: getBundleArrayFromBundle
import android.os.Bundle; //导入方法依赖的package包/类
public static Bundle[] getBundleArrayFromBundle(Bundle bundle, String key) {
Parcelable[] array = bundle.getParcelableArray(key);
if ((array instanceof Bundle[]) || array == null) {
return (Bundle[]) array;
}
Bundle[] typedArray = (Bundle[]) Arrays.copyOf(array, array.length, Bundle[].class);
bundle.putParcelableArray(key, typedArray);
return typedArray;
}
示例13: put
import android.os.Bundle; //导入方法依赖的package包/类
public Bundler put(@NonNull String key, Parcelable[] value) {
Bundle safeBundle = new Bundle();
safeBundle.putParcelableArray(key, value);
if (isValidBundleSize(safeBundle)) {
bundle.putParcelableArray(key, value);
}
clearBundle(safeBundle);
return this;
}
示例14: getNotificationArrayFromBundle
import android.os.Bundle; //导入方法依赖的package包/类
private static Notification[] getNotificationArrayFromBundle(Bundle bundle, String key) {
Parcelable[] array = bundle.getParcelableArray(key);
if ((array instanceof Notification[]) || array == null) {
return (Notification[]) array;
}
Notification[] typedArray = new Notification[array.length];
for (int i = 0; i < array.length; i++) {
typedArray[i] = (Notification) array[i];
}
bundle.putParcelableArray(key, typedArray);
return typedArray;
}
示例15: getBundleForAction
import android.os.Bundle; //导入方法依赖的package包/类
private static Bundle getBundleForAction(Action action) {
Bundle bundle = new Bundle();
bundle.putInt("icon", action.getIcon());
bundle.putCharSequence("title", action.getTitle());
bundle.putParcelable(KEY_ACTION_INTENT, action.getActionIntent());
bundle.putBundle(KEY_EXTRAS, action.getExtras());
bundle.putParcelableArray(KEY_REMOTE_INPUTS, RemoteInputCompatJellybean.toBundleArray(action.getRemoteInputs()));
return bundle;
}