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);
}
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;
}
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);
}
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);
}
}
}
}
}
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;
}
Aggregations