Search in sources :

Example 16 with Loader

use of android.support.v4.content.Loader in project bitcoin-wallet by bitcoin-wallet.

the class PeerListFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            adapter.notifyItemsChanged();
            final Loader<String> loader = loaderManager.getLoader(ID_REVERSE_DNS_LOADER);
            final boolean loaderRunning = loader != null && loader.isStarted();
            if (!loaderRunning) {
                for (int i = 0; i < adapter.getItemCount(); i++) {
                    final Peer peer = adapter.getItem(i);
                    final InetAddress address = peer.getAddress().getAddr();
                    if (!hostnames.containsKey(address)) {
                        final Bundle args = new Bundle();
                        args.putSerializable("address", address);
                        loaderManager.initLoader(ID_REVERSE_DNS_LOADER, args, reverseDnsLoaderCallbacks).forceLoad();
                        break;
                    }
                }
            }
            handler.postDelayed(this, REFRESH_MS);
        }
    }, REFRESH_MS);
}
Also used : Bundle(android.os.Bundle) Peer(org.bitcoinj.core.Peer) AsyncTaskLoader(android.support.v4.content.AsyncTaskLoader) Loader(android.support.v4.content.Loader) InetAddress(java.net.InetAddress)

Example 17 with Loader

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

the class TransactionListFragment method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    CursorLoader loader = new CursorLoader(getContext());
    loader.setUri(ChuckContentProvider.TRANSACTION_URI);
    if (!TextUtils.isEmpty(currentFilter)) {
        if (TextUtils.isDigitsOnly(currentFilter)) {
            loader.setSelection("responseCode LIKE ?");
            loader.setSelectionArgs(new String[] { currentFilter + "%" });
        } else {
            loader.setSelection("path LIKE ?");
            loader.setSelectionArgs(new String[] { "%" + currentFilter + "%" });
        }
    }
    loader.setProjection(HttpTransaction.PARTIAL_PROJECTION);
    loader.setSortOrder("requestDate DESC");
    return loader;
}
Also used : CursorLoader(android.support.v4.content.CursorLoader)

Example 18 with Loader

use of android.support.v4.content.Loader in project UltimateRecyclerView by cymcsg.

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)

Example 19 with Loader

use of android.support.v4.content.Loader in project ViewPagerIndicator by LuckyJayce.

the class FragmentListPageAdapter method restoreState.

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        mSavedState.clear();
        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);
                }
            }
        }
    }
}
Also used : Bundle(android.os.Bundle) Fragment(android.support.v4.app.Fragment)

Example 20 with Loader

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

the class FeedListFragment method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle b) {
    final int realId = id - mFeedId * 100 - mCategoryId;
    if (realId == LOADER_ID_BASE_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(getActivity(), 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)

Aggregations

Bundle (android.os.Bundle)16 Fragment (android.support.v4.app.Fragment)16 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