Search in sources :

Example 91 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project Slide by ccrama.

the class SubmissionNewsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder2, final int pos) {
    int i = pos != 0 ? pos - 1 : pos;
    if (holder2 instanceof NewsViewHolder) {
        final NewsViewHolder holder = (NewsViewHolder) holder2;
        final Submission submission = dataSet.posts.get(i);
        CreateCardView.colorCard(submission.getSubredditName().toLowerCase(Locale.ENGLISH), holder.itemView, subreddit, (subreddit.equals("frontpage") || subreddit.equals("mod") || subreddit.equals("friends") || (subreddit.equals("all")) || subreddit.contains(".") || subreddit.contains("+")));
        holder.itemView.setOnClickListener(new OnSingleClickListener() {

            @Override
            public void onSingleClick(View v) {
                if (Authentication.didOnline || submission.getComments() != null) {
                    holder.title.setAlpha(0.54f);
                    if (context instanceof MainActivity) {
                        final MainActivity a = (MainActivity) context;
                        if (a.singleMode && a.commentPager && a.adapter instanceof MainActivity.MainPagerAdapterComment) {
                            if (a.openingComments != submission) {
                                clicked = holder2.getBindingAdapterPosition();
                                a.openingComments = submission;
                                a.toOpenComments = a.pager.getCurrentItem() + 1;
                                a.currentComment = holder.getBindingAdapterPosition() - 1;
                                ((MainActivity.MainPagerAdapterComment) (a).adapter).storedFragment = (a).adapter.getCurrentFragment();
                                ((MainActivity.MainPagerAdapterComment) (a).adapter).size = a.toOpenComments + 1;
                                try {
                                    a.adapter.notifyDataSetChanged();
                                } catch (Exception ignored) {
                                }
                            }
                            a.pager.postDelayed(new Runnable() {

                                @Override
                                public void run() {
                                    a.pager.setCurrentItem(a.pager.getCurrentItem() + 1, true);
                                }
                            }, 400);
                        } else {
                            Intent i2 = new Intent(context, CommentsScreen.class);
                            i2.putExtra(CommentsScreen.EXTRA_PAGE, holder2.getBindingAdapterPosition() - 1);
                            i2.putExtra(CommentsScreen.EXTRA_SUBREDDIT, subreddit);
                            i2.putExtra("fullname", submission.getFullName());
                            context.startActivityForResult(i2, 940);
                            clicked = holder2.getBindingAdapterPosition();
                        }
                    } else if (context instanceof SubredditView) {
                        final SubredditView a = (SubredditView) context;
                        if (a.singleMode && a.commentPager) {
                            if (a.openingComments != submission) {
                                clicked = holder2.getBindingAdapterPosition();
                                a.openingComments = submission;
                                a.currentComment = holder.getBindingAdapterPosition() - 1;
                                ((SubredditView.SubredditPagerAdapterComment) (a).adapter).storedFragment = (a).adapter.getCurrentFragment();
                                ((SubredditView.SubredditPagerAdapterComment) a.adapter).size = 3;
                                a.adapter.notifyDataSetChanged();
                            }
                            a.pager.postDelayed(new Runnable() {

                                @Override
                                public void run() {
                                    a.pager.setCurrentItem(a.pager.getCurrentItem() + 1, true);
                                }
                            }, 400);
                        } else {
                            Intent i2 = new Intent(context, CommentsScreen.class);
                            i2.putExtra(CommentsScreen.EXTRA_PAGE, holder2.getBindingAdapterPosition() - 1);
                            i2.putExtra(CommentsScreen.EXTRA_SUBREDDIT, subreddit);
                            i2.putExtra("fullname", submission.getFullName());
                            context.startActivityForResult(i2, 940);
                            clicked = holder2.getBindingAdapterPosition();
                        }
                    }
                } else {
                    if (!Reddit.appRestart.contains("offlinepopup")) {
                        new AlertDialog.Builder(context).setTitle(R.string.cache_no_comments_found).setMessage(R.string.cache_no_comments_found_message).setCancelable(false).setPositiveButton(R.string.btn_ok, (dialog, which) -> Reddit.appRestart.edit().putString("offlinepopup", "").apply()).show();
                    } else {
                        Snackbar s = Snackbar.make(holder.itemView, R.string.cache_no_comments_found_snackbar, Snackbar.LENGTH_SHORT);
                        s.setAction(R.string.misc_more_info, new View.OnClickListener() {

                            @Override
                            public void onClick(View v) {
                                new AlertDialog.Builder(context).setTitle(R.string.cache_no_comments_found).setMessage(R.string.cache_no_comments_found_message).setCancelable(false).setPositiveButton(R.string.btn_ok, (dialog, which) -> Reddit.appRestart.edit().putString("offlinepopup", "").apply()).show();
                            }
                        });
                        LayoutUtils.showSnackbar(s);
                    }
                }
            }
        });
        new PopulateNewsViewHolder().populateNewsViewHolder(holder, submission, context, false, false, dataSet.posts, listView, custom, dataSet.offline, dataSet.subreddit.toLowerCase(Locale.ENGLISH), null);
    }
    if (holder2 instanceof SubmissionFooterViewHolder) {
        Handler handler = new Handler();
        final Runnable r = new Runnable() {

            public void run() {
                notifyItemChanged(dataSet.posts.size() + // the loading spinner to replaced by nomoreposts.xml
                1);
            }
        };
        handler.post(r);
        if (holder2.itemView.findViewById(R.id.reload) != null) {
            holder2.itemView.findViewById(R.id.reload).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    dataSet.loadMore(context, displayer, true);
                }
            });
        }
    }
    if (holder2 instanceof SpacerViewHolder) {
        View header = (context).findViewById(R.id.header);
        int height = header.getHeight();
        if (height == 0) {
            header.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
            height = header.getMeasuredHeight();
            holder2.itemView.findViewById(R.id.height).setLayoutParams(new LinearLayout.LayoutParams(holder2.itemView.getWidth(), height));
            if (listView.getLayoutManager() instanceof CatchStaggeredGridLayoutManager) {
                CatchStaggeredGridLayoutManager.LayoutParams layoutParams = new CatchStaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);
                layoutParams.setFullSpan(true);
                holder2.itemView.setLayoutParams(layoutParams);
            }
        } else {
            holder2.itemView.findViewById(R.id.height).setLayoutParams(new LinearLayout.LayoutParams(holder2.itemView.getWidth(), height));
            if (listView.getLayoutManager() instanceof CatchStaggeredGridLayoutManager) {
                CatchStaggeredGridLayoutManager.LayoutParams layoutParams = new CatchStaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);
                layoutParams.setFullSpan(true);
                holder2.itemView.setLayoutParams(layoutParams);
            }
        }
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) LayoutUtils(me.ccrama.redditslide.util.LayoutUtils) LinearLayout(android.widget.LinearLayout) SettingValues(me.ccrama.redditslide.SettingValues) AlertDialog(androidx.appcompat.app.AlertDialog) R(me.ccrama.redditslide.R) PopulateNewsViewHolder(me.ccrama.redditslide.SubmissionViews.PopulateNewsViewHolder) Submission(net.dean.jraw.models.Submission) MainActivity(me.ccrama.redditslide.Activities.MainActivity) Intent(android.content.Intent) ArrayList(java.util.ArrayList) OnSingleClickListener(me.ccrama.redditslide.util.OnSingleClickListener) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) Locale(java.util.Locale) Handler(android.os.Handler) SubredditView(me.ccrama.redditslide.Activities.SubredditView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CommentsScreen(me.ccrama.redditslide.Activities.CommentsScreen) LayoutInflater(android.view.LayoutInflater) Reddit(me.ccrama.redditslide.Reddit) Authentication(me.ccrama.redditslide.Authentication) ViewGroup(android.view.ViewGroup) CatchStaggeredGridLayoutManager(me.ccrama.redditslide.Views.CatchStaggeredGridLayoutManager) List(java.util.List) CreateCardView(me.ccrama.redditslide.Views.CreateCardView) Activity(android.app.Activity) Snackbar(com.google.android.material.snackbar.Snackbar) CatchStaggeredGridLayoutManager(me.ccrama.redditslide.Views.CatchStaggeredGridLayoutManager) OnSingleClickListener(me.ccrama.redditslide.util.OnSingleClickListener) SubredditView(me.ccrama.redditslide.Activities.SubredditView) MainActivity(me.ccrama.redditslide.Activities.MainActivity) PopulateNewsViewHolder(me.ccrama.redditslide.SubmissionViews.PopulateNewsViewHolder) CommentsScreen(me.ccrama.redditslide.Activities.CommentsScreen) Submission(net.dean.jraw.models.Submission) Handler(android.os.Handler) Intent(android.content.Intent) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) SubredditView(me.ccrama.redditslide.Activities.SubredditView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CreateCardView(me.ccrama.redditslide.Views.CreateCardView) PopulateNewsViewHolder(me.ccrama.redditslide.SubmissionViews.PopulateNewsViewHolder) LinearLayout(android.widget.LinearLayout) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 92 with Snackbar

use of com.google.android.material.snackbar.Snackbar 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);
    final Drawable profile = mContext.getResources().getDrawable(R.drawable.ic_account_circle);
    final Drawable report = mContext.getResources().getDrawable(R.drawable.ic_report);
    final Drawable approve = mContext.getResources().getDrawable(R.drawable.ic_thumb_up);
    final Drawable nsfw = mContext.getResources().getDrawable(R.drawable.ic_visibility_off);
    final Drawable pin = mContext.getResources().getDrawable(R.drawable.ic_bookmark_border);
    final Drawable distinguish = mContext.getResources().getDrawable(R.drawable.ic_star);
    final Drawable remove = mContext.getResources().getDrawable(R.drawable.ic_close);
    final Drawable ban = mContext.getResources().getDrawable(R.drawable.ic_gavel);
    final Drawable spam = mContext.getResources().getDrawable(R.drawable.ic_flag);
    final Drawable note = mContext.getResources().getDrawable(R.drawable.ic_note);
    final Drawable removeReason = mContext.getResources().getDrawable(R.drawable.ic_announcement);
    final Drawable lock = mContext.getResources().getDrawable(R.drawable.ic_lock);
    // Tint drawables
    final List<Drawable> drawableSet = Arrays.asList(profile, report, approve, nsfw, distinguish, remove, pin, ban, spam, note, removeReason, lock);
    BlendModeUtil.tintDrawablesAsSrcAtop(drawableSet, color);
    ta.recycle();
    // Bottom sheet builder
    BottomSheet.Builder b = new BottomSheet.Builder((Activity) mContext).title(CompatUtil.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));
    }
    if (SettingValues.toolboxEnabled) {
        b.sheet(24, note, mContext.getString(R.string.mod_usernotes_view));
    }
    b.sheet(1, approve, mContext.getString(R.string.mod_btn_approve));
    b.sheet(6, remove, mContext.getString(R.string.btn_remove));
    b.sheet(7, removeReason, mContext.getString(R.string.mod_btn_remove_reason));
    b.sheet(10, spam, mContext.getString(R.string.mod_btn_spam));
    final boolean locked = comment.getDataNode().has("locked") && comment.getDataNode().get("locked").asBoolean();
    if (locked) {
        b.sheet(25, lock, mContext.getString(R.string.mod_btn_unlock_comment));
    } else {
        b.sheet(25, lock, mContext.getString(R.string.mod_btn_lock_comment));
    }
    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(8, profile, mContext.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:
                    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 7:
                    if (SettingValues.removalReasonType == SettingValues.RemovalReasonType.TOOLBOX.ordinal() && ToolboxUI.canShowRemoval(comment.getSubredditName())) {
                        ToolboxUI.showRemoval(mContext, comment, new ToolboxUI.CompletedRemovalCallback() {

                            @Override
                            public void onComplete(boolean success) {
                                if (success) {
                                    Snackbar s = Snackbar.make(holder.itemView, R.string.comment_removed, Snackbar.LENGTH_LONG);
                                    LayoutUtils.showSnackbar(s);
                                } else {
                                    new AlertDialog.Builder(mContext).setTitle(R.string.err_general).setMessage(R.string.err_retry_later).show();
                                }
                            }
                        });
                    } else {
                        // Show a Slide reason dialog if we can't show a toolbox or reddit reason
                        doRemoveCommentReason(mContext, holder, comment);
                    }
                    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;
                case 24:
                    ToolboxUI.showUsernotes(mContext, comment.getAuthor(), comment.getSubredditName(), "l," + comment.getParentId() + "," + comment.getId());
                    break;
                case 25:
                    lockUnlockComment(mContext, holder, comment, !locked);
                    break;
            }
        }
    });
    b.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) DialogInterface(android.content.DialogInterface) Drawable(android.graphics.drawable.Drawable) Activity(android.app.Activity) Intent(android.content.Intent) Profile(me.ccrama.redditslide.Activities.Profile) TypedArray(android.content.res.TypedArray) BottomSheet(com.cocosw.bottomsheet.BottomSheet) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 93 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project Slide by ccrama.

