Java Code Examples for android.os.Bundle.putParcelableArray()

The following are Jave code examples for showing how to use putParcelableArray() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Quran   File: FragmentStatePagerAdapter.java   View Source Code Vote up 6 votes
@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;
}
 
Example 2
Project: boohee_v5.6   File: a.java   View Source Code Vote up 6 votes
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;
}
 
Example 3
Project: TPlayer   File: ChooseTypeAndAccountActivity.java   View Source Code Vote up 6 votes
@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);
}
 
Example 4
Project: Veggietizer   File: OverviewActivity.java   View Source Code Vote up 6 votes
@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);
}
 
Example 5
Project: FontProvider   File: FontProvider.java   View Source Code Vote up 6 votes
@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;
}
 
Example 6
Project: Options   File: DialogListOption.java   View Source Code Vote up 6 votes
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;
}
 
Example 7
Project: kognitivo   File: AppLinkData.java   View Source Code Vote up 5 votes
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;
}
 
Example 8
Project: anitrend-app   File: DefaultStatePagerAdapter.java   View Source Code Vote up 5 votes
@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;
}
 
Example 9
Project: boohee_v5.6   File: NotificationCompatApi21.java   View Source Code Vote up 5 votes
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;
}
 
Example 10
Project: Android_watch_magpie   File: ListValuesFragment.java   View Source Code Vote up 5 votes
@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);
}
 
Example 11
Project: CameraKitView   File: AspectRatioFragment.java   View Source Code Vote up 5 votes
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;
}
 
Example 12
Project: AndroidBackendlessChat   File: AppLinkData.java   View Source Code Vote up 5 votes
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;
}
 
Example 13
Project: boohee_v5.6   File: BundleUtil.java   View Source Code Vote up 5 votes
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;
}
 
Example 14
Project: garras   File: Bundler.java   View Source Code Vote up 5 votes
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;
}
 
Example 15
Project: boohee_v5.6   File: NotificationCompat.java   View Source Code Vote up 5 votes
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;
}
 
Example 16
Project: boohee_v5.6   File: NotificationCompatJellybean.java   View Source Code Vote up 5 votes
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;
}
 
Example 17
Project: letv   File: NotificationCompat.java   View Source Code Vote up 5 votes
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;
}
 
Example 18
Project: GitHub   File: Injector.java   View Source Code Vote up 4 votes
public void putParcelableArray(Bundle state, String key, Parcelable[] x) {
    state.putParcelableArray(key + baseKey, x);
}
 
Example 19
Project: Android-app   File: MainActivity.java   View Source Code Vote up 4 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    outState.putParcelableArray(VIDEOS_KEY, videos);
}
 
Example 20
Project: Lyra   File: ParcelableArrayCoder.java   View Source Code Vote up 2 votes
/**
 * Write a field's value into the saved state {@link Bundle}.
 *
 * @param state      {@link Bundle} used to save the state
 * @param key        key retrieved from {@code fieldDeclaringClass#fieldName}
 * @param fieldValue value of field
 */
@Override
public void serialize(@NonNull Bundle state, @NonNull String key, @NonNull Parcelable[] fieldValue) {
    state.putParcelableArray(key, fieldValue);
}