Search in sources :

Example 1 with Loader

use of android.support.v4.content.Loader in project Reader by TheKeeperOfPie.

the class RecyclerFragmentPagerAdapter method restoreState.

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        savedStates.clear();
        fragments.clear();
        if (fss != null) {
            for (Parcelable fs : fss) {
                savedStates.add((Fragment.SavedState) fs);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                FragmentType f = (FragmentType) fragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (fragments.size() <= index) {
                        fragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    fragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}
Also used : Bundle(android.os.Bundle) Parcelable(android.os.Parcelable) Fragment(android.support.v4.app.Fragment)

Example 2 with Loader

use of android.support.v4.content.Loader in project android-ui-design-pattern by MathieuCalba.

the class FeedItemActivity method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle b) {
    final int realId = id - mFeedId * 100 - mCategoryId;
    if (realId == LOADER_ID_FEED_LIST) {
        if (b != null) {
            final int feedId = b.getInt(EXTRA_FEED_ID, -1);
            if (feedId != -1) {
                final int categoryId = b.getInt(EXTRA_CATEGORY_ID, -1);
                Uri uri = null;
                if (categoryId == -1) {
                    uri = YANAContract.ArticleTable.buildUriWithFeedId(feedId);
                } else {
                    uri = YANAContract.ArticleTable.buildUriWithFeedIdAndCategoryId(feedId, categoryId);
                }
                return new CursorLoader(this, uri, YANAContract.ArticleTable.PROJ_LIST.COLS, null, null, YANAContract.ArticleTable.DEFAULT_SORT);
            }
        }
    }
    return null;
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) Uri(android.net.Uri)

Example 3 with Loader

use of android.support.v4.content.Loader in project actor-platform by actorapp.

the class FragmentNoMenuStatePagerAdapter method restoreState.

@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();
        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);
                }
            }
        }
    }
}
Also used : Bundle(android.os.Bundle) Parcelable(android.os.Parcelable) Fragment(android.support.v4.app.Fragment)

Example 4 with Loader

use of android.support.v4.content.Loader in project chuck by jgilfelt.

the class TransactionActivity method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    CursorLoader loader = new CursorLoader(this);
    loader.setUri(ContentUris.withAppendedId(ChuckContentProvider.TRANSACTION_URI, transactionId));
    return loader;
}
Also used : CursorLoader(android.support.v4.content.CursorLoader)

Example 5 with Loader

use of android.support.v4.content.Loader in project Android-ObservableScrollView by ksoichiro.

the class CacheFragmentStatePagerAdapter method restoreState.

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    Bundle bundle = (Bundle) state;
    int pages = bundle.getInt(STATE_PAGES);
    if (0 < pages) {
        for (int i = 0; i < pages; i++) {
            int position = bundle.getInt(createCacheIndex(i));
            Fragment f = mFm.getFragment(bundle, createCacheKey(position));
            mPages.put(position, f);
        }
    }
    Parcelable p = bundle.getParcelable(STATE_SUPER_STATE);
    super.restoreState(p, loader);
}
Also used : Bundle(android.os.Bundle) Parcelable(android.os.Parcelable) Fragment(android.support.v4.app.Fragment)

Aggregations

Fragment (android.support.v4.app.Fragment)16 Bundle (android.os.Bundle)15 CursorLoader (android.support.v4.content.CursorLoader)11 View (android.view.View)7 Context (android.content.Context)6 Parcelable (android.os.Parcelable)6 RecyclerView (android.support.v7.widget.RecyclerView)6 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 ActivityManager (android.app.ActivityManager)5 Point (android.graphics.Point)5 AccessibilityNodeInfoCompat (android.support.v4.view.accessibility.AccessibilityNodeInfoCompat)5 GridLayoutManager (android.support.v7.widget.GridLayoutManager)5 SpanSizeLookup (android.support.v7.widget.GridLayoutManager.SpanSizeLookup)5 Recycler (android.support.v7.widget.RecyclerView.Recycler)5 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)5 DocumentClipper (com.android.documentsui.DocumentClipper)5 State (com.android.documentsui.State)5 Selection (com.android.documentsui.dirlist.MultiSelectManager.Selection)5 Cursor (android.database.Cursor)4