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:br.fapema.morholt.android.wizardpager.wizard.basic.FixedFragmentStatePagerAdapter.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  a v  a2  s  .c  o m*/
        mFragments.clear();

        ArrayList<String> tags = bundle.getStringArrayList("tags");
        if (tags != null) {
            mSavedFragmentTags = tags;
        } else {
            mSavedFragmentTags.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:am.project.x.widget.FragmentRemovePagerAdapter.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 ww w  .j  a v a  2  s  .co  m
        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")) {
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    f.setMenuVisibility(false);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:com.tapchatapp.android.app.ui.TapchatFragmentStatePagerAdapter.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  ava  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);
                    f.onResume();
                } else {
                    if (DEBUG)
                        Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:com.webalcove.travelbook.FixedFragmentStatePagerAdapter.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  .ja va2 s . c o m
        mFragments.clear();
        ArrayList<String> tags = bundle.getStringArrayList("tags");
        if (tags != null) {
            mSavedFragmentTags = tags;
        } else {
            mSavedFragmentTags.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:com.gawdl3y.android.tasktimer.adapters.NewFragmentStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        mItemIds = bundle.getIntArray("itemids");
        if (mItemIds == null) {
            mItemIds = new int[] {};
        }/*from w ww  .j a va2 s .  c  o m*/
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        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:com.btmura.android.reddit.app.FragmentStateItemPagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        mItemIds = bundle.getLongArray("itemIds");
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();// w w  w. j  a  v  a2  s .  com
        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:com.philliphsu.bottomsheetpickers.date.PagingMonthAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        String[] titles = bundle.getStringArray(KEY_MONTH_YEAR_TITLES);
        int[] positions = bundle.getIntArray(KEY_POSITIONS);
        mMonthYearTitles.clear();// w w w  .j a  v  a 2 s  .c  om
        if (titles != null && positions != null) {
            // Both arrays should be the same size, so use either length.
            for (int i = 0; i < titles.length; i++) {
                mMonthYearTitles.append(positions[i], titles[i]);
            }
        }
    }
}

From source file:com.example.craiger.nav.FragmentItemIdStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        long[] itemIdsForState = bundle.getLongArray("itemIdsForState");
        Parcelable[] fss = bundle.getParcelableArray("states");
        mFragmentToItemIdMap.clear();/*from  w  w w  . j  av a2s . com*/
        mItemIdToFragmentMap.clear();
        mUnusedRestoredFragments.clear();
        mSavedState.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.put(itemIdsForState[i], (Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith(KEY_FRAGMENT)) {
                Long itemId = Long.parseLong(key.substring(KEY_FRAGMENT.length()));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    f.setMenuVisibility(false);
                    mFragmentToItemIdMap.put(f, itemId);
                    mItemIdToFragmentMap.put(itemId, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
        mUnusedRestoredFragments.addAll(mFragmentToItemIdMap.keySet());
    }
}

From source file:com.esminis.server.library.activity.DrawerFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        Bundle bundle = savedInstanceState.getBundle("android:preferences");
        if (bundle != null) {
            try {
                Parcelable parcelable = bundle.getParcelable("modules");
                if (parcelable != null) {
                    Field field = parcelable.getClass().getDeclaredField("dialogBundle");
                    field.setAccessible(true);
                    Bundle bundleTemp = (Bundle) field.get(parcelable);
                    if (bundleTemp != null) {
                        bundleTemp.setClassLoader(getClass().getClassLoader());
                    }//from  ww w.  j av  a 2  s .  c  om
                }
            } catch (Throwable ignored) {
            }
        }
    }
    super.onActivityCreated(savedInstanceState);
    if (getView() == null) {
        return;
    }
    View view = getView().findViewById(android.R.id.list);
    if (view == null) {
        return;
    }
    TypedValue attribute = new TypedValue();
    getActivity().getTheme().resolveAttribute(android.R.attr.windowBackground, attribute, true);
    if (attribute.resourceId > 0) {
        view.setBackgroundColor(ContextCompat.getColor(getActivity(), attribute.resourceId));
    }
}

From source file:net.thetranquilpsychonaut.hashtagger.cwacpager.ArrayPagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    Bundle b = (Bundle) state;
    b.setClassLoader(getClass().getClassLoader());
    entries = ((Bundle) state).getParcelableArrayList(KEY_DESCRIPTORS);
    notifyDataSetChanged();//from ww  w .  j  a  va  2s.  c  o m
}