the class SettingsSubreddit method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    applyColorTheme();
    setContentView(R.layout.activity_settings_subreddit);
    SettingsThemeFragment.changed = true;
    setupAppBar(R.id.toolbar, R.string.title_subreddit_settings, true, true);
    recycler = ((RecyclerView) findViewById(R.id.subslist));
    recycler.setLayoutManager(new LinearLayoutManager(this));
    reloadSubList();
    findViewById(R.id.reset).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new AlertDialog.Builder(SettingsSubreddit.this).setTitle(R.string.clear_all_sub_themes).setMessage(R.string.clear_all_sub_themes_msg).setPositiveButton(R.string.btn_yes, (dialog, which) -> {
                for (String s : changedSubs) {
                    Palette.removeColor(s);
                    SettingValues.prefs.edit().remove(Reddit.PREF_LAYOUT + s).apply();
                    new ColorPreferences(SettingsSubreddit.this).removeFontStyle(s);
                    SettingValues.resetPicsEnabled(s);
                }
                reloadSubList();
            }).setNegativeButton(R.string.btn_no, null).show();
        }
    });
    findViewById(R.id.post_floating_action_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final ArrayList<String> subs = UserSubscriptions.sort(UserSubscriptions.getSubscriptions(SettingsSubreddit.this));
            final CharSequence[] subsAsChar = subs.toArray(new CharSequence[0]);
            MaterialDialog.Builder builder = new MaterialDialog.Builder(SettingsSubreddit.this);
            builder.title(R.string.dialog_choose_subreddits_to_edit).items(subsAsChar).itemsCallbackMultiChoice(null, new MaterialDialog.ListCallbackMultiChoice() {

                @Override
                public boolean onSelection(MaterialDialog dialog, Integer[] which, CharSequence[] text) {
                    ArrayList<String> selectedSubs = new ArrayList<>();
                    for (int i : which) {
                        selectedSubs.add(subsAsChar[i].toString());
                    }
                    if (mSettingsSubAdapter != null)
                        mSettingsSubAdapter.prepareAndShowSubEditor(selectedSubs);
                    return true;
                }
            }).positiveText(R.string.btn_select).negativeText(R.string.btn_cancel).show();
        }
    });
    findViewById(R.id.color).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (Authentication.isLoggedIn) {
                new AlertDialog.Builder(SettingsSubreddit.this).setTitle(R.string.dialog_color_sync_title).setMessage(R.string.dialog_color_sync_message).setPositiveButton(R.string.misc_continue, (dialog, which) -> {
                    final MaterialDialog d = new MaterialDialog.Builder(SettingsSubreddit.this).title(R.string.general_sub_sync).content(R.string.misc_please_wait).progress(false, 100).cancelable(false).show();
                    new AsyncTask<Void, Void, Void>() {

                        @Override
                        protected Void doInBackground(Void... params) {
                            ArrayList<Subreddit> subColors = UserSubscriptions.syncSubredditsGetObject();
                            d.setMaxProgress(subColors.size());
                            int i = 0;
                            done = 0;
                            for (Subreddit s : subColors) {
                                if (s.getDataNode().has("key_color") && !s.getDataNode().get("key_color").asText().isEmpty() && Palette.getColor(s.getDisplayName().toLowerCase(Locale.ENGLISH)) == Palette.getDefaultColor()) {
                                    Palette.setColor(s.getDisplayName().toLowerCase(Locale.ENGLISH), GetClosestColor.getClosestColor(s.getDataNode().get("key_color").asText(), SettingsSubreddit.this));
                                    done++;
                                }
                                d.setProgress(i);
                                i++;
                                if (i == d.getMaxProgress()) {
                                    d.dismiss();
                                }
                            }
                            return null;
                        }

                        @Override
                        protected void onPostExecute(Void aVoid) {
                            reloadSubList();
                            Resources res = getResources();
                            new AlertDialog.Builder(SettingsSubreddit.this).setTitle(R.string.color_sync_complete).setMessage(res.getQuantityString(R.plurals.color_sync_colored, done, done)).setPositiveButton(R.string.btn_ok, null).show();
                        }
                    }.execute();
                    d.show();
                }).setNegativeButton(R.string.btn_cancel, null).show();
            } else {
                Snackbar s = Snackbar.make(mToolbar, R.string.err_color_sync_login, Snackbar.LENGTH_SHORT);
                LayoutUtils.showSnackbar(s);
            }
        }
    });
}
Also used : LayoutUtils(me.ccrama.redditslide.util.LayoutUtils) SettingValues(me.ccrama.redditslide.SettingValues) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) R(me.ccrama.redditslide.R) Intent(android.content.Intent) ArrayList(java.util.ArrayList) Locale(java.util.Locale) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) View(android.view.View) UserSubscriptions(me.ccrama.redditslide.UserSubscriptions) RecyclerView(androidx.recyclerview.widget.RecyclerView) AsyncTask(android.os.AsyncTask) Reddit(me.ccrama.redditslide.Reddit) Authentication(me.ccrama.redditslide.Authentication) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Palette(me.ccrama.redditslide.Visuals.Palette) GetClosestColor(me.ccrama.redditslide.Visuals.GetClosestColor) BaseActivityAnim(me.ccrama.redditslide.Activities.BaseActivityAnim) List(java.util.List) Subreddit(net.dean.jraw.models.Subreddit) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Snackbar(com.google.android.material.snackbar.Snackbar) Resources(android.content.res.Resources) ArrayList(java.util.ArrayList) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) AsyncTask(android.os.AsyncTask) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerView(androidx.recyclerview.widget.RecyclerView) Resources(android.content.res.Resources) Subreddit(net.dean.jraw.models.Subreddit) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 94 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project Slide by ccrama.

