use of com.hippo.ehviewer.ui.MainActivity in project EhViewer by seven332.
the class GalleryDetailScene method onClick.
@Override
public void onClick(View v) {
Context context = getContext2();
MainActivity activity = getActivity2();
if (null == context || null == activity) {
return;
}
if (mTip == v) {
if (request()) {
adjustViewVisibility(STATE_REFRESH, true);
}
} else if (mOtherActions == v) {
ensurePopMenu();
if (mPopupMenu != null) {
mPopupMenu.show();
}
} else if (mUploader == v) {
String uploader = getUploader();
if (TextUtils.isEmpty(uploader)) {
return;
}
ListUrlBuilder lub = new ListUrlBuilder();
lub.setMode(ListUrlBuilder.MODE_UPLOADER);
lub.setKeyword(uploader);
GalleryListScene.startScene(this, lub);
} else if (mCategory == v) {
int category = getCategory();
if (category == -1) {
return;
}
ListUrlBuilder lub = new ListUrlBuilder();
lub.setCategory(category);
GalleryListScene.startScene(this, lub);
} else if (mDownload == v) {
GalleryInfo galleryInfo = getGalleryInfo();
if (galleryInfo != null) {
CommonOperations.startDownload(activity, galleryInfo, false);
}
} else if (mRead == v) {
GalleryInfo galleryInfo = null;
if (mGalleryInfo != null) {
galleryInfo = mGalleryInfo;
} else if (mGalleryDetail != null) {
galleryInfo = mGalleryDetail;
}
if (galleryInfo != null) {
Intent intent = new Intent(activity, GalleryActivity.class);
intent.setAction(GalleryActivity.ACTION_EH);
intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, galleryInfo);
startActivity(intent);
}
} else if (mInfo == v) {
Bundle args = new Bundle();
args.putParcelable(GalleryInfoScene.KEY_GALLERY_DETAIL, mGalleryDetail);
startScene(new Announcer(GalleryInfoScene.class).setArgs(args));
} else if (mHeartGroup == v) {
if (mGalleryDetail != null && !mModifingFavorites) {
boolean remove = false;
if (EhDB.containLocalFavorites(mGalleryDetail.gid)) {
EhDB.removeLocalFavorites(mGalleryDetail.gid);
remove = true;
}
if (mGalleryDetail.isFavorited) {
mModifingFavorites = true;
CommonOperations.removeFromFavorites(activity, mGalleryDetail, new ModifyFavoritesListener(context, activity.getStageId(), getTag(), true));
remove = true;
}
if (!remove) {
mModifingFavorites = true;
CommonOperations.addToFavorites(activity, mGalleryDetail, new ModifyFavoritesListener(context, activity.getStageId(), getTag(), false));
}
// Update UI
updateFavoriteDrawable();
}
} else if (mShare == v) {
String url = getGalleryDetailUrl(false);
if (url != null) {
AppHelper.share(activity, url);
}
} else if (mTorrent == v) {
if (mGalleryDetail != null) {
TorrentListDialogHelper helper = new TorrentListDialogHelper();
Dialog dialog = new AlertDialog.Builder(context).setTitle(R.string.torrents).setView(R.layout.dialog_torrent_list).setOnDismissListener(helper).show();
helper.setDialog(dialog, mGalleryDetail.torrentUrl);
}
} else if (mArchive == v) {
if (mGalleryDetail == null) {
return;
}
if (mGalleryDetail.apiUid < 0) {
showTip(R.string.sign_in_first, LENGTH_SHORT);
return;
}
ArchiveListDialogHelper helper = new ArchiveListDialogHelper();
Dialog dialog = new AlertDialog.Builder(context).setTitle(R.string.dialog_archive_title).setView(R.layout.dialog_archive_list).setOnDismissListener(helper).show();
helper.setDialog(dialog, mGalleryDetail.archiveUrl);
} else if (mRate == v) {
if (mGalleryDetail == null) {
return;
}
if (mGalleryDetail.apiUid < 0) {
showTip(R.string.sign_in_first, LENGTH_SHORT);
return;
}
RateDialogHelper helper = new RateDialogHelper();
Dialog dialog = new AlertDialog.Builder(context).setTitle(R.string.rate).setView(R.layout.dialog_rate).setNegativeButton(android.R.string.cancel, null).setPositiveButton(android.R.string.ok, helper).show();
helper.setDialog(dialog, mGalleryDetail.rating);
} else if (mSimilar == v) {
showSimilarGalleryList();
} else if (mSearchCover == v) {
showCoverGalleryList();
} else if (mComments == v) {
if (mGalleryDetail == null) {
return;
}
Bundle args = new Bundle();
args.putLong(GalleryCommentsScene.KEY_API_UID, mGalleryDetail.apiUid);
args.putString(GalleryCommentsScene.KEY_API_KEY, mGalleryDetail.apiKey);
args.putLong(GalleryCommentsScene.KEY_GID, mGalleryDetail.gid);
args.putString(GalleryCommentsScene.KEY_TOKEN, mGalleryDetail.token);
args.putParcelableArray(GalleryCommentsScene.KEY_COMMENTS, mGalleryDetail.comments);
startScene(new Announcer(GalleryCommentsScene.class).setArgs(args).setRequestCode(this, REQUEST_CODE_COMMENT_GALLERY));
} else if (mPreviews == v) {
if (null != mGalleryDetail) {
Bundle args = new Bundle();
args.putParcelable(GalleryPreviewsScene.KEY_GALLERY_INFO, mGalleryDetail);
startScene(new Announcer(GalleryPreviewsScene.class).setArgs(args));
}
} else {
Object o = v.getTag(R.id.tag);
if (o instanceof String) {
String tag = (String) o;
ListUrlBuilder lub = new ListUrlBuilder();
lub.setMode(ListUrlBuilder.MODE_TAG);
lub.setKeyword(tag);
GalleryListScene.startScene(this, lub);
return;
}
GalleryInfo galleryInfo = getGalleryInfo();
o = v.getTag(R.id.index);
if (null != galleryInfo && o instanceof Integer) {
int index = (Integer) o;
Intent intent = new Intent(context, GalleryActivity.class);
intent.setAction(GalleryActivity.ACTION_EH);
intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, galleryInfo);
intent.putExtra(GalleryActivity.KEY_PAGE, index);
startActivity(intent);
return;
}
}
}
use of com.hippo.ehviewer.ui.MainActivity in project EhViewer by seven332.
the class GalleryDetailScene method request.
private boolean request() {
Context context = getContext2();
MainActivity activity = getActivity2();
String url = getGalleryDetailUrl(false);
if (null == context || null == activity || null == url) {
return false;
}
EhClient.Callback callback = new GetGalleryDetailListener(context, activity.getStageId(), getTag());
mRequestId = ((EhApplication) context.getApplicationContext()).putGlobalStuff(callback);
EhRequest request = new EhRequest().setMethod(EhClient.METHOD_GET_GALLERY_DETAIL).setArgs(url).setCallback(callback);
EhApplication.getEhClient(context).execute(request);
return true;
}
use of com.hippo.ehviewer.ui.MainActivity in project EhViewer by seven332.
the class GalleryListScene method onItemLongClick.
@Override
public boolean onItemLongClick(EasyRecyclerView parent, View view, int position, long id) {
final Context context = getContext2();
final MainActivity activity = getActivity2();
if (null == context || null == activity || null == mHelper) {
return false;
}
final GalleryInfo gi = mHelper.getDataAt(position);
new AlertDialog.Builder(context).setTitle(EhUtils.getSuitableTitle(gi)).setItems(R.array.gallery_list_menu_entries, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case // Download
0:
CommonOperations.startDownload(activity, gi, false);
break;
case // Favorites
1:
CommonOperations.addToFavorites(activity, gi, new addToFavoriteListener(context, activity.getStageId(), getTag()));
break;
}
}
}).show();
return true;
}
use of com.hippo.ehviewer.ui.MainActivity in project EhViewer by seven332.
the class ProgressScene method doJobs.
private boolean doJobs() {
Context context = getContext2();
MainActivity activity = getActivity2();
if (null == context || null == activity) {
return false;
}
if (ACTION_GALLERY_TOKEN.equals(mAction)) {
if (mGid == -1 || mPToken == null || mPage == -1) {
return false;
}
EhRequest request = new EhRequest().setMethod(EhClient.METHOD_GET_GALLERY_TOKEN).setArgs(mGid, mPToken, mPage).setCallback(new GetGalleryTokenListener(context, activity.getStageId(), getTag()));
EhApplication.getEhClient(context).execute(request);
return true;
}
return false;
}
use of com.hippo.ehviewer.ui.MainActivity in project EhViewer by seven332.
the class SelectSiteScene method onClick.
@Override
public void onClick(View v) {
MainActivity activity = getActivity2();
if (null == activity || null == mRadioGroup) {
return;
}
if (v == mOk) {
int id = mRadioGroup.getCheckedRadioButtonId();
switch(id) {
case R.id.site_e:
Settings.putSelectSite(false);
Settings.putGallerySite(EhUrl.SITE_E);
startSceneForCheckStep(CHECK_STEP_SELECT_SITE, getArguments());
finish();
break;
case R.id.site_ex:
Settings.putSelectSite(false);
Settings.putGallerySite(EhUrl.SITE_EX);
startSceneForCheckStep(CHECK_STEP_SELECT_SITE, getArguments());
finish();
break;
default:
Toast.makeText(activity, R.string.no_select, Toast.LENGTH_SHORT).show();
break;
}
}
}
Aggregations