Source:
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager( getResources().getInteger(R.integer.news_fragment_column_count), StaggeredGridLayoutManager.VERTICAL); getListView().setLayoutManager(layoutManager); mAdapter = new NewsAdapter(getActivity(), ((GdgActivity) getActivity()).getGoogleApiClient()); setRecyclerAdapter(mAdapter); setOnRefreshListener(this); final String plusId = getArguments().getString(Const.EXTRA_PLUS_ID); if (Utils.isOnline(getActivity())) { setIsLoading(true); App.getInstance().getModelCache() .getAsync(CACHE_KEY_NEWS + plusId, new ModelCache.CacheListener() { @Override public void onGet(Object item) { Activities activityFeed = (Activities) item; mAdapter.addAll(activityFeed.getItems()); setIsLoading(false); } @Override public void onNotFound(String key) { App.getInstance().getPlusApi().getActivities(plusId).enqueue( new Callback<Activities>() { @Override public void success(Activities activityFeed) { if (activityFeed != null) { mAdapter.addAll(activityFeed.getItems()); } else { } setIsLoading(false); } }); } }); } else { App.getInstance().getModelCache().getAsync(CACHE_KEY_NEWS + plusId, false, new ModelCache.CacheListener() { @Override public void onGet(Object item) { Activities feed = (Activities) item; if (isAdded()) { Snackbar snackbar = Snackbar.make(getView(), R.string.cached_content, Snackbar.LENGTH_SHORT); ColoredSnackBar.info(snackbar).show(); } mAdapter.addAll(feed.getItems()); setIsLoading(false); } @Override public void onNotFound(String key) { showError(R.string.offline_alert); } }); } }

Target:
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager( getResources().getInteger(R.integer.news_fragment_column_count), StaggeredGridLayoutManager.VERTICAL); getListView().setLayoutManager(layoutManager); mAdapter = new NewsAdapter(getActivity(), ((GdgActivity) getActivity()).getGoogleApiClient()); setRecyclerAdapter(mAdapter); setOnRefreshListener(this); final String plusId = getArguments().getString(Const.EXTRA_PLUS_ID); if (Utils.isOnline(getActivity())) { setIsLoading(true); App.getInstance().getModelCache() .getAsync(ModelCache.KEY_NEWS + plusId, new ModelCache.CacheListener() { @Override public void onGet(Object item) { Activities activityFeed = (Activities) item; mAdapter.addAll(activityFeed.getItems()); setIsLoading(false); } @Override public void onNotFound(String key) { App.getInstance().getPlusApi().getActivities(plusId).enqueue( new Callback<Activities>() { @Override public void success(Activities activityFeed) { if (activityFeed != null) { mAdapter.addAll(activityFeed.getItems()); } else { } setIsLoading(false); } }); } }); } else { App.getInstance().getModelCache().getAsync(ModelCache.KEY_NEWS + plusId, false, new ModelCache.CacheListener() { @Override public void onGet(Object item) { Activities feed = (Activities) item; if (isAdded()) { Snackbar snackbar = Snackbar.make(getView(), R.string.cached_content, Snackbar.LENGTH_SHORT); ColoredSnackBar.info(snackbar).show(); } mAdapter.addAll(feed.getItems()); setIsLoading(false); } @Override public void onNotFound(String key) { showError(R.string.offline_alert); } }); } }