the class SettingsGeneralFragment method doNotifText.

public static void doNotifText(final Activity context) {
    {
        View notifs = context.findViewById(R.id.settings_general_redditnotifs);
        if (notifs != null) {
            if (!Reddit.isPackageInstalled("com.reddit.frontpage") || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
                notifs.setVisibility(View.GONE);
                if (context.findViewById(R.id.settings_general_installreddit) != null) {
                    context.findViewById(R.id.settings_general_installreddit).setVisibility(View.VISIBLE);
                }
            } else {
                if (((Reddit) context.getApplication()).isNotificationAccessEnabled()) {
                    SwitchCompat single = context.findViewById(R.id.settings_general_piggyback);
                    if (single != null) {
                        single.setChecked(true);
                        single.setEnabled(false);
                    }
                } else {
                    final SwitchCompat single = context.findViewById(R.id.settings_general_piggyback);
                    if (single != null) {
                        single.setChecked(false);
                        single.setEnabled(true);
                        single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                            @Override
                            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                                single.setChecked(false);
                                Snackbar s = Snackbar.make(single, "Give Slide notification access", Snackbar.LENGTH_LONG);
                                s.setAction("Go to settings", new View.OnClickListener() {

                                    @Override
                                    public void onClick(View view) {
                                        context.startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
                                    }
                                });
                                s.show();
                            }
                        });
                    }
                }
            }
        }
    }
}
Also used : Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton) SwitchCompat(androidx.appcompat.widget.SwitchCompat) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 95 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project Slide by ccrama.

