Search in sources :

Example 1 with PeekViewActivity

use of me.ccrama.redditslide.ForceTouch.PeekViewActivity 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();
                }
            }
        }
    });
}
Also used : MultiredditOverview(me.ccrama.redditslide.Activities.MultiredditOverview) OnSingleClickListener(me.ccrama.redditslide.util.OnSingleClickListener) SubredditView(me.ccrama.redditslide.Activities.SubredditView) Intent(android.content.Intent) MainActivity(me.ccrama.redditslide.Activities.MainActivity) MediaView(me.ccrama.redditslide.Activities.MediaView) ImageView(android.widget.ImageView) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) View(android.view.View) TextView(android.widget.TextView) SubredditView(me.ccrama.redditslide.Activities.SubredditView) RecyclerView(android.support.v7.widget.RecyclerView) CreateCardView(me.ccrama.redditslide.Views.CreateCardView) Profile(me.ccrama.redditslide.Activities.Profile) MediaView(me.ccrama.redditslide.Activities.MediaView) ApiException(net.dean.jraw.ApiException) Search(me.ccrama.redditslide.Activities.Search) TextView(android.widget.TextView) PeekViewActivity(me.ccrama.redditslide.ForceTouch.PeekViewActivity) Snackbar(android.support.design.widget.Snackbar)

Example 2 with PeekViewActivity

use of me.ccrama.redditslide.ForceTouch.PeekViewActivity in project Slide by ccrama.

the class HeaderImageLinkView method onLinkLongClick.

public void onLinkLongClick(final String url, MotionEvent event) {
    popped = false;
    if (url == null) {
        return;
    }
    performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    Activity activity = null;
    final Context context = getContext();
    if (context instanceof Activity) {
        activity = (Activity) context;
    } else if (context instanceof android.support.v7.view.ContextThemeWrapper) {
        activity = (Activity) ((android.support.v7.view.ContextThemeWrapper) context).getBaseContext();
    } else if (context instanceof ContextWrapper) {
        Context context1 = ((ContextWrapper) context).getBaseContext();
        if (context1 instanceof Activity) {
            activity = (Activity) context1;
        } else if (context1 instanceof ContextWrapper) {
            Context context2 = ((ContextWrapper) context1).getBaseContext();
            if (context2 instanceof Activity) {
                activity = (Activity) context2;
            } else if (context2 instanceof ContextWrapper) {
                activity = (Activity) ((android.support.v7.view.ContextThemeWrapper) context2).getBaseContext();
            }
        }
    } else {
        throw new RuntimeException("Could not find activity from context:" + context);
    }
    if (activity != null && !activity.isFinishing()) {
        if (SettingValues.peek) {
            Peek.into(R.layout.peek_view_submission, new SimpleOnPeek() {

                @Override
                public void onInflated(final PeekView peekView, final View rootView) {
                    // do stuff
                    TextView text = ((TextView) rootView.findViewById(R.id.title));
                    text.setText(url);
                    text.setTextColor(Color.WHITE);
                    ((PeekMediaView) rootView.findViewById(R.id.peek)).setUrl(url);
                    peekView.addButton((R.id.share), new OnButtonUp() {

                        @Override
                        public void onButtonUp() {
                            Reddit.defaultShareText("", url, rootView.getContext());
                        }
                    });
                    peekView.addButton((R.id.upvoteb), new OnButtonUp() {

                        @Override
                        public void onButtonUp() {
                            ((View) getParent()).findViewById(R.id.upvote).callOnClick();
                        }
                    });
                    peekView.setOnRemoveListener(new OnRemove() {

                        @Override
                        public void onRemove() {
                            ((PeekMediaView) rootView.findViewById(R.id.peek)).doClose();
                        }
                    });
                    peekView.addButton((R.id.comments), new OnButtonUp() {

                        @Override
                        public void onButtonUp() {
                            ((View) getParent().getParent()).callOnClick();
                        }
                    });
                    peekView.setOnPop(new OnPop() {

                        @Override
                        public void onPop() {
                            popped = true;
                            callOnClick();
                        }
                    });
                }
            }).with(new PeekViewOptions().setFullScreenPeek(true)).show((PeekViewActivity) activity, event);
        } else {
            BottomSheet.Builder b = new BottomSheet.Builder(activity).title(url).grid();
            int[] attrs = new int[] { R.attr.tintColor };
            TypedArray ta = getContext().obtainStyledAttributes(attrs);
            int color = ta.getColor(0, Color.WHITE);
            Drawable open = getResources().getDrawable(R.drawable.ic_open_in_browser);
            open.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
            Drawable share = getResources().getDrawable(R.drawable.ic_share);
            share.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
            Drawable copy = getResources().getDrawable(R.drawable.ic_content_copy);
            copy.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
            ta.recycle();
            b.sheet(R.id.open_link, open, getResources().getString(R.string.submission_link_extern));
            b.sheet(R.id.share_link, share, getResources().getString(R.string.share_link));
            b.sheet(R.id.copy_link, copy, getResources().getString(R.string.submission_link_copy));
            final Activity finalActivity = activity;
            b.listener(new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch(which) {
                        case R.id.open_link:
                            LinkUtil.openExternally(url, context);
                            break;
                        case R.id.share_link:
                            Reddit.defaultShareText("", url, finalActivity);
                            break;
                        case R.id.copy_link:
                            LinkUtil.copyUrl(url, finalActivity);
                            break;
                    }
                }
            }).show();
        }
    }
}
Also used : DialogInterface(android.content.DialogInterface) PeekViewActivity(me.ccrama.redditslide.ForceTouch.PeekViewActivity) Activity(android.app.Activity) PeekMediaView(me.ccrama.redditslide.Views.PeekMediaView) TypedArray(android.content.res.TypedArray) PeekView(me.ccrama.redditslide.ForceTouch.PeekView) TransparentTagTextView(me.ccrama.redditslide.Views.TransparentTagTextView) TextView(android.widget.TextView) OnPop(me.ccrama.redditslide.ForceTouch.callback.OnPop) PeekViewOptions(me.ccrama.redditslide.ForceTouch.builder.PeekViewOptions) Context(android.content.Context) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) PeekView(me.ccrama.redditslide.ForceTouch.PeekView) View(android.view.View) TransparentTagTextView(me.ccrama.redditslide.Views.TransparentTagTextView) TextView(android.widget.TextView) PeekMediaView(me.ccrama.redditslide.Views.PeekMediaView) OnButtonUp(me.ccrama.redditslide.ForceTouch.callback.OnButtonUp) OnRemove(me.ccrama.redditslide.ForceTouch.callback.OnRemove) BottomSheet(com.cocosw.bottomsheet.BottomSheet) ContextWrapper(android.content.ContextWrapper) SimpleOnPeek(me.ccrama.redditslide.ForceTouch.callback.SimpleOnPeek)

