Search in sources :

Example 71 with Snackbar

use of android.support.design.widget.Snackbar in project Reader by TheKeeperOfPie.

the class FragmentThreadList method onCreateView.

@SuppressWarnings("ResourceType")
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    initialize();
    view = bind(inflater.inflate(R.layout.fragment_thread_list, container, false));
    setUpToolbar();
    buttonExpandActions.setOnClickListener(v -> toggleLayoutActions());
    behaviorButtonExpandActions = new ScrollAwareFloatingActionButtonBehavior(getActivity(), null, new ScrollAwareFloatingActionButtonBehavior.OnVisibilityChangeListener() {

        @Override
        public void onStartHideFromScroll() {
            hideLayoutActions(0);
        }

        @Override
        public void onEndHideFromScroll() {
            buttonExpandActions.setImageResource(R.drawable.ic_unfold_more_white_24dp);
            buttonExpandActions.setColorFilter(themer.getColorFilterAccent());
        }
    });
    ((CoordinatorLayout.LayoutParams) buttonExpandActions.getLayoutParams()).setBehavior(behaviorButtonExpandActions);
    buttonJumpTop.setOnClickListener(v -> scrollToPositionWithOffset(0, 0));
    buttonJumpTop.setOnLongClickListener(v -> {
        Toast.makeText(getActivity(), getString(R.string.content_description_button_jump_top), Toast.LENGTH_SHORT).show();
        return false;
    });
    buttonClearViewed.setOnClickListener(v -> controllerLinks.clearViewed(historian));
    buttonClearViewed.setOnLongClickListener(v -> {
        Toast.makeText(getActivity(), getString(R.string.content_description_button_clear_viewed), Toast.LENGTH_SHORT).show();
        return false;
    });
    // Margin is included within shadow margin on pre-Lollipop, so remove all regular margin
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ((CoordinatorLayout.LayoutParams) buttonExpandActions.getLayoutParams()).setMargins(0, 0, 0, 0);
        int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
        LinearLayout.LayoutParams layoutParamsJumpTop = (LinearLayout.LayoutParams) buttonJumpTop.getLayoutParams();
        layoutParamsJumpTop.setMargins(0, 0, 0, 0);
        buttonJumpTop.setLayoutParams(layoutParamsJumpTop);
        LinearLayout.LayoutParams layoutParamsClearViewed = (LinearLayout.LayoutParams) buttonClearViewed.getLayoutParams();
        layoutParamsClearViewed.setMargins(0, 0, 0, 0);
        buttonClearViewed.setLayoutParams(layoutParamsClearViewed);
        RelativeLayout.LayoutParams layoutParamsActions = (RelativeLayout.LayoutParams) layoutActions.getLayoutParams();
        layoutParamsActions.setMarginStart(margin);
        layoutParamsActions.setMarginEnd(margin);
        layoutActions.setLayoutParams(layoutParamsActions);
    }
    buttonExpandActions.setColorFilter(themer.getColorFilterAccent());
    buttonJumpTop.setColorFilter(themer.getColorFilterAccent());
    buttonClearViewed.setColorFilter(themer.getColorFilterAccent());
    swipeRefreshThreadList.setOnRefreshListener(() -> {
        controllerLinks.reload();
    });
    AdapterListener adapterListener = new AdapterListener() {

        @Override
        public void requestMore() {
            controllerLinks.loadMore();
        }

        @Override
        public void scrollAndCenter(int position, int height) {
            UtilsAnimation.scrollToPositionWithCentering(position, recyclerThreadList, height, 0, 0, false);
        }

        @Override
        public void hideToolbar() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void clearDecoration() {
            behaviorButtonExpandActions.animateOut(buttonExpandActions);
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
            recyclerThreadList.requestDisallowInterceptTouchEvent(disallow);
            swipeRefreshThreadList.requestDisallowInterceptTouchEvent(disallow);
            itemTouchHelper.select(null, CustomItemTouchHelper.ACTION_STATE_IDLE);
        }

        @Override
        public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
            itemTouchHelper.setDisallow(disallow);
        }
    };
    AdapterLink.ViewHolderLink.Listener listener = new LinksListenerBase(mListener.getEventListenerBase()) {

        @Override
        public void onVote(Link link, AdapterLink.ViewHolderLink viewHolderLink, Likes vote) {
            mListener.getEventListenerBase().onVote(link, vote).subscribe(new ObserverEmpty<Link>() {

                @Override
                public void onError(Throwable e) {
                    controllerLinks.getEventHolder().getErrors().call(LinksError.VOTE);
                }

                @Override
                public void onNext(Link link) {
                    controllerLinks.update(link);
                }
            });
        }

        @Override
        public void onDelete(Link link) {
            new AlertDialog.Builder(getContext()).setTitle(R.string.delete_post).setMessage(link.getTitle()).setPositiveButton(R.string.yes, (dialog, which) -> {
                mListener.getEventListenerBase().onDelete(link).subscribe(new ObserverEmpty<Link>() {

                    @Override
                    public void onError(Throwable e) {
                        controllerLinks.getEventHolder().getErrors().call(LinksError.DELETE);
                    }

                    @Override
                    public void onNext(Link link) {
                        controllerLinks.remove(link);
                    }
                });
            }).setNegativeButton(R.string.no, null).show();
        }

        @Override
        public void onReport(Link link) {
            // TODO: Add link title
            new AlertDialog.Builder(getContext()).setTitle(R.string.report_title).setSingleChoiceItems(Report.getDisplayReasons(getResources()), -1, (dialog, which) -> {
                reportSelected = Report.values()[which];
            }).setPositiveButton(R.string.ok, (dialog, which) -> {
                if (reportSelected == Report.OTHER) {
                    View viewDialog = LayoutInflater.from(getContext()).inflate(R.layout.dialog_text_input, null, false);
                    final EditText editText = (EditText) viewDialog.findViewById(R.id.edit_text);
                    editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(100) });
                    new AlertDialog.Builder(getContext()).setView(viewDialog).setTitle(R.string.item_report).setPositiveButton(R.string.ok, (dialog1, which1) -> {
                        mListener.getEventListenerBase().onReport(link, editText.getText().toString()).subscribe(new ObserverError<String>() {

                            @Override
                            public void onError(Throwable e) {
                                controllerLinks.getEventHolder().getErrors().call(LinksError.REPORT);
                            }
                        });
                    }).setNegativeButton(R.string.cancel, (dialog1, which1) -> {
                        dialog1.dismiss();
                    }).show();
                } else if (reportSelected != null) {
                    mListener.getEventListenerBase().onReport(link, reportSelected.getReason()).subscribe(new ObserverError<String>() {

                        @Override
                        public void onError(Throwable e) {
                            controllerLinks.getEventHolder().getErrors().call(LinksError.REPORT);
                        }
                    });
                }
            }).setNegativeButton(R.string.cancel, null).show();
        }

        @Override
        public void onSave(Link link) {
            if (link.isSaved()) {
                mListener.getEventListenerBase().onUnsave(link).subscribe(new ObserverEmpty<Link>() {

                    @Override
                    public void onError(Throwable e) {
                        controllerLinks.getEventHolder().getErrors().call(LinksError.UNSAVE);
                    }

                    @Override
                    public void onNext(Link link) {
                        controllerLinks.update(link);
                    }
                });
            } else {
                mListener.getEventListenerBase().onSave(link).subscribe(new ObserverEmpty<Link>() {

                    @Override
                    public void onError(Throwable e) {
                        controllerLinks.getEventHolder().getErrors().call(LinksError.SAVE);
                    }

                    @Override
                    public void onNext(Link link) {
                        controllerLinks.update(link);
                    }
                });
            }
        }

        @Override
        public void onMarkNsfw(Link link) {
            if (link.isOver18()) {
                mListener.getEventListenerBase().onUnmarkNsfw(link).subscribe(new ObserverEmpty<Link>() {

                    @Override
                    public void onError(Throwable e) {
                        controllerLinks.getEventHolder().getErrors().call(LinksError.UNMARK_NSFW);
                    }

                    @Override
                    public void onNext(Link link) {
                        controllerLinks.update(link);
                    }
                });
            } else {
                mListener.getEventListenerBase().onMarkNsfw(link).subscribe(new ObserverEmpty<Link>() {

                    @Override
                    public void onError(Throwable e) {
                        controllerLinks.getEventHolder().getErrors().call(LinksError.MARK_NSFW);
                    }

                    @Override
                    public void onNext(Link link) {
                        controllerLinks.update(link);
                    }
                });
            }
        }
    };
    adapterLinkList = new AdapterLinkList(getActivity(), adapterListener, eventListenerHeader, listener);
    adapterLinkGrid = new AdapterLinkGrid(getActivity(), adapterListener, eventListenerHeader, listener);
    adapterLink = AppSettings.MODE_GRID.equals(preferences.getString(AppSettings.INTERFACE_MODE, AppSettings.MODE_GRID)) ? adapterLinkGrid : adapterLinkList;
    itemDecorationDivider = new ItemDecorationDivider(getActivity(), ItemDecorationDivider.VERTICAL_LIST);
    //        recyclerThreadList.setItemAnimator(null);
    resetAdapter(adapterLink);
    recyclerThreadList.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            switch(newState) {
                case RecyclerView.SCROLL_STATE_IDLE:
                case RecyclerView.SCROLL_STATE_DRAGGING:
                    picasso.resumeTag(AdapterLink.TAG_PICASSO);
                    break;
                case RecyclerView.SCROLL_STATE_SETTLING:
                    picasso.pauseTag(AdapterLink.TAG_PICASSO);
                    break;
            }
        }
    });
    itemTouchHelper = new CustomItemTouchHelper(new CustomItemTouchHelper.SimpleCallback(getActivity(), R.drawable.ic_visibility_off_white_24dp, ItemTouchHelper.START | ItemTouchHelper.END, ItemTouchHelper.START | ItemTouchHelper.END) {

        @Override
        public float getSwipeThreshold(RecyclerView.ViewHolder viewHolder) {
            if (layoutManager instanceof StaggeredGridLayoutManager) {
                return 1f / ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
            }
            return 0.5f;
        }

        @Override
        public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            if (viewHolder.getAdapterPosition() == 0) {
                return 0;
            }
            ViewGroup.LayoutParams layoutParams = viewHolder.itemView.getLayoutParams();
            if (layoutParams instanceof StaggeredGridLayoutManager.LayoutParams && !((StaggeredGridLayoutManager.LayoutParams) layoutParams).isFullSpan()) {
                int spanCount = layoutManager instanceof StaggeredGridLayoutManager ? ((StaggeredGridLayoutManager) layoutManager).getSpanCount() : 2;
                int spanIndex = ((StaggeredGridLayoutManager.LayoutParams) layoutParams).getSpanIndex() % spanCount;
                if (spanIndex == 0) {
                    return ItemTouchHelper.END;
                } else if (spanIndex == spanCount - 1) {
                    return ItemTouchHelper.START;
                }
            }
            return super.getSwipeDirs(recyclerView, viewHolder);
        }

        @Override
        public boolean isLongPressDragEnabled() {
            return false;
        }

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(final RecyclerView.ViewHolder viewHolder, int direction) {
            // Offset by 1 due to subreddit header
            Link link = controllerLinks.hideLink(viewHolder.getAdapterPosition());
            mListener.getEventListenerBase().hide(link);
            if (snackbar != null) {
                snackbar.dismiss();
            }
            SpannableString text = new SpannableString(link.isHidden() ? getString(R.string.link_hidden) : getString(R.string.link_shown));
            text.setSpan(new ForegroundColorSpan(themer.getColorFilterPrimary().getColor()), 0, text.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
            //noinspection ResourceType
            snackbar = Snackbar.make(recyclerThreadList, text, UtilsAnimation.SNACKBAR_DURATION).setActionTextColor(themer.getColorFilterPrimary().getColor()).setAction(R.string.undo, v -> {
                mListener.getEventListenerBase().hide(link);
                controllerLinks.reshowLastHiddenLink();
            });
            snackbar.getView().setBackgroundColor(themer.getColorPrimary());
            snackbar.show();
        }
    });
    itemTouchHelper.attachToRecyclerView(recyclerThreadList);
    recyclerThreadList.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {

        @Override
        public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
            //                rv.getChildViewHolder(rv.findChildViewUnder(e.getX(), e.getY()));
            return false;
        }

        @Override
        public void onTouchEvent(RecyclerView rv, MotionEvent e) {
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
    if (layoutManager instanceof LinearLayoutManager) {
        recyclerThreadList.setPadding(0, 0, 0, 0);
    } else {
        int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
        recyclerThreadList.setPadding(padding, 0, padding, 0);
    }
    textSidebar.setMovementMethod(LinkMovementMethod.getInstance());
    buttonSubscribe.setOnClickListener(v -> controllerLinks.subscribe());
    return view;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) ObserverEmpty(com.winsonchiu.reader.rx.ObserverEmpty) Historian(com.winsonchiu.reader.history.Historian) ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) LinkMovementMethod(android.text.method.LinkMovementMethod) UtilsAnimation(com.winsonchiu.reader.utils.UtilsAnimation) BindView(butterknife.BindView) Picasso(com.squareup.picasso.Picasso) Reddit(com.winsonchiu.reader.data.reddit.Reddit) Likes(com.winsonchiu.reader.data.reddit.Likes) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) View(android.view.View) Button(android.widget.Button) ViewCompat(android.support.v4.view.ViewCompat) ForegroundColorSpan(android.text.style.ForegroundColorSpan) Log(android.util.Log) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ActionLog(com.winsonchiu.reader.rx.ActionLog) FloatingActionButton(android.support.design.widget.FloatingActionButton) CustomItemTouchHelper(com.winsonchiu.reader.utils.CustomItemTouchHelper) UtilsReddit(com.winsonchiu.reader.utils.UtilsReddit) ViewGroup(android.view.ViewGroup) R(com.winsonchiu.reader.R) UtilsColor(com.winsonchiu.reader.utils.UtilsColor) FragmentBase(com.winsonchiu.reader.FragmentBase) FragmentNewPost(com.winsonchiu.reader.FragmentNewPost) TextView(android.widget.TextView) RelativeLayout(android.widget.RelativeLayout) Time(com.winsonchiu.reader.data.reddit.Time) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) InputFilter(android.text.InputFilter) User(com.winsonchiu.reader.data.reddit.User) Subscription(rx.Subscription) ObserverError(com.winsonchiu.reader.rx.ObserverError) Report(com.winsonchiu.reader.data.reddit.Report) AppBarLayout(android.support.design.widget.AppBarLayout) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Spanned(android.text.Spanned) FastOutSlowInInterpolator(android.support.v4.view.animation.FastOutSlowInInterpolator) Subreddit(com.winsonchiu.reader.data.reddit.Subreddit) UtilsRx(com.winsonchiu.reader.utils.UtilsRx) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) AppSettings(com.winsonchiu.reader.AppSettings) MenuItem(android.view.MenuItem) GravityCompat(android.support.v4.view.GravityCompat) Inject(javax.inject.Inject) MotionEvent(android.view.MotionEvent) Toast(android.widget.Toast) Menu(android.view.Menu) Link(com.winsonchiu.reader.data.reddit.Link) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) Build(android.os.Build) DrawerLayout(android.support.v4.widget.DrawerLayout) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) SpannableString(android.text.SpannableString) LayoutInflater(android.view.LayoutInflater) ControllerUser(com.winsonchiu.reader.ControllerUser) Sort(com.winsonchiu.reader.data.reddit.Sort) ItemDecorationDivider(com.winsonchiu.reader.utils.ItemDecorationDivider) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) Thing(com.winsonchiu.reader.data.reddit.Thing) FragmentSearch(com.winsonchiu.reader.search.FragmentSearch) RecyclerView(android.support.v7.widget.RecyclerView) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) Toolbar(android.support.v7.widget.Toolbar) ActivityMain(com.winsonchiu.reader.ActivityMain) FragmentListenerBase(com.winsonchiu.reader.FragmentListenerBase) Activity(android.app.Activity) UtilsTheme(com.winsonchiu.reader.utils.UtilsTheme) EditText(android.widget.EditText) ItemDecorationDivider(com.winsonchiu.reader.utils.ItemDecorationDivider) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) SpannableString(android.text.SpannableString) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) AppBarLayout(android.support.design.widget.AppBarLayout) EditText(android.widget.EditText) InputFilter(android.text.InputFilter) ForegroundColorSpan(android.text.style.ForegroundColorSpan) SpannableString(android.text.SpannableString) RelativeLayout(android.widget.RelativeLayout) Link(com.winsonchiu.reader.data.reddit.Link) CustomItemTouchHelper(com.winsonchiu.reader.utils.CustomItemTouchHelper) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) ViewGroup(android.view.ViewGroup) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) MotionEvent(android.view.MotionEvent) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ObserverError(com.winsonchiu.reader.rx.ObserverError) RecyclerView(android.support.v7.widget.RecyclerView) Likes(com.winsonchiu.reader.data.reddit.Likes) LinearLayout(android.widget.LinearLayout)

