use of me.ccrama.redditslide.Activities.Profile in project Slide by ccrama.
the class CommentAdapterHelper method showModBottomSheet.
public static void showModBottomSheet(final CommentAdapter adapter, final Context mContext, final CommentNode baseNode, final Comment comment, final CommentViewHolder holder, final Map<String, Integer> reports, final Map<String, String> reports2) {
int[] attrs = new int[] { R.attr.tintColor };
TypedArray ta = mContext.obtainStyledAttributes(attrs);
// Initialize drawables
int color = ta.getColor(0, Color.WHITE);
Drawable profile = mContext.getResources().getDrawable(R.drawable.profile);
final Drawable report = mContext.getResources().getDrawable(R.drawable.report);
final Drawable approve = mContext.getResources().getDrawable(R.drawable.support);
final Drawable nsfw = mContext.getResources().getDrawable(R.drawable.hide);
final Drawable pin = mContext.getResources().getDrawable(R.drawable.sub);
final Drawable distinguish = mContext.getResources().getDrawable(R.drawable.iconstarfilled);
final Drawable remove = mContext.getResources().getDrawable(R.drawable.close);
final Drawable ban = mContext.getResources().getDrawable(R.drawable.ban);
final Drawable spam = mContext.getResources().getDrawable(R.drawable.spam);
// Tint drawables
profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
report.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
approve.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
nsfw.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
distinguish.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
remove.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
pin.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
ban.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
spam.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
ta.recycle();
// Bottom sheet builder
BottomSheet.Builder b = new BottomSheet.Builder((Activity) mContext).title(Html.fromHtml(comment.getBody()));
int reportCount = reports.size() + reports2.size();
if (reportCount == 0) {
b.sheet(0, report, mContext.getString(R.string.mod_no_reports));
} else {
b.sheet(0, report, mContext.getResources().getQuantityString(R.plurals.mod_btn_reports, reportCount, reportCount));
}
b.sheet(1, approve, mContext.getString(R.string.mod_btn_approve));
// b.sheet(2, spam, mContext.getString(R.string.mod_btn_spam)) todo this
final boolean stickied = comment.getDataNode().has("stickied") && comment.getDataNode().get("stickied").asBoolean();
if (baseNode.isTopLevel()) {
if (!stickied) {
b.sheet(4, pin, mContext.getString(R.string.mod_sticky));
} else {
b.sheet(4, pin, mContext.getString(R.string.mod_unsticky));
}
}
final boolean distinguished = !comment.getDataNode().get("distinguished").isNull();
if (comment.getAuthor().equalsIgnoreCase(Authentication.name)) {
if (!distinguished) {
b.sheet(9, distinguish, mContext.getString(R.string.mod_distinguish));
} else {
b.sheet(9, distinguish, mContext.getString(R.string.mod_undistinguish));
}
}
b.sheet(23, ban, mContext.getString(R.string.mod_ban_user));
b.sheet(6, remove, mContext.getString(R.string.btn_remove)).sheet(10, spam, "Mark as spam").sheet(8, profile, mContext.getString(R.string.mod_btn_author)).listener(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case 0:
viewReports(mContext, reports, reports2);
break;
case 1:
doApproval(mContext, holder, comment, adapter);
break;
case 4:
if (stickied) {
unStickyComment(mContext, holder, comment);
} else {
stickyComment(mContext, holder, comment);
}
break;
case 9:
if (distinguished) {
unDistinguishComment(mContext, holder, comment);
} else {
distinguishComment(mContext, holder, comment);
}
break;
case 6:
removeComment(mContext, holder, comment, adapter, false);
break;
case 10:
removeComment(mContext, holder, comment, adapter, true);
break;
case 8:
Intent i = new Intent(mContext, Profile.class);
i.putExtra(Profile.EXTRA_PROFILE, comment.getAuthor());
mContext.startActivity(i);
break;
case 23:
showBan(mContext, adapter.listView, comment, "", "", "", "");
break;
}
}
});
b.show();
}
use of me.ccrama.redditslide.Activities.Profile in project Slide by ccrama.
the class PopulateNewsViewHolder method addClickFunctions.
private static void addClickFunctions(final View base, final ContentType.Type type, final Activity contextActivity, final Submission submission, final NewsViewHolder holder, final boolean full) {
base.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
if (NetworkUtil.isConnected(contextActivity) || (!NetworkUtil.isConnected(contextActivity) && ContentType.fullImage(type))) {
if (SettingValues.storeHistory && !full) {
if (!submission.isNsfw() || SettingValues.storeNSFWHistory) {
HasSeen.addSeen(submission.getFullName());
if (contextActivity instanceof MainActivity || contextActivity instanceof MultiredditOverview || contextActivity instanceof SubredditView || contextActivity instanceof Search || contextActivity instanceof Profile) {
holder.title.setAlpha(0.54f);
}
}
}
if (!(contextActivity instanceof PeekViewActivity) || !((PeekViewActivity) contextActivity).isPeeking() || (base instanceof HeaderImageLinkView && ((HeaderImageLinkView) base).popped)) {
if (!PostMatch.openExternal(submission.getUrl()) || type == ContentType.Type.VIDEO) {
switch(type) {
case VID_ME:
case STREAMABLE:
if (SettingValues.video) {
Intent myIntent = new Intent(contextActivity, MediaView.class);
myIntent.putExtra(MediaView.SUBREDDIT, submission.getSubredditName());
myIntent.putExtra(MediaView.EXTRA_URL, submission.getUrl());
contextActivity.startActivity(myIntent);
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case IMGUR:
openImage(type, contextActivity, submission, holder.leadImage, holder.getAdapterPosition());
break;
case EMBEDDED:
if (SettingValues.video) {
String data = Html.fromHtml(submission.getDataNode().get("media_embed").get("content").asText()).toString();
{
Intent i = new Intent(contextActivity, FullscreenVideo.class);
i.putExtra(FullscreenVideo.EXTRA_HTML, data);
contextActivity.startActivity(i);
}
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case REDDIT:
openRedditContent(submission.getUrl(), contextActivity);
break;
case LINK:
LinkUtil.openUrl(submission.getUrl(), Palette.getColor(submission.getSubredditName()), contextActivity, holder.getAdapterPosition(), submission);
break;
case SELF:
if (holder != null) {
OnSingleClickListener.override = true;
holder.itemView.performClick();
}
break;
case ALBUM:
if (SettingValues.album) {
Intent i;
if (SettingValues.albumSwipe) {
i = new Intent(contextActivity, AlbumPager.class);
i.putExtra(AlbumPager.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
} else {
i = new Intent(contextActivity, Album.class);
i.putExtra(Album.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
}
addAdaptorPosition(i, submission, holder.getAdapterPosition());
contextActivity.startActivity(i);
contextActivity.overridePendingTransition(R.anim.slideright, R.anim.fade_out);
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case TUMBLR:
if (SettingValues.album) {
Intent i;
if (SettingValues.albumSwipe) {
i = new Intent(contextActivity, TumblrPager.class);
i.putExtra(TumblrPager.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
} else {
i = new Intent(contextActivity, Tumblr.class);
i.putExtra(Tumblr.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
}
addAdaptorPosition(i, submission, holder.getAdapterPosition());
contextActivity.startActivity(i);
contextActivity.overridePendingTransition(R.anim.slideright, R.anim.fade_out);
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case DEVIANTART:
case XKCD:
case IMAGE:
openImage(type, contextActivity, submission, holder.leadImage, holder.getAdapterPosition());
break;
case GIF:
openGif(contextActivity, submission, holder.getAdapterPosition());
break;
case NONE:
if (holder != null) {
holder.itemView.performClick();
}
break;
case VIDEO:
if (Reddit.videoPlugin) {
try {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setClassName("ccrama.me.slideyoutubeplugin", "ccrama.me.slideyoutubeplugin.YouTubeView");
sharingIntent.putExtra("url", submission.getUrl());
contextActivity.startActivity(sharingIntent);
} catch (Exception e) {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
}
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
}
} else {
if (!(contextActivity instanceof PeekViewActivity) || !((PeekViewActivity) contextActivity).isPeeking()) {
Snackbar s = Snackbar.make(holder.itemView, R.string.go_online_view_content, Snackbar.LENGTH_SHORT);
View view = s.getView();
TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
tv.setTextColor(Color.WHITE);
s.show();
}
}
}
});
}
use of me.ccrama.redditslide.Activities.Profile in project Slide by ccrama.
the class PopulateSubmissionViewHolder method showModBottomSheet.
public <T extends Contribution> void showModBottomSheet(final Activity mContext, final Submission submission, final List<T> posts, final SubmissionViewHolder holder, final RecyclerView recyclerview, final Map<String, Integer> reports, final Map<String, String> reports2) {
final Resources res = mContext.getResources();
int[] attrs = new int[] { R.attr.tintColor };
TypedArray ta = mContext.obtainStyledAttributes(attrs);
int color = ta.getColor(0, Color.WHITE);
Drawable profile = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.profile, null);
final Drawable report = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.report, null);
final Drawable approve = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.support, null);
final Drawable nsfw = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.hide, null);
final Drawable spoiler = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.spoil, null);
final Drawable pin = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.sub, null);
final Drawable lock = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.lock, null);
final Drawable flair = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.ic_format_quote_white_48dp, null);
final Drawable remove = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.close, null);
final Drawable remove_reason = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.reportreason, null);
final Drawable ban = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.ban, null);
final Drawable spam = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.spam, null);
final Drawable distinguish = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.iconstarfilled, null);
profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
report.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
approve.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
spam.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
nsfw.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
pin.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
flair.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
remove.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
spoiler.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
remove_reason.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
ban.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
spam.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
distinguish.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
lock.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
ta.recycle();
BottomSheet.Builder b = new BottomSheet.Builder(mContext).title(Html.fromHtml(submission.getTitle()));
int reportCount = reports.size() + reports2.size();
b.sheet(0, report, res.getQuantityString(R.plurals.mod_btn_reports, reportCount, reportCount));
boolean approved = false;
String whoApproved = "";
b.sheet(1, approve, res.getString(R.string.mod_btn_approve));
b.sheet(6, remove, mContext.getString(R.string.mod_btn_remove)).sheet(7, remove_reason, res.getString(R.string.mod_btn_remove_reason)).sheet(30, spam, "Mark as spam");
// b.sheet(2, spam, mContext.getString(R.string.mod_btn_spam)) todo this
b.sheet(20, flair, res.getString(R.string.mod_btn_submission_flair));
final boolean isNsfw = submission.isNsfw();
if (isNsfw) {
b.sheet(3, nsfw, res.getString(R.string.mod_btn_unmark_nsfw));
} else {
b.sheet(3, nsfw, res.getString(R.string.mod_btn_mark_nsfw));
}
final boolean isSpoiler = submission.getDataNode().get("spoiler").asBoolean();
if (isSpoiler) {
b.sheet(12, nsfw, "Unmark as spoiler");
} else {
b.sheet(12, nsfw, "Mark as spoiler");
}
final boolean locked = submission.isLocked();
if (locked) {
b.sheet(9, lock, "Unlock thread");
} else {
b.sheet(9, lock, "Lock thread");
}
final boolean stickied = submission.isStickied();
if (stickied) {
b.sheet(4, pin, res.getString(R.string.mod_btn_unpin));
} else {
b.sheet(4, pin, res.getString(R.string.mod_btn_pin));
}
final boolean distinguished = submission.getDistinguishedStatus() == DistinguishedStatus.MODERATOR || submission.getDistinguishedStatus() == DistinguishedStatus.ADMIN;
if (submission.getAuthor().equalsIgnoreCase(Authentication.name)) {
if (distinguished) {
b.sheet(5, distinguish, "Undistingiush");
} else {
b.sheet(5, distinguish, "Distinguish");
}
}
final String finalWhoApproved = whoApproved;
final boolean finalApproved = approved;
b.sheet(8, profile, res.getString(R.string.mod_btn_author));
b.sheet(23, ban, mContext.getString(R.string.mod_ban_user));
b.listener(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case 0:
new AsyncTask<Void, Void, ArrayList<String>>() {
@Override
protected ArrayList<String> doInBackground(Void... params) {
ArrayList<String> finalReports = new ArrayList<>();
for (Map.Entry<String, Integer> entry : reports.entrySet()) {
finalReports.add(entry.getValue() + "× " + entry.getKey());
}
for (Map.Entry<String, String> entry : reports2.entrySet()) {
finalReports.add(entry.getKey() + ": " + entry.getValue());
}
if (finalReports.isEmpty()) {
finalReports.add(mContext.getString(R.string.mod_no_reports));
}
return finalReports;
}
@Override
public void onPostExecute(ArrayList<String> data) {
new AlertDialogWrapper.Builder(mContext).setTitle(R.string.mod_reports).setItems(data.toArray(new CharSequence[data.size()]), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
break;
case 1:
if (finalApproved) {
Intent i = new Intent(mContext, Profile.class);
i.putExtra(Profile.EXTRA_PROFILE, finalWhoApproved);
mContext.startActivity(i);
} else {
approveSubmission(mContext, posts, submission, recyclerview, holder);
}
break;
case 2:
// todo this
break;
case 3:
if (isNsfw) {
unNsfwSubmission(mContext, submission, holder);
} else {
setPostNsfw(mContext, submission, holder);
}
break;
case 12:
if (isSpoiler) {
unSpoiler(mContext, submission, holder);
} else {
setSpoiler(mContext, submission, holder);
}
break;
case 9:
if (locked) {
unLockSubmission(mContext, submission, holder);
} else {
lockSubmission(mContext, submission, holder);
}
break;
case 4:
if (stickied) {
unStickySubmission(mContext, submission, holder);
} else {
stickySubmission(mContext, submission, holder);
}
break;
case 5:
if (distinguished) {
unDistinguishSubmission(mContext, submission, holder);
} else {
distinguishSubmission(mContext, submission, holder);
}
break;
case 6:
removeSubmission(mContext, submission, posts, recyclerview, holder, false);
break;
case 7:
doRemoveSubmissionReason(mContext, submission, posts, recyclerview, holder);
break;
case 30:
removeSubmission(mContext, submission, posts, recyclerview, holder, true);
break;
case 8:
Intent i = new Intent(mContext, Profile.class);
i.putExtra(Profile.EXTRA_PROFILE, submission.getAuthor());
mContext.startActivity(i);
break;
case 20:
doSetFlair(mContext, submission, holder);
break;
case 23:
// ban a user
showBan(mContext, holder.itemView, submission, "", "", "", "");
break;
}
}
});
b.show();
}
use of me.ccrama.redditslide.Activities.Profile in project Slide by ccrama.
the class ModeratorAdapter method showModBottomSheet.
public static void showModBottomSheet(final Context mContext, final Comment comment, final ProfileCommentViewHolder holder, final Map<String, Integer> reports, final Map<String, String> reports2) {
int[] attrs = new int[] { R.attr.tintColor };
TypedArray ta = mContext.obtainStyledAttributes(attrs);
// Initialize drawables
int color = ta.getColor(0, Color.WHITE);
Drawable profile = mContext.getResources().getDrawable(R.drawable.profile);
final Drawable report = mContext.getResources().getDrawable(R.drawable.report);
final Drawable approve = mContext.getResources().getDrawable(R.drawable.support);
final Drawable nsfw = mContext.getResources().getDrawable(R.drawable.hide);
final Drawable pin = mContext.getResources().getDrawable(R.drawable.sub);
final Drawable distinguish = mContext.getResources().getDrawable(R.drawable.iconstarfilled);
final Drawable remove = mContext.getResources().getDrawable(R.drawable.close);
final Drawable ban = mContext.getResources().getDrawable(R.drawable.ban);
final Drawable spam = mContext.getResources().getDrawable(R.drawable.spam);
// Tint drawables
profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
report.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
approve.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
nsfw.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
distinguish.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
remove.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
pin.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
ban.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
spam.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
ta.recycle();
// Bottom sheet builder
BottomSheet.Builder b = new BottomSheet.Builder((Activity) mContext).title(Html.fromHtml(comment.getBody()));
int reportCount = reports.size() + reports2.size();
if (reportCount == 0) {
b.sheet(0, report, mContext.getString(R.string.mod_no_reports));
} else {
b.sheet(0, report, mContext.getResources().getQuantityString(R.plurals.mod_btn_reports, reportCount, reportCount));
}
b.sheet(1, approve, mContext.getString(R.string.mod_btn_approve));
// b.sheet(2, spam, mContext.getString(R.string.mod_btn_spam)) todo this
final boolean distinguished = !comment.getDataNode().get("distinguished").isNull();
if (comment.getAuthor().equalsIgnoreCase(Authentication.name)) {
if (!distinguished) {
b.sheet(9, distinguish, mContext.getString(R.string.mod_distinguish));
} else {
b.sheet(9, distinguish, mContext.getString(R.string.mod_undistinguish));
}
}
b.sheet(23, ban, mContext.getString(R.string.mod_ban_user));
b.sheet(6, remove, mContext.getString(R.string.btn_remove)).sheet(10, spam, "Mark as spam").sheet(8, profile, mContext.getString(R.string.mod_btn_author)).listener(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case 0:
CommentAdapterHelper.viewReports(mContext, reports, reports2);
break;
case 1:
doApproval(mContext, holder, comment);
break;
case 9:
if (distinguished) {
unDistinguishComment(mContext, holder, comment);
} else {
distinguishComment(mContext, holder, comment);
}
break;
case 6:
removeComment(mContext, holder, comment, false);
break;
case 10:
removeComment(mContext, holder, comment, true);
break;
case 8:
Intent i = new Intent(mContext, Profile.class);
i.putExtra(Profile.EXTRA_PROFILE, comment.getAuthor());
mContext.startActivity(i);
break;
case 23:
CommentAdapterHelper.showBan(mContext, holder.itemView, comment, "", "", "", "");
break;
}
}
});
b.show();
}
use of me.ccrama.redditslide.Activities.Profile in project Slide by ccrama.
the class PopulateSubmissionViewHolder method addClickFunctions.
private static void addClickFunctions(final View base, final ContentType.Type type, final Activity contextActivity, final Submission submission, final SubmissionViewHolder holder, final boolean full) {
base.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
if (NetworkUtil.isConnected(contextActivity) || (!NetworkUtil.isConnected(contextActivity) && ContentType.fullImage(type))) {
if (SettingValues.storeHistory && !full) {
if (!submission.isNsfw() || SettingValues.storeNSFWHistory) {
HasSeen.addSeen(submission.getFullName());
if (contextActivity instanceof MainActivity || contextActivity instanceof MultiredditOverview || contextActivity instanceof SubredditView || contextActivity instanceof Search || contextActivity instanceof Profile) {
holder.title.setAlpha(0.54f);
holder.body.setAlpha(0.54f);
}
}
}
if (!(contextActivity instanceof PeekViewActivity) || !((PeekViewActivity) contextActivity).isPeeking() || (base instanceof HeaderImageLinkView && ((HeaderImageLinkView) base).popped)) {
if (!PostMatch.openExternal(submission.getUrl()) || type == ContentType.Type.VIDEO) {
switch(type) {
case VID_ME:
case STREAMABLE:
if (SettingValues.video) {
Intent myIntent = new Intent(contextActivity, MediaView.class);
myIntent.putExtra(MediaView.SUBREDDIT, submission.getSubredditName());
myIntent.putExtra(MediaView.EXTRA_URL, submission.getUrl());
addAdaptorPosition(myIntent, submission, holder.getAdapterPosition());
contextActivity.startActivity(myIntent);
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case IMGUR:
openImage(type, contextActivity, submission, holder.leadImage, holder.getAdapterPosition());
break;
case EMBEDDED:
if (SettingValues.video) {
String data = Html.fromHtml(submission.getDataNode().get("media_embed").get("content").asText()).toString();
{
Intent i = new Intent(contextActivity, FullscreenVideo.class);
i.putExtra(FullscreenVideo.EXTRA_HTML, data);
contextActivity.startActivity(i);
}
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case REDDIT:
openRedditContent(submission.getUrl(), contextActivity);
break;
case LINK:
LinkUtil.openUrl(submission.getUrl(), Palette.getColor(submission.getSubredditName()), contextActivity, holder.getAdapterPosition(), submission);
break;
case SELF:
if (holder != null) {
OnSingleClickListener.override = true;
holder.itemView.performClick();
}
break;
case ALBUM:
if (SettingValues.album) {
Intent i;
if (SettingValues.albumSwipe) {
i = new Intent(contextActivity, AlbumPager.class);
i.putExtra(AlbumPager.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
} else {
i = new Intent(contextActivity, Album.class);
i.putExtra(Album.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
}
addAdaptorPosition(i, submission, holder.getAdapterPosition());
contextActivity.startActivity(i);
contextActivity.overridePendingTransition(R.anim.slideright, R.anim.fade_out);
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case TUMBLR:
if (SettingValues.album) {
Intent i;
if (SettingValues.albumSwipe) {
i = new Intent(contextActivity, TumblrPager.class);
i.putExtra(TumblrPager.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
} else {
i = new Intent(contextActivity, Tumblr.class);
i.putExtra(Tumblr.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
}
addAdaptorPosition(i, submission, holder.getAdapterPosition());
contextActivity.startActivity(i);
contextActivity.overridePendingTransition(R.anim.slideright, R.anim.fade_out);
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case DEVIANTART:
case XKCD:
case IMAGE:
openImage(type, contextActivity, submission, holder.leadImage, holder.getAdapterPosition());
break;
case VREDDIT_REDIRECT:
case GIF:
case VREDDIT_DIRECT:
openGif(contextActivity, submission, holder.getAdapterPosition());
break;
case NONE:
if (holder != null) {
holder.itemView.performClick();
}
break;
case VIDEO:
if (Reddit.videoPlugin) {
try {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setClassName("ccrama.me.slideyoutubeplugin", "ccrama.me.slideyoutubeplugin.YouTubeView");
sharingIntent.putExtra("url", submission.getUrl());
contextActivity.startActivity(sharingIntent);
} catch (Exception e) {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
}
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
}
} else {
if (!(contextActivity instanceof PeekViewActivity) || !((PeekViewActivity) contextActivity).isPeeking()) {
Snackbar s = Snackbar.make(holder.itemView, R.string.go_online_view_content, Snackbar.LENGTH_SHORT);
View view = s.getView();
TextView tv = view.findViewById(android.support.design.R.id.snackbar_text);
tv.setTextColor(Color.WHITE);
s.show();
}
}
}
});
}
Aggregations