use of dev.dworks.apps.anexplorer.adapter.RecentsAdapter in project AnExplorer by 1hakr.
the class HomeFragment method showRecents.
private void showRecents() {
final RootInfo root = roots.getRecentsRoot();
recents.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openRoot(root);
}
});
mRecentsAdapter = new RecentsAdapter(getActivity(), null);
mRecentsAdapter.setOnItemClickListener(new RecentsAdapter.OnItemClickListener() {
@Override
public void onItemClick(RecentsAdapter.ViewHolder item, int position) {
openDocument(item.mDocumentInfo);
}
});
mRecentsRecycler.setAdapter(mRecentsAdapter);
LinearSnapHelper helper = new LinearSnapHelper();
helper.attachToRecyclerView(mRecentsRecycler);
final BaseActivity.State state = getDisplayState(this);
mCallbacks = new LoaderManager.LoaderCallbacks<DirectoryResult>() {
@Override
public Loader<DirectoryResult> onCreateLoader(int id, Bundle args) {
final RootsCache roots = DocumentsApplication.getRootsCache(getActivity());
return new RecentLoader(getActivity(), roots, state);
}
@Override
public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result) {
if (!isAdded())
return;
if (null == result.cursor || (null != result.cursor && result.cursor.getCount() == 0)) {
recents_container.setVisibility(View.GONE);
} else {
// recents_container.setVisibility(View.VISIBLE);
mRecentsAdapter.swapCursor(new LimitCursorWrapper(result.cursor, MAX_RECENT_COUNT));
}
}
@Override
public void onLoaderReset(Loader<DirectoryResult> loader) {
mRecentsAdapter.swapCursor(null);
}
};
getLoaderManager().restartLoader(mLoaderId, null, mCallbacks);
}
Aggregations