Example 3 with PeekViewActivity

use of me.ccrama.redditslide.ForceTouch.PeekViewActivity 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();
                }
            }
        }
    });
}
Also used : MultiredditOverview(me.ccrama.redditslide.Activities.MultiredditOverview) OnSingleClickListener(me.ccrama.redditslide.util.OnSingleClickListener) SubredditView(me.ccrama.redditslide.Activities.SubredditView) Intent(android.content.Intent) MainActivity(me.ccrama.redditslide.Activities.MainActivity) MediaView(me.ccrama.redditslide.Activities.MediaView) ImageView(android.widget.ImageView) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) RecyclerView(android.support.v7.widget.RecyclerView) CreateCardView(me.ccrama.redditslide.Views.CreateCardView) View(android.view.View) TextView(android.widget.TextView) SubredditView(me.ccrama.redditslide.Activities.SubredditView) Profile(me.ccrama.redditslide.Activities.Profile) MediaView(me.ccrama.redditslide.Activities.MediaView) InvalidScopeException(net.dean.jraw.http.oauth.InvalidScopeException) ApiException(net.dean.jraw.ApiException) Search(me.ccrama.redditslide.Activities.Search) TextView(android.widget.TextView) PeekViewActivity(me.ccrama.redditslide.ForceTouch.PeekViewActivity) Snackbar(android.support.design.widget.Snackbar)

Example 4 with PeekViewActivity

use of me.ccrama.redditslide.ForceTouch.PeekViewActivity in project Slide by ccrama.

the class SpoilerRobotoTextView method onLinkLongClick.

