use of com.hippo.ehviewer.client.data.GalleryComment in project EhViewer by seven332.
the class GalleryCommentsScene method showCommentDialog.
private void showCommentDialog(int position) {
final Context context = getContext2();
if (null == context || null == mComments || position >= mComments.length || position < 0) {
return;
}
final GalleryComment comment = mComments[position];
List<String> menu = new ArrayList<>();
final IntList menuId = new IntList();
Resources resources = context.getResources();
if (0 == comment.id || mApiUid < 0) {
// 0 id is uploader comment, can't vote
// Not sign in, can't vote
menu.add(resources.getString(R.string.copy_comment_text));
menuId.add(R.id.copy);
} else {
menu.add(resources.getString(R.string.copy_comment_text));
menuId.add(R.id.copy);
menu.add(resources.getString(comment.voteUp ? R.string.cancel_vote_up : R.string.vote_up));
menuId.add(R.id.vote_up);
menu.add(resources.getString(comment.voteDown ? R.string.cancel_vote_down : R.string.vote_down));
menuId.add(R.id.vote_down);
}
if (!TextUtils.isEmpty(comment.voteState)) {
menu.add(resources.getString(R.string.check_vote_status));
menuId.add(R.id.check_vote_status);
}
new AlertDialog.Builder(context).setItems(menu.toArray(new String[menu.size()]), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which < 0 || which >= menuId.size()) {
return;
}
int id = menuId.get(which);
switch(id) {
case R.id.copy:
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setPrimaryClip(ClipData.newPlainText(null, comment.comment));
showTip(R.string.copied_to_clipboard, LENGTH_SHORT);
break;
case R.id.vote_up:
voteComment(comment.id, 1);
break;
case R.id.vote_down:
voteComment(comment.id, -1);
break;
case R.id.check_vote_status:
showVoteStatusDialog(context, comment.voteState);
break;
}
}
}).show();
}
Aggregations