use of me.ccrama.redditslide.Activities.MultiredditOverview 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.MultiredditOverview 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