use of com.foobnix.ui2.adapter.AuthorsAdapter2 in project LibreraReader by foobnix.
the class SearchFragment2 method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_search2, container, false);
NO_SERIES = " (" + getString(R.string.without_series) + ")";
handler = new Handler();
secondTopPanel = view.findViewById(R.id.secondTopPanel);
countBooks = (TextView) view.findViewById(R.id.countBooks);
onRefresh = view.findViewById(R.id.onRefresh);
onRefresh.setActivated(true);
cleanFilter = (ImageView) view.findViewById(R.id.cleanFilter);
sortBy = (TextView) view.findViewById(R.id.sortBy);
sortOrder = (ImageView) view.findViewById(R.id.sortOrder);
myAutoCompleteImage = (ImageView) view.findViewById(R.id.myAutoCompleteImage);
searchEditText = (AutoCompleteTextView) view.findViewById(R.id.filterLine);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
myAutoCompleteImage.setVisibility(View.GONE);
((FastScrollRecyclerView) recyclerView).setFastScrollStateChangeListener(new FastScrollStateChangeListener() {
@Override
public void onFastScrollStop() {
ImageLoader.getInstance().resume();
LOG.d("ImageLoader resume");
}
@Override
public void onFastScrollStart() {
LOG.d("ImageLoader pause");
ImageLoader.getInstance().pause();
}
});
searchEditText.addTextChangedListener(filterTextWatcher);
searchEditText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
EditTextHelper.enableKeyboardSearch(searchEditText, new Runnable() {
@Override
public void run() {
Keyboards.close(searchEditText);
Keyboards.hideNavigation(getActivity());
}
});
searchAdapter = new FileMetaAdapter();
authorsAdapter = new AuthorsAdapter2();
onGridlList = (ImageView) view.findViewById(R.id.onGridList);
onGridlList.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
popupMenu(onGridlList);
}
});
onRefresh.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!onRefresh.isActivated()) {
Toast.makeText(getActivity(), R.string.extracting_information_from_books, Toast.LENGTH_LONG).show();
return;
}
PrefDialogs.chooseFolderDialog(getActivity(), new Runnable() {
@Override
public void run() {
AppState.get().searchPaths = AppState.get().searchPaths.replace("//", "/");
}
}, new Runnable() {
@Override
public void run() {
recyclerView.scrollToPosition(0);
seachAll();
}
});
}
});
cleanFilter.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
searchEditText.setText("");
recyclerView.scrollToPosition(0);
searchAndOrderAsync();
}
});
sortBy.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
sortByPopup(v);
}
});
sortOrder.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AppState.get().isSortAsc = !AppState.get().isSortAsc;
searchAndOrderAsync();
}
});
bindAdapter(searchAdapter);
searchAdapter.setOnAuthorClickListener(onAuthorClick);
searchAdapter.setOnSeriesClickListener(onSeriesClick);
authorsAdapter.setOnItemClickListener(onAuthorSeriesClick);
onGridList();
if (AppDB.get().getCount() == 0) {
seachAll();
} else {
checkForDeleteBooks();
searchAndOrderAsync();
}
initAutocomplition();
onTintChanged();
recyclerView.addOnScrollListener(new OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
}
});
myAutoCompleteImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showAutoCompleteDialog();
}
});
return view;
}
use of com.foobnix.ui2.adapter.AuthorsAdapter2 in project LibreraReader by foobnix.
the class UIFragment method onGridList.
public void onGridList(int mode, ImageView onGridlList, final FileMetaAdapter searchAdapter, AuthorsAdapter2 authorsAdapter) {
if (searchAdapter == null) {
return;
}
if (onGridlList != null) {
PopupHelper.updateGridOrListIcon(onGridlList, mode);
}
if (mode == AppState.MODE_LIST) {
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(mLayoutManager);
searchAdapter.setAdapterType(FileMetaAdapter.ADAPTER_LIST);
recyclerView.setAdapter(searchAdapter);
} else if (mode == AppState.MODE_COVERS || mode == AppState.MODE_GRID) {
final int num = Math.max(1, Dips.screenWidthDP() / AppState.get().coverBigSize);
GridLayoutManager mGridManager = new GridLayoutManager(getActivity(), num);
mGridManager.setSpanSizeLookup(new SpanSizeLookup() {
@Override
public int getSpanSize(int pos) {
int type = searchAdapter.getItemViewType(pos);
if (type == FileMetaAdapter.DISPALY_TYPE_LAYOUT_TITLE_FOLDERS) {
return num;
}
if (type == FileMetaAdapter.DISPALY_TYPE_LAYOUT_TAG) {
return 1;
}
if (type == FileMetaAdapter.DISPALY_TYPE_LAYOUT_TITLE_NONE) {
return num;
}
if (type == FileMetaAdapter.DISPLAY_TYPE_DIRECTORY) {
if (num == 1) {
return 1;
} else if (num == 2) {
return 1;
} else if (num == 3) {
return 3;
}
return 2;
}
if (type == FileMetaAdapter.DISPALY_TYPE_SERIES) {
return num;
}
return (type == FileMetaAdapter.DISPALY_TYPE_LAYOUT_TITLE_BOOKS) ? num : 1;
}
});
recyclerView.setLayoutManager(mGridManager);
searchAdapter.setAdapterType(mode == AppState.MODE_COVERS ? FileMetaAdapter.ADAPTER_COVERS : FileMetaAdapter.ADAPTER_GRID);
recyclerView.setAdapter(searchAdapter);
} else if (Arrays.asList(AppState.MODE_AUTHORS, AppState.MODE_SERIES, AppState.MODE_GENRE, AppState.MODE_TAGS).contains(mode)) {
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setAdapter(authorsAdapter);
} else if (mode == AppState.MODE_LIST_COMPACT) {
final int num = Math.max(2, Dips.screenWidthDP() / Dips.dpToPx(300));
GridLayoutManager mGridManager = new GridLayoutManager(getActivity(), num);
mGridManager.setSpanSizeLookup(new SpanSizeLookup() {
@Override
public int getSpanSize(int pos) {
int type = searchAdapter.getItemViewType(pos);
if (type == FileMetaAdapter.DISPALY_TYPE_LAYOUT_TITLE_FOLDERS) {
return num;
}
if (type == FileMetaAdapter.DISPALY_TYPE_LAYOUT_TAG) {
return 1;
}
if (type == FileMetaAdapter.DISPALY_TYPE_LAYOUT_TITLE_NONE) {
return num;
}
return (type == FileMetaAdapter.DISPALY_TYPE_LAYOUT_TITLE_BOOKS) ? num : 1;
}
});
recyclerView.setLayoutManager(mGridManager);
searchAdapter.setAdapterType(FileMetaAdapter.ADAPTER_LIST_COMPACT);
recyclerView.setAdapter(searchAdapter);
}
if (recyclerView instanceof FastScrollRecyclerView) {
((FastScrollRecyclerView) recyclerView).myConfiguration();
}
}
Aggregations