Example 72 with Snackbar

use of android.support.design.widget.Snackbar in project MultiPhotoPicker by wangeason.

the class PhotoPagerActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        onBackPressed();
        return true;
    }
    if (item.getItemId() == R.id.delete) {
        final int index = pagerFragment.getCurrentItem();
        final String deletedPath = pagerFragment.getPaths().get(index);
        Snackbar snackbar = Snackbar.make(pagerFragment.getView(), R.string.deleted_a_photo, Snackbar.LENGTH_LONG);
        if (pagerFragment.getPaths().size() <= 1) {
            // show confirm dialog
            new AlertDialog.Builder(this).setTitle(R.string.confirm_to_delete).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                    setResult(RESULT_OK);
                    finish();
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            }).show();
        } else {
            snackbar.show();
            pagerFragment.getPaths().remove(index);
            //pagerFragment.getViewPager().removeViewAt(index);
            pagerFragment.getViewPager().getAdapter().notifyDataSetChanged();
        }
        snackbar.setAction(R.string.undo, new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                if (pagerFragment.getPaths().size() > 0) {
                    pagerFragment.getPaths().add(index, deletedPath);
                } else {
                    pagerFragment.getPaths().add(deletedPath);
                }
                pagerFragment.getViewPager().getAdapter().notifyDataSetChanged();
                pagerFragment.getViewPager().setCurrentItem(index, true);
            }
        });
        return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : DialogInterface(android.content.DialogInterface) View(android.view.View) Snackbar(android.support.design.widget.Snackbar)

