Example usage for android.os Bundle putParcelableArray

List of usage examples for android.os Bundle putParcelableArray

Introduction

In this page you can find the example usage for android.os Bundle putParcelableArray.

Prototype

public void putParcelableArray(@Nullable String key, @Nullable Parcelable[] value) 

Source Link

Document

Inserts an array of Parcelable values into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java

/**
 * Use this factory method to create a new instance of
 * this fragment using the provided parameters.
 *
 * @param buddyId   the buddyId to whom the image should be sent
 * @param name      the name of the chat
 * @param imageUris the imageUris representing the images that are added
 * @return A new instance of fragment SendImageFragment.
 */// ww w.  jav  a2  s . c  om
public static SendImageFragment newInstance(String buddyId, String name, Parcelable... imageUris) {
    SendImageFragment fragment = new SendImageFragment();
    Bundle args = new Bundle();
    args.putParcelableArray(Constants.IMAGE_URI, imageUris);
    args.putString(Constants.BUDDY_ID, buddyId);
    args.putString(Constants.CHAT_NAME, name);
    fragment.setArguments(args);
    return fragment;
}

From source file:Main.java

@SuppressWarnings("unchecked")
private static void putArray(String key, ArrayList arrayList, Bundle bundle) {
    if (arrayList.size() == 0) {
        bundle.putBooleanArray(key, new boolean[] {});
    } else {// w w w . j a  va  2 s.  c  o m
        verifyArrayListIsSingleType(arrayList);
        if (arrayList.get(0) instanceof String) {
            bundle.putStringArray(key, toStringArray((ArrayList<String>) arrayList));
        } else if (arrayList.get(0) instanceof Integer) {
            bundle.putIntArray(key, toIntArray((ArrayList<Integer>) arrayList));
        } else if (arrayList.get(0) instanceof Float) {
            bundle.putFloatArray(key, toFloatArray((ArrayList<Float>) arrayList));
        } else if (arrayList.get(0) instanceof Double) {
            bundle.putDoubleArray(key, toDoubleArray((ArrayList<Double>) arrayList));
        } else if (arrayList.get(0) instanceof Boolean) {
            bundle.putBooleanArray(key, toBooleanArray((ArrayList<Boolean>) arrayList));
        } else if (arrayList.get(0) instanceof HashMap) {
            bundle.putParcelableArray(key, toBundleArray((ArrayList<HashMap>) arrayList));
        } else if (arrayList.get(0) instanceof ArrayList) {
            Log.w("RNNavigation",
                    "Arrays of arrays passed in props are converted to dictionaries with indexes as keys");
            Bundle innerArray = new Bundle();
            for (int i = 0; i < arrayList.size(); i++) {
                putArray(String.valueOf(i), (ArrayList) arrayList.get(i), innerArray);
            }
            bundle.putParcelable(key, innerArray);
        }
    }
}

From source file:com.liu.Account.view.emojicon.EmojiconGridFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelableArray(EMOJICONS_KEY, mData);
}

From source file:com.shoutin.emojicons.EmojiconGridFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelableArray(ARG_EMOJICONS, mEmojicons);
}

From source file:com.repkap11.repcast.activities.RepcastActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putParcelableArray(INSTANCE_STATE_BACK_STACK_FILES,
            mBackSelectFileFragments.toArray(new JsonDirectory.JsonFileDir[0]));
    outState.putParcelableArray(INSTANCE_STATE_BACK_STACK_TORRENTS,
            mBackTorrentFragments.toArray(new JsonTorrent.JsonTorrentResult[0]));
    super.onSaveInstanceState(outState);
}

From source file:com.github.michalbednarski.intentslab.bindservice.InvokeAidlMethodFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelableArray(STATE_METHOD_ARGUMENTS,
            mMethodArgumentsToRestore != null ? mMethodArgumentsToRestore : // Not fully restored
                    mArgumentsEditorHelper != null ? mArgumentsEditorHelper.getSandboxedArguments() : null);
}

From source file:com.github.michalbednarski.intentslab.ActivityMonitorActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mRecordedIntents != null) {
        outState.putParcelableArray("recordedIntents", mRecordedIntents);
    }/*from   w  ww  . jav a 2 s.  com*/
}

From source file:com.facebook.AppLinkData.java

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;/*from  w w w.  ja v a  2s  .c  om*/
        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;
}

From source file:cl.monsoon.s1next.widget.FragmentStatePagerAdapter.java

@Override
public Parcelable saveState() {
    Bundle state = null;
    if (mSavedState.size() > 0) {
        state = new Bundle();
        Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
        mSavedState.toArray(fss);/*www .j a  v  a  2 s .  co m*/
        state.putParcelableArray("states", fss);
    }
    for (int i = 0; i < mFragments.size(); i++) {
        Fragment f = mFragments.get(i);
        if (f != null && f.isAdded()) {
            if (state == null) {
                state = new Bundle();
            }
            String key = "f" + i;
            mFragmentManager.putFragment(state, key, f);
        }
    }
    return state;
}

From source file:android.support.v13.app.FragmentStatePagerAdapter.java

@Override
public Parcelable saveState() {
    Bundle state = null;
    if (mSavedState.size() > 0) {
        state = new Bundle();
        Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
        mSavedState.toArray(fss);//www  .jav  a  2 s . c  o m
        state.putParcelableArray("states", fss);
    }
    for (int i = 0; i < mFragments.size(); i++) {
        Fragment f = mFragments.get(i);
        if (f != null) {
            if (state == null) {
                state = new Bundle();
            }
            String key = "f" + i;
            mFragmentManager.putFragment(state, key, f);
        }
    }
    return state;
}