private void load(boolean allowCached) { if (allowCached && mWallpapers != null) { mAdapter.set(mWallpapers); setListShown(true); return; } setListShown(false); Bridge.config().logging(true); WallpaperUtils.getAll( getActivity(), allowCached, new WallpaperUtils.WallpapersCallback() { @Override public void onRetrievedWallpapers( WallpaperUtils.WallpapersHolder wallpapers, Exception error, boolean cancelled) { if (error != null) { mEmpty.setText(error.getMessage()); } else { mEmpty.setText(cancelled ? R.string.request_cancelled : R.string.no_wallpapers); mWallpapers = wallpapers; mAdapter.set(mWallpapers); } setListShown(true); } }); }
@Override public void onPause() { super.onPause(); if (getActivity() != null) { if (mAdapter != null) WallpaperUtils.saveDb(getActivity(), mAdapter.getWallpapers()); if (getActivity().isFinishing()) { Bridge.cancelAll().tag(WallpapersFragment.class.getName()).commit(); } } }
public void load() { load(!WallpaperUtils.didExpire(getActivity())); }
@Override public void onDestroyView() { super.onDestroyView(); ButterKnife.unbind(this); WallpaperUtils.resetOptionCache(true); }