Example 73 with Snackbar

use of android.support.design.widget.Snackbar in project PermissionsSample by CesarValiente.

the class BaseActivity method showSnackBarPermissionMessage.

protected void showSnackBarPermissionMessage(int message) {
    final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_coordinator_layout);
    Snackbar snackbar = Snackbar.make(coordinatorLayout, getString(message), Snackbar.LENGTH_LONG).setAction(getString(R.string.snackbar_settings), new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.setData(Uri.parse("package:" + BuildConfig.APPLICATION_ID));
            startActivity(intent);
        }
    });
    snackbar.show();
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) Snackbar(android.support.design.widget.Snackbar)

Example 74 with Snackbar

use of android.support.design.widget.Snackbar in project PermissionsSample by CesarValiente.

the class ContactFragment method imageSaved.

@Override
public void imageSaved(final boolean result) {
    Snackbar snackbar;
    if (result) {
        snackbar = Snackbar.make(photo, getString(R.string.image_saved), Snackbar.LENGTH_LONG);
    } else {
        snackbar = Snackbar.make(photo, getString(R.string.image_not_saved), Snackbar.LENGTH_LONG);
    }
    snackbar.show();
}
Also used : Snackbar(android.support.design.widget.Snackbar)

Example 75 with Snackbar

use of android.support.design.widget.Snackbar in project Dexter by Karumi.