@Override
public void onLinkLongClick(final String baseUrl, MotionEvent event) {
    if (baseUrl == null) {
        return;
    }
    final String url = StringEscapeUtils.unescapeHtml4(baseUrl);
    performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    Activity activity = null;
    final Context context = getContext();
    if (context instanceof Activity) {
        activity = (Activity) context;
    } else if (context instanceof android.support.v7.view.ContextThemeWrapper) {
        activity = (Activity) ((android.support.v7.view.ContextThemeWrapper) context).getBaseContext();
    } else if (context instanceof ContextWrapper) {
        Context context1 = ((ContextWrapper) context).getBaseContext();
        if (context1 instanceof Activity) {
            activity = (Activity) context1;
        } else if (context1 instanceof ContextWrapper) {
            Context context2 = ((ContextWrapper) context1).getBaseContext();
            if (context2 instanceof Activity) {
                activity = (Activity) context2;
            } else if (context2 instanceof ContextWrapper) {
                activity = (Activity) ((android.support.v7.view.ContextThemeWrapper) context2).getBaseContext();
            }
        }
    } else {
        throw new RuntimeException("Could not find activity from context:" + context);
    }
    if (activity != null && !activity.isFinishing()) {
        if (SettingValues.peek) {
            Peek.into(R.layout.peek_view, new SimpleOnPeek() {

                @Override
                public void onInflated(final PeekView peekView, final View rootView) {
                    // do stuff
                    TextView text = ((TextView) rootView.findViewById(R.id.title));
                    text.setText(url);
                    text.setTextColor(Color.WHITE);
                    ((PeekMediaView) rootView.findViewById(R.id.peek)).setUrl(url);
                    peekView.addButton((R.id.copy), new OnButtonUp() {

                        @Override
                        public void onButtonUp() {
                            ClipboardManager clipboard = (ClipboardManager) rootView.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
                            ClipData clip = ClipData.newPlainText("Link", url);
                            clipboard.setPrimaryClip(clip);
                            Toast.makeText(rootView.getContext(), R.string.submission_link_copied, Toast.LENGTH_SHORT).show();
                        }
                    });
                    peekView.setOnRemoveListener(new OnRemove() {

                        @Override
                        public void onRemove() {
                            ((PeekMediaView) rootView.findViewById(R.id.peek)).doClose();
                        }
                    });
                    peekView.addButton((R.id.share), new OnButtonUp() {

                        @Override
                        public void onButtonUp() {
                            Reddit.defaultShareText("", url, rootView.getContext());
                        }
                    });
                    peekView.addButton((R.id.pop), new OnButtonUp() {

                        @Override
                        public void onButtonUp() {
                            Reddit.defaultShareText("", url, rootView.getContext());
                        }
                    });
                    peekView.addButton((R.id.external), new OnButtonUp() {

                        @Override
                        public void onButtonUp() {
                            LinkUtil.openExternally(url, context);
                        }
                    });
                    peekView.setOnPop(new OnPop() {

                        @Override
                        public void onPop() {
                            onLinkClick(url, 0, "", null);
                        }
                    });
                }
            }).with(new PeekViewOptions().setFullScreenPeek(true)).show((PeekViewActivity) activity, event);
        } else {
            BottomSheet.Builder b = new BottomSheet.Builder(activity).title(url).grid();
            int[] attrs = new int[] { R.attr.tintColor };
            TypedArray ta = getContext().obtainStyledAttributes(attrs);
            int color = ta.getColor(0, Color.WHITE);
            Drawable open = getResources().getDrawable(R.drawable.ic_open_in_browser);
            open.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
            Drawable share = getResources().getDrawable(R.drawable.ic_share);
            share.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
            Drawable copy = getResources().getDrawable(R.drawable.ic_content_copy);
            copy.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
            ta.recycle();
            b.sheet(R.id.open_link, open, getResources().getString(R.string.submission_link_extern));
            b.sheet(R.id.share_link, share, getResources().getString(R.string.share_link));
            b.sheet(R.id.copy_link, copy, getResources().getString(R.string.submission_link_copy));
            final Activity finalActivity = activity;
            b.listener(new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch(which) {
                        case R.id.open_link:
                            LinkUtil.openExternally(url, context);
                            break;
                        case R.id.share_link:
                            Reddit.defaultShareText("", url, finalActivity);
                            break;
                        case R.id.copy_link:
                            LinkUtil.copyUrl(url, finalActivity);
                            break;
                    }
                }
            }).show();
        }
    }
}
Also used : DialogInterface(android.content.DialogInterface) SpannableStringBuilder(android.text.SpannableStringBuilder) PeekViewActivity(me.ccrama.redditslide.ForceTouch.PeekViewActivity) Activity(android.app.Activity) PeekMediaView(me.ccrama.redditslide.Views.PeekMediaView) TypedArray(android.content.res.TypedArray) PeekView(me.ccrama.redditslide.ForceTouch.PeekView) TextView(android.widget.TextView) RobotoTextView(com.devspark.robototextview.widget.RobotoTextView) OnPop(me.ccrama.redditslide.ForceTouch.callback.OnPop) PeekViewOptions(me.ccrama.redditslide.ForceTouch.builder.PeekViewOptions) Context(android.content.Context) ClipboardManager(android.content.ClipboardManager) Drawable(android.graphics.drawable.Drawable) MediaView(me.ccrama.redditslide.Activities.MediaView) PeekView(me.ccrama.redditslide.ForceTouch.PeekView) View(android.view.View) TextView(android.widget.TextView) PeekMediaView(me.ccrama.redditslide.Views.PeekMediaView) RobotoTextView(com.devspark.robototextview.widget.RobotoTextView) OnButtonUp(me.ccrama.redditslide.ForceTouch.callback.OnButtonUp) TextPaint(android.text.TextPaint) OnRemove(me.ccrama.redditslide.ForceTouch.callback.OnRemove) BottomSheet(com.cocosw.bottomsheet.BottomSheet) ContextWrapper(android.content.ContextWrapper) ClipData(android.content.ClipData) SimpleOnPeek(me.ccrama.redditslide.ForceTouch.callback.SimpleOnPeek)

