Example usage for android.os Bundle setClassLoader

List of usage examples for android.os Bundle setClassLoader

Introduction

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

Prototype

@Override
public void setClassLoader(ClassLoader loader) 

Source Link

Document

Changes the ClassLoader this Bundle uses when instantiating objects.

Usage

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

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();/*w  w  w .j  av a 2  s  .  c om*/
        mFragments.clear();
        if (fss != null) {
            for (Parcelable fs : fss) {
                mSavedState.add((Fragment.SavedState) fs);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:com.cokus.fangdouyu.widget.viewpagerindicator.view.indicator.FragmentListPageAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        mSavedState.clear();//from  w w  w.  j av  a2  s. c om
        mFragments.clear();
        if (bundle.containsKey("states")) {
            mSavedState = bundle.getSparseParcelableArray("states");
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    f.setMenuVisibility(false);
                    mFragments.put(index, f);
                } else {
                    //                  Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:edt.com.edt.view.mainpage.indicator.FragmentListPageAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        mSavedState.clear();//from   w  w w .j a  v  a2 s.  c o m
        mFragments.clear();
        if (bundle.containsKey("states")) {
            mSavedState = bundle.getSparseParcelableArray("states");
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    f.setMenuVisibility(false);
                    mFragments.put(index, f);
                } else {
                    //                  Log.w(TAG, "Bad fragment_home at key " + key);
                }
            }
        }
    }
}

From source file:com.example.li.demo.tab.FragmentListPageAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        mSavedState.clear();/*from w  w  w.j av a 2s .  co m*/
        mFragments.clear();
        if (bundle.containsKey("states")) {
            mSavedState = bundle.getSparseParcelableArray("states");
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    f.setMenuVisibility(false);
                    mFragments.put(index, f);
                } else {
                    Log.w("", "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:com.klinker.android.launcher.addons.pages.FragmentStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();//from   www  .j  ava 2s  .  c  om
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                try {
                    Fragment f = mFragmentManager.getFragment(bundle, key);
                    if (f != null) {
                        while (mFragments.size() <= index) {
                            mFragments.add(null);
                        }
                        f.setMenuVisibility(false);
                        mFragments.set(index, f);
                    } else {
                        Log.w(TAG, "Bad fragment at key " + key);
                    }
                } catch (IllegalStateException e) {
                    // fragment no longer exists
                }
            }
        }
    }
}

From source file:com.collegiate.core.FragmentStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();/*from   w w  w  . ja  v a  2  s . c  o m*/
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                }
            }
        }
    }
}

From source file:Main.java

/**
 * Concatenate two Parcelable Bundles containing char[] to form one Parcelable.<br>
 * The char[] message is stored via Bundle.putCharArray using {@link #BUNDLE_PROPERTIES} as the key for the item.<br>
 *  /* w w  w .ja  v  a 2s.  co  m*/
 * @param one       Parcelable Bundle, containing char[] message
 * @param another    Parcelable Bundle, containing char[] message
 * @return Parcelable Bundle, including Parcelable one and another.
 * @see Bundle#putCharArray(String, char[])
 * @see Bundle#getCharArray(String)
 */
public static Parcelable assembleParcelProps(Parcelable one, Parcelable another) {
    Bundle bundle = new Bundle();
    char[] characters = null;
    char[] characters1 = null;
    char[] characters2 = null;
    int length = 0;

    if (one != null) {
        characters1 = ((Bundle) one).getCharArray(BUNDLE_PROPERTIES);
        if (characters1 != null)
            length += characters1.length;
    }
    if (another != null) {
        characters2 = ((Bundle) another).getCharArray(BUNDLE_PROPERTIES);
        if (characters2 != null)
            length += characters2.length;
    }

    characters = new char[length];

    if (characters1 != null && characters2 != null) {
        System.arraycopy(characters1, 0, characters, 0, characters1.length);
        System.arraycopy(characters2, 0, characters, characters1.length, characters2.length);
    } else if (characters1 != null && characters2 == null) {
        System.arraycopy(characters1, 0, characters, 0, characters1.length);
    } else if (characters1 == null && characters2 != null) {
        System.arraycopy(characters2, 0, characters, 0, characters2.length);
    }

    bundle.putCharArray(BUNDLE_PROPERTIES, characters);
    bundle.setClassLoader(Bundle.class.getClassLoader());
    return bundle;
}

From source file:cn.youngkaaa.yviewpager.YFragmentStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();//from   w w w .j  a  v  a 2  s  . c o m
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

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

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();//from w  w w  .j  a v  a 2  s  .  co m
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    FragmentCompat.setMenuVisibility(f, false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:chat.crypt.messenger.app.view.FragmentNoMenuStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();/*w ww  .ja v a 2 s  .c  o  m*/
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    // f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}