the class SnackbarOnDeniedPermissionListener method onPermissionDenied.

@Override
public void onPermissionDenied(PermissionDeniedResponse response) {
    super.onPermissionDenied(response);
    Snackbar snackbar = Snackbar.make(rootView, text, Snackbar.LENGTH_LONG);
    if (buttonText != null && onButtonClickListener != null) {
        snackbar.setAction(buttonText, onButtonClickListener);
    }
    if (snackbarCallback != null) {
        snackbar.setCallback(snackbarCallback);
    }
    snackbar.show();
}
Also used : Snackbar(android.support.design.widget.Snackbar)

Aggregations

Snackbar (android.support.design.widget.Snackbar)102 View (android.view.View)56 TextView (android.widget.TextView)25 Intent (android.content.Intent)13 RecyclerView (android.support.v7.widget.RecyclerView)13 BaseTransientBottomBar (android.support.design.widget.BaseTransientBottomBar)10 ImageView (android.widget.ImageView)10 ViewGroup (android.view.ViewGroup)8 DialogInterface (android.content.DialogInterface)7 LayoutInflater (android.view.LayoutInflater)6 AdapterView (android.widget.AdapterView)6 LinearLayout (android.widget.LinearLayout)6 ListView (android.widget.ListView)6 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)5 AlertDialog (android.app.AlertDialog)4 Context (android.content.Context)4 Nullable (android.support.annotation.Nullable)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 File (java.io.File)4 RemindyDAO (ve.com.abicelis.remindy.database.RemindyDAO)4