Example 5 with PeekViewActivity

use of me.ccrama.redditslide.ForceTouch.PeekViewActivity in project Slide by ccrama.

the class RedditItemView method doSubmission.

public void doSubmission(Submission submission, View content) {
    final SubmissionViewHolder holder = new SubmissionViewHolder(content);
    CreateCardView.resetColorCard(holder.itemView);
    if (submission.getSubredditName() != null) {
        CreateCardView.colorCard(submission.getSubredditName().toLowerCase(Locale.ENGLISH), holder.itemView, "no_subreddit", false);
    }
    new PopulateSubmissionViewHolder().populateSubmissionViewHolder(holder, submission, ((PeekViewActivity) getContext()), false, false, null, null, false, false, null, null);
}
Also used : SubmissionViewHolder(me.ccrama.redditslide.Adapters.SubmissionViewHolder) PopulateSubmissionViewHolder(me.ccrama.redditslide.SubmissionViews.PopulateSubmissionViewHolder) PopulateSubmissionViewHolder(me.ccrama.redditslide.SubmissionViews.PopulateSubmissionViewHolder) PeekViewActivity(me.ccrama.redditslide.ForceTouch.PeekViewActivity)

Aggregations

PeekViewActivity (me.ccrama.redditslide.ForceTouch.PeekViewActivity)5 View (android.view.View)4 TextView (android.widget.TextView)4 ImageView (android.widget.ImageView)3 MediaView (me.ccrama.redditslide.Activities.MediaView)3 Activity (android.app.Activity)2 Context (android.content.Context)2 ContextWrapper (android.content.ContextWrapper)2 DialogInterface (android.content.DialogInterface)2 Intent (android.content.Intent)2 TypedArray (android.content.res.TypedArray)2 Drawable (android.graphics.drawable.Drawable)2 Snackbar (android.support.design.widget.Snackbar)2 RecyclerView (android.support.v7.widget.RecyclerView)2 BottomSheet (com.cocosw.bottomsheet.BottomSheet)2 MainActivity (me.ccrama.redditslide.Activities.MainActivity)2 MultiredditOverview (me.ccrama.redditslide.Activities.MultiredditOverview)2 Profile (me.ccrama.redditslide.Activities.Profile)2 Search (me.ccrama.redditslide.Activities.Search)2 SubredditView (me.ccrama.redditslide.Activities.SubredditView)2