use of com.hippo.annotation.Implemented in project EhViewer by seven332.
the class FavoritesScene method onItemClick.
@Override
@Implemented(AdapterView.OnItemClickListener.class)
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Skip if in search mode
if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
return;
}
if (mUrlBuilder == null || mHelper == null) {
return;
}
// Local favorite position is 0, All favorite position is 1, so position - 2 is OK
int newFavCat = position - 2;
// Check is the same
if (mUrlBuilder.getFavCat() == newFavCat) {
return;
}
// Ensure outOfCustomChoiceMode to avoid error
if (mRecyclerView != null) {
mRecyclerView.isInCustomChoice();
}
exitSearchMode(true);
mUrlBuilder.setKeyword(null);
mUrlBuilder.setFavCat(newFavCat);
updateSearchBar();
mHelper.refresh();
closeDrawer(Gravity.RIGHT);
}
use of com.hippo.annotation.Implemented in project EhViewer by seven332.
the class FavoritesScene method onClickSecondaryFab.
@Override
@Implemented(FabLayout.OnClickFabListener.class)
public void onClickSecondaryFab(FabLayout view, FloatingActionButton fab, int position) {
Context context = getContext2();
if (null == context || null == mRecyclerView || null == mHelper) {
return;
}
if (!mRecyclerView.isInCustomChoice()) {
switch(position) {
case // Go to
0:
if (mHelper.canGoTo()) {
showGoToDialog();
}
break;
case // Refresh
1:
mHelper.refresh();
break;
}
view.setExpanded(false);
return;
}
mModifyGiList.clear();
SparseBooleanArray stateArray = mRecyclerView.getCheckedItemPositions();
for (int i = 0, n = stateArray.size(); i < n; i++) {
if (stateArray.valueAt(i)) {
GalleryInfo gi = mHelper.getDataAtEx(stateArray.keyAt(i));
if (gi != null) {
mModifyGiList.add(gi);
}
}
}
switch(position) {
case 2:
{
// Download
Activity activity = getActivity2();
if (activity != null) {
CommonOperations.startDownload(getActivity2(), mModifyGiList, false);
}
mModifyGiList.clear();
if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
mRecyclerView.outOfCustomChoiceMode();
}
break;
}
case 3:
{
// Delete
DeleteDialogHelper helper = new DeleteDialogHelper();
new AlertDialog.Builder(context).setTitle(R.string.delete_favorites_dialog_title).setMessage(getString(R.string.delete_favorites_dialog_message, mModifyGiList.size())).setPositiveButton(android.R.string.ok, helper).setOnCancelListener(helper).show();
break;
}
case 4:
{
// Move
MoveDialogHelper helper = new MoveDialogHelper();
// First is local favorite, the other 10 is cloud favorite
String[] array = new String[11];
array[0] = getString(R.string.local_favorites);
System.arraycopy(Settings.getFavCat(), 0, array, 1, 10);
new AlertDialog.Builder(context).setTitle(R.string.move_favorites_dialog_title).setItems(array, helper).setOnCancelListener(helper).show();
break;
}
}
}
use of com.hippo.annotation.Implemented in project EhViewer by seven332.
the class FavoritesScene method onItemClick.
@Override
@Implemented(EasyRecyclerView.OnItemClickListener.class)
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
// Skip if in search mode
if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
return true;
}
if (mUrlBuilder == null || mHelper == null) {
return true;
}
// Local favorite position is 0, All favorite position is 1, so position - 2 is OK
int newFavCat = position - 2;
// Check is the same
if (mUrlBuilder.getFavCat() == newFavCat) {
return true;
}
// Ensure outOfCustomChoiceMode to avoid error
if (mRecyclerView != null) {
mRecyclerView.isInCustomChoice();
}
exitSearchMode(true);
mUrlBuilder.setKeyword(null);
mUrlBuilder.setFavCat(newFavCat);
updateSearchBar();
mHelper.refresh();
closeDrawer(Gravity.RIGHT);
} else {
if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
mRecyclerView.toggleItemChecked(position);
} else if (mHelper != null) {
GalleryInfo gi = mHelper.getDataAtEx(position);
if (gi == null) {
return true;
}
Bundle args = new Bundle();
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
View thumb;
if (null != (thumb = view.findViewById(R.id.thumb))) {
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
}
startScene(announcer);
}
}
return true;
}
Aggregations