the class Vote method createVoteSnackbar.

private void createVoteSnackbar(final int i) {
    ((Activity) c).runOnUiThread(() -> {
        try {
            if (v != null && c != null && v.getContext() != null) {
                Snackbar snackbar = Snackbar.make(v, i, Snackbar.LENGTH_SHORT);
                LayoutUtils.showSnackbar(snackbar);
            }
        } catch (Exception ignored) {
        }
        c = null;
        v = null;
    });
}
Also used : Activity(android.app.Activity) ApiException(net.dean.jraw.ApiException) Snackbar(com.google.android.material.snackbar.Snackbar)

Aggregations

Snackbar (com.google.android.material.snackbar.Snackbar)110 View (android.view.View)61 Intent (android.content.Intent)46 TextView (android.widget.TextView)41 AlertDialog (androidx.appcompat.app.AlertDialog)29 Context (android.content.Context)28 ImageView (android.widget.ImageView)28 LayoutInflater (android.view.LayoutInflater)24 ArrayList (java.util.ArrayList)23 RecyclerView (androidx.recyclerview.widget.RecyclerView)22 Bundle (android.os.Bundle)20 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)20 DialogInterface (android.content.DialogInterface)19 List (java.util.List)19 CreateCardView (me.ccrama.redditslide.Views.CreateCardView)18 Submission (net.dean.jraw.models.Submission)18 SubredditView (me.ccrama.redditslide.Activities.SubredditView)17 ApiException (net.dean.jraw.ApiException)17 Activity (android.app.Activity)16 OnSingleClickListener (me.ccrama.redditslide.util.OnSingleClickListener)16