Search in sources :

Example 11 with LinearOutSlowInInterpolator

use of androidx.interpolator.view.animation.LinearOutSlowInInterpolator in project UltimateRecyclerView by cymcsg.

the class SliderHeader method initSlider.

private View initSlider(UltimateRecyclerView listview) {
    final View view = LayoutInflater.from(getApplication()).inflate(R.layout.list_item_header, null, false);
    final ViewTreeObserver vto = listview.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
        @Override
        public void onGlobalLayout() {
            view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            // Log.d("vto", "globallayout");
            final SliderLayout sl = (SliderLayout) view.findViewById(R.id.header_slider);
            try {
                sl.setOffscreenPageLimit(1);
                sl.setSliderTransformDuration(500, new LinearOutSlowInInterpolator());
                sl.setPresetTransformer(TransformerL.Default);
                sl.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
                sl.getPagerIndicator().setDefaultIndicatorColor(R.color.accent, R.color.primaryDark);
                sl.getPagerIndicator().setVisibility(View.GONE);
                setup_double_faces(sl);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    return view;
}
Also used : SliderLayout(com.hkm.slider.SliderLayout) LinearOutSlowInInterpolator(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) BaseSliderView(com.hkm.slider.SliderTypes.BaseSliderView) TextSliderView(com.hkm.slider.SliderTypes.TextSliderView) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver) TargetApi(android.annotation.TargetApi)

Example 12 with LinearOutSlowInInterpolator

use of androidx.interpolator.view.animation.LinearOutSlowInInterpolator in project Slide by ccrama.

the class NewsView method clearSeenPosts.

public List<Submission> clearSeenPosts(boolean forever) {
    if (adapter.dataSet.posts != null) {
        List<Submission> originalDataSetPosts = adapter.dataSet.posts;
        OfflineSubreddit o = OfflineSubreddit.getSubreddit(id.toLowerCase(Locale.ENGLISH), false, getActivity());
        for (int i = adapter.dataSet.posts.size(); i > -1; i--) {
            try {
                if (HasSeen.getSeen(adapter.dataSet.posts.get(i))) {
                    if (forever) {
                        Hidden.setHidden(adapter.dataSet.posts.get(i));
                    }
                    o.clearPost(adapter.dataSet.posts.get(i));
                    adapter.dataSet.posts.remove(i);
                    if (adapter.dataSet.posts.isEmpty()) {
                        adapter.notifyDataSetChanged();
                    } else {
                        rv.setItemAnimator(new AlphaInAnimator());
                        adapter.notifyItemRemoved(i + 1);
                    }
                }
            } catch (IndexOutOfBoundsException e) {
            // Let the loop reset itself
            }
        }
        adapter.notifyItemRangeChanged(0, adapter.dataSet.posts.size());
        o.writeToMemoryNoStorage();
        rv.setItemAnimator(new SlideUpAlphaAnimator().withInterpolator(new LinearOutSlowInInterpolator()));
        return originalDataSetPosts;
    }
    return null;
}
Also used : AlphaInAnimator(com.mikepenz.itemanimators.AlphaInAnimator) LinearOutSlowInInterpolator(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) Submission(net.dean.jraw.models.Submission) OfflineSubreddit(me.ccrama.redditslide.OfflineSubreddit) SlideUpAlphaAnimator(com.mikepenz.itemanimators.SlideUpAlphaAnimator)

Example 13 with LinearOutSlowInInterpolator

use of androidx.interpolator.view.animation.LinearOutSlowInInterpolator in project Slide by ccrama.

the class NewsView method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), new ColorPreferences(inflater.getContext()).getThemeSubreddit(id));
    final View v = LayoutInflater.from(contextThemeWrapper).inflate(R.layout.fragment_verticalcontent, container, false);
    if (getActivity() instanceof MainActivity) {
        v.findViewById(R.id.back).setBackgroundResource(0);
    }
    rv = v.findViewById(R.id.vertical_content);
    rv.setHasFixedSize(true);
    final RecyclerView.LayoutManager mLayoutManager = createLayoutManager(LayoutUtils.getNumColumns(getResources().getConfiguration().orientation, getActivity()));
    if (!(getActivity() instanceof SubredditView)) {
        v.findViewById(R.id.back).setBackground(null);
    }
    rv.setLayoutManager(mLayoutManager);
    rv.setItemAnimator(new SlideUpAlphaAnimator().withInterpolator(new LinearOutSlowInInterpolator()));
    rv.getLayoutManager().scrollToPosition(0);
    mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors(id, getContext()));
    /**
     * If using List view mode, we need to remove the start margin from the SwipeRefreshLayout.
     * The scrollbar style of "outsideInset" creates a 4dp padding around it. To counter this,
     * change the scrollbar style to "insideOverlay" when list view is enabled.
     * To recap: this removes the margins from the start/end so list view is full-width.
     */
    if (SettingValues.defaultCardView == CreateCardView.CardEnum.LIST) {
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        MarginLayoutParamsCompat.setMarginStart(params, 0);
        rv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        mSwipeRefreshLayout.setLayoutParams(params);
    }
    /**
     * If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned.
     * So, we estimate the height of the header in dp.
     * If the view type is "single" (and therefore "commentPager"), we need a different offset
     */
    final int HEADER_OFFSET = (SettingValues.single || getActivity() instanceof SubredditView) ? Constants.SINGLE_HEADER_VIEW_OFFSET : Constants.TAB_HEADER_VIEW_OFFSET;
    mSwipeRefreshLayout.setProgressViewOffset(false, HEADER_OFFSET - Constants.PTR_OFFSET_TOP, HEADER_OFFSET + Constants.PTR_OFFSET_BOTTOM);
    if (SettingValues.fab) {
        fab = v.findViewById(R.id.post_floating_action_button);
        if (SettingValues.fabType == Constants.FAB_POST) {
            fab.setImageResource(R.drawable.ic_add);
            fab.setContentDescription(getString(R.string.btn_fab_post));
            fab.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent inte = new Intent(getActivity(), Submit.class);
                    inte.putExtra(Submit.EXTRA_SUBREDDIT, id);
                    getActivity().startActivity(inte);
                }
            });
        } else {
            fab.setImageResource(R.drawable.ic_visibility_off);
            fab.setContentDescription(getString(R.string.btn_fab_hide));
            fab.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (!Reddit.fabClear) {
                        new AlertDialog.Builder(getActivity()).setTitle(R.string.settings_fabclear).setMessage(R.string.settings_fabclear_msg).setPositiveButton(R.string.btn_ok, (dialog, which) -> {
                            Reddit.colors.edit().putBoolean(SettingValues.PREF_FAB_CLEAR, true).apply();
                            Reddit.fabClear = true;
                            clearSeenPosts(false);
                        }).show();
                    } else {
                        clearSeenPosts(false);
                    }
                }
            });
            final Handler handler = new Handler();
            fab.setOnTouchListener(new View.OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    detector.onTouchEvent(event);
                    if (event.getAction() == MotionEvent.ACTION_DOWN) {
                        origY = event.getY();
                        handler.postDelayed(mLongPressRunnable, android.view.ViewConfiguration.getLongPressTimeout());
                    }
                    if (((event.getAction() == MotionEvent.ACTION_MOVE) && Math.abs(event.getY() - origY) > fab.getHeight() / 2.0f) || (event.getAction() == MotionEvent.ACTION_UP)) {
                        handler.removeCallbacks(mLongPressRunnable);
                    }
                    return false;
                }
            });
            mLongPressRunnable = new Runnable() {

                public void run() {
                    fab.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                    if (!Reddit.fabClear) {
                        new AlertDialog.Builder(getActivity()).setTitle(R.string.settings_fabclear).setMessage(R.string.settings_fabclear_msg).setPositiveButton(R.string.btn_ok, (dialog, which) -> {
                            Reddit.colors.edit().putBoolean(SettingValues.PREF_FAB_CLEAR, true).apply();
                            Reddit.fabClear = true;
                            clearSeenPosts(true);
                        }).show();
                    } else {
                        clearSeenPosts(true);
                    }
                    Snackbar s = Snackbar.make(rv, getResources().getString(R.string.posts_hidden_forever), Snackbar.LENGTH_LONG);
                    /*Todo a way to unhide
                        s.setAction(R.string.btn_undo, new View.OnClickListener() {

                            @Override
                            public void onClick(View v) {

                            }
                        });*/
                    LayoutUtils.showSnackbar(s);
                }
            };
        }
    } else {
        v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE);
    }
    if (fab != null)
        fab.show();
    header = getActivity().findViewById(R.id.header);
    // TODO, have it so that if the user clicks anywhere in the rv to hide and cancel GoToSubreddit?
    // final TextInputEditText GO_TO_SUB_FIELD = (TextInputEditText) getActivity().findViewById(R.id.toolbar_search);
    // final Toolbar TOOLBAR = ((Toolbar) getActivity().findViewById(R.id.toolbar));
    // final String PREV_TITLE = TOOLBAR.getTitle().toString();
    // final ImageView CLOSE_BUTTON = (ImageView) getActivity().findViewById(R.id.close);
    // 
    // rv.setOnTouchListener(new View.OnTouchListener() {
    // @Override
    // public boolean onTouch(View v, MotionEvent event) {
    // System.out.println("touched");
    // KeyboardUtil.hideKeyboard(getActivity(), v.getWindowToken(), 0);
    // 
    // GO_TO_SUB_FIELD.setText("");
    // GO_TO_SUB_FIELD.setVisibility(View.GONE);
    // CLOSE_BUTTON.setVisibility(View.GONE);
    // TOOLBAR.setTitle(PREV_TITLE);
    // 
    // return false;
    // }
    // });
    resetScroll();
    Reddit.isLoading = false;
    if (MainActivity.shouldLoad == null || id == null || (MainActivity.shouldLoad != null && MainActivity.shouldLoad.equals(id)) || !(getActivity() instanceof MainActivity)) {
        doAdapter();
    }
    return v;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) SubredditView(me.ccrama.redditslide.Activities.SubredditView) MainActivity(me.ccrama.redditslide.Activities.MainActivity) SlideUpAlphaAnimator(com.mikepenz.itemanimators.SlideUpAlphaAnimator) LinearOutSlowInInterpolator(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) Context(android.content.Context) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Handler(android.os.Handler) ToolbarScrollHideHandler(me.ccrama.redditslide.handler.ToolbarScrollHideHandler) Intent(android.content.Intent) SubredditView(me.ccrama.redditslide.Activities.SubredditView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CreateCardView(me.ccrama.redditslide.Views.CreateCardView) MotionEvent(android.view.MotionEvent) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) RelativeLayout(android.widget.RelativeLayout) Submit(me.ccrama.redditslide.Activities.Submit) RecyclerView(androidx.recyclerview.widget.RecyclerView) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 14 with LinearOutSlowInInterpolator

use of androidx.interpolator.view.animation.LinearOutSlowInInterpolator in project Slide by ccrama.

the class SubmissionsView method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), new ColorPreferences(inflater.getContext()).getThemeSubreddit(id));
    final View v = LayoutInflater.from(contextThemeWrapper).inflate(R.layout.fragment_verticalcontent, container, false);
    if (getActivity() instanceof MainActivity) {
        v.findViewById(R.id.back).setBackgroundResource(0);
    }
    rv = v.findViewById(R.id.vertical_content);
    rv.setHasFixedSize(true);
    final RecyclerView.LayoutManager mLayoutManager = createLayoutManager(LayoutUtils.getNumColumns(getResources().getConfiguration().orientation, getActivity()));
    if (!(getActivity() instanceof SubredditView)) {
        v.findViewById(R.id.back).setBackground(null);
    }
    rv.setLayoutManager(mLayoutManager);
    rv.setItemAnimator(new SlideUpAlphaAnimator().withInterpolator(new LinearOutSlowInInterpolator()));
    rv.getLayoutManager().scrollToPosition(0);
    mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors(id, getContext()));
    /**
     * If using List view mode, we need to remove the start margin from the SwipeRefreshLayout.
     * The scrollbar style of "outsideInset" creates a 4dp padding around it. To counter this,
     * change the scrollbar style to "insideOverlay" when list view is enabled.
     * To recap: this removes the margins from the start/end so list view is full-width.
     */
    if (SettingValues.defaultCardView == CreateCardView.CardEnum.LIST) {
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        MarginLayoutParamsCompat.setMarginStart(params, 0);
        rv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        mSwipeRefreshLayout.setLayoutParams(params);
    }
    /**
     * If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned.
     * So, we estimate the height of the header in dp.
     * If the view type is "single" (and therefore "commentPager"), we need a different offset
     */
    final int HEADER_OFFSET = (SettingValues.single || getActivity() instanceof SubredditView) ? Constants.SINGLE_HEADER_VIEW_OFFSET : Constants.TAB_HEADER_VIEW_OFFSET;
    mSwipeRefreshLayout.setProgressViewOffset(false, HEADER_OFFSET - Constants.PTR_OFFSET_TOP, HEADER_OFFSET + Constants.PTR_OFFSET_BOTTOM);
    if (SettingValues.fab) {
        fab = v.findViewById(R.id.post_floating_action_button);
        if (SettingValues.fabType == Constants.FAB_POST) {
            fab.setImageResource(R.drawable.ic_add);
            fab.setContentDescription(getString(R.string.btn_fab_post));
            fab.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent inte = new Intent(getActivity(), Submit.class);
                    inte.putExtra(Submit.EXTRA_SUBREDDIT, id);
                    getActivity().startActivity(inte);
                }
            });
        } else if (SettingValues.fabType == Constants.FAB_SEARCH) {
            fab.setImageResource(R.drawable.ic_search);
            fab.setContentDescription(getString(R.string.btn_fab_search));
            fab.setOnClickListener(new View.OnClickListener() {

                String term;

                @Override
                public void onClick(View v) {
                    MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()).title(R.string.search_title).alwaysCallInputCallback().input(getString(R.string.search_msg), "", new MaterialDialog.InputCallback() {

                        @Override
                        public void onInput(MaterialDialog materialDialog, CharSequence charSequence) {
                            term = charSequence.toString();
                        }
                    });
                    // Add "search current sub" if it is not frontpage/all/random
                    if (!id.equalsIgnoreCase("frontpage") && !id.equalsIgnoreCase("all") && !id.contains(".") && !id.contains("/m/") && !id.equalsIgnoreCase("friends") && !id.equalsIgnoreCase("random") && !id.equalsIgnoreCase("popular") && !id.equalsIgnoreCase("myrandom") && !id.equalsIgnoreCase("randnsfw")) {
                        builder.positiveText(getString(R.string.search_subreddit, id)).onPositive(new MaterialDialog.SingleButtonCallback() {

                            @Override
                            public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
                                Intent i = new Intent(getActivity(), Search.class);
                                i.putExtra(Search.EXTRA_TERM, term);
                                i.putExtra(Search.EXTRA_SUBREDDIT, id);
                                startActivity(i);
                            }
                        });
                        builder.neutralText(R.string.search_all).onNeutral(new MaterialDialog.SingleButtonCallback() {

                            @Override
                            public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
                                Intent i = new Intent(getActivity(), Search.class);
                                i.putExtra(Search.EXTRA_TERM, term);
                                startActivity(i);
                            }
                        });
                    } else {
                        builder.positiveText(R.string.search_all).onPositive(new MaterialDialog.SingleButtonCallback() {

                            @Override
                            public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
                                Intent i = new Intent(getActivity(), Search.class);
                                i.putExtra(Search.EXTRA_TERM, term);
                                startActivity(i);
                            }
                        });
                    }
                    builder.show();
                }
            });
        } else {
            fab.setImageResource(R.drawable.ic_visibility_off);
            fab.setContentDescription(getString(R.string.btn_fab_hide));
            fab.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (!Reddit.fabClear) {
                        new AlertDialog.Builder(getActivity()).setTitle(R.string.settings_fabclear).setMessage(R.string.settings_fabclear_msg).setPositiveButton(R.string.btn_ok, (dialog, which) -> {
                            Reddit.colors.edit().putBoolean(SettingValues.PREF_FAB_CLEAR, true).apply();
                            Reddit.fabClear = true;
                            clearSeenPosts(false);
                        }).show();
                    } else {
                        clearSeenPosts(false);
                    }
                }
            });
            final Handler handler = new Handler();
            fab.setOnTouchListener(new View.OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    detector.onTouchEvent(event);
                    if (event.getAction() == MotionEvent.ACTION_DOWN) {
                        origY = event.getY();
                        handler.postDelayed(mLongPressRunnable, android.view.ViewConfiguration.getLongPressTimeout());
                    }
                    if (((event.getAction() == MotionEvent.ACTION_MOVE) && Math.abs(event.getY() - origY) > fab.getHeight() / 2.0f) || (event.getAction() == MotionEvent.ACTION_UP)) {
                        handler.removeCallbacks(mLongPressRunnable);
                    }
                    return false;
                }
            });
            mLongPressRunnable = new Runnable() {

                public void run() {
                    fab.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                    if (!Reddit.fabClear) {
                        new AlertDialog.Builder(getActivity()).setTitle(R.string.settings_fabclear).setMessage(R.string.settings_fabclear_msg).setPositiveButton(R.string.btn_ok, (dialog, which) -> {
                            Reddit.colors.edit().putBoolean(SettingValues.PREF_FAB_CLEAR, true).apply();
                            Reddit.fabClear = true;
                            clearSeenPosts(true);
                        }).show();
                    } else {
                        clearSeenPosts(true);
                    }
                    Snackbar s = Snackbar.make(rv, getResources().getString(R.string.posts_hidden_forever), Snackbar.LENGTH_LONG);
                    /*Todo a way to unhide
                        s.setAction(R.string.btn_undo, new View.OnClickListener() {

                            @Override
                            public void onClick(View v) {

                            }
                        });*/
                    LayoutUtils.showSnackbar(s);
                }
            };
        }
    } else {
        v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE);
    }
    if (fab != null)
        fab.show();
    header = getActivity().findViewById(R.id.header);
    // TODO, have it so that if the user clicks anywhere in the rv to hide and cancel GoToSubreddit?
    // final TextInputEditText GO_TO_SUB_FIELD = (TextInputEditText) getActivity().findViewById(R.id.toolbar_search);
    // final Toolbar TOOLBAR = ((Toolbar) getActivity().findViewById(R.id.toolbar));
    // final String PREV_TITLE = TOOLBAR.getTitle().toString();
    // final ImageView CLOSE_BUTTON = (ImageView) getActivity().findViewById(R.id.close);
    // 
    // rv.setOnTouchListener(new View.OnTouchListener() {
    // @Override
    // public boolean onTouch(View v, MotionEvent event) {
    // System.out.println("touched");
    // KeyboardUtil.hideKeyboard(getActivity(), v.getWindowToken(), 0);
    // 
    // GO_TO_SUB_FIELD.setText("");
    // GO_TO_SUB_FIELD.setVisibility(View.GONE);
    // CLOSE_BUTTON.setVisibility(View.GONE);
    // TOOLBAR.setTitle(PREV_TITLE);
    // 
    // return false;
    // }
    // });
    resetScroll();
    Reddit.isLoading = false;
    if (MainActivity.shouldLoad == null || id == null || (MainActivity.shouldLoad != null && MainActivity.shouldLoad.equals(id)) || !(getActivity() instanceof MainActivity)) {
        doAdapter();
    }
    return v;
}
Also used : Bundle(android.os.Bundle) R(me.ccrama.redditslide.R) NonNull(androidx.annotation.NonNull) MainActivity(me.ccrama.redditslide.Activities.MainActivity) Locale(java.util.Locale) Handler(android.os.Handler) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Fragment(androidx.fragment.app.Fragment) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SubredditPosts(me.ccrama.redditslide.Adapters.SubredditPosts) MarginLayoutParamsCompat(androidx.core.view.MarginLayoutParamsCompat) Palette(me.ccrama.redditslide.Visuals.Palette) ViewGroup(android.view.ViewGroup) CatchStaggeredGridLayoutManager(me.ccrama.redditslide.Views.CatchStaggeredGridLayoutManager) HapticFeedbackConstants(android.view.HapticFeedbackConstants) OfflineSubreddit(me.ccrama.redditslide.OfflineSubreddit) List(java.util.List) RelativeLayout(android.widget.RelativeLayout) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Snackbar(com.google.android.material.snackbar.Snackbar) LayoutUtils(me.ccrama.redditslide.util.LayoutUtils) Context(android.content.Context) LinearOutSlowInInterpolator(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) GestureDetector(android.view.GestureDetector) BaseActivity(me.ccrama.redditslide.Activities.BaseActivity) SettingValues(me.ccrama.redditslide.SettingValues) AlertDialog(androidx.appcompat.app.AlertDialog) HasSeen(me.ccrama.redditslide.HasSeen) Submission(net.dean.jraw.models.Submission) Intent(android.content.Intent) Constants(me.ccrama.redditslide.Constants) Hidden(me.ccrama.redditslide.Hidden) MotionEvent(android.view.MotionEvent) Search(me.ccrama.redditslide.Activities.Search) SubredditView(me.ccrama.redditslide.Activities.SubredditView) SubmissionAdapter(me.ccrama.redditslide.Adapters.SubmissionAdapter) AlphaInAnimator(com.mikepenz.itemanimators.AlphaInAnimator) LayoutInflater(android.view.LayoutInflater) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) Reddit(me.ccrama.redditslide.Reddit) DialogAction(com.afollestad.materialdialogs.DialogAction) Submit(me.ccrama.redditslide.Activities.Submit) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) ToolbarScrollHideHandler(me.ccrama.redditslide.handler.ToolbarScrollHideHandler) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) SubmissionDisplay(me.ccrama.redditslide.Adapters.SubmissionDisplay) SlideUpAlphaAnimator(com.mikepenz.itemanimators.SlideUpAlphaAnimator) Configuration(android.content.res.Configuration) CreateCardView(me.ccrama.redditslide.Views.CreateCardView) SubredditView(me.ccrama.redditslide.Activities.SubredditView) MainActivity(me.ccrama.redditslide.Activities.MainActivity) SlideUpAlphaAnimator(com.mikepenz.itemanimators.SlideUpAlphaAnimator) LinearOutSlowInInterpolator(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) Search(me.ccrama.redditslide.Activities.Search) Context(android.content.Context) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Handler(android.os.Handler) ToolbarScrollHideHandler(me.ccrama.redditslide.handler.ToolbarScrollHideHandler) Intent(android.content.Intent) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SubredditView(me.ccrama.redditslide.Activities.SubredditView) CreateCardView(me.ccrama.redditslide.Views.CreateCardView) MotionEvent(android.view.MotionEvent) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) DialogAction(com.afollestad.materialdialogs.DialogAction) RelativeLayout(android.widget.RelativeLayout) Submit(me.ccrama.redditslide.Activities.Submit) RecyclerView(androidx.recyclerview.widget.RecyclerView) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 15 with LinearOutSlowInInterpolator

use of androidx.interpolator.view.animation.LinearOutSlowInInterpolator in project Slide by ccrama.

the class SubmissionsView method clearSeenPosts.

public List<Submission> clearSeenPosts(boolean forever) {
    if (adapter.dataSet.posts != null) {
        List<Submission> originalDataSetPosts = adapter.dataSet.posts;
        OfflineSubreddit o = OfflineSubreddit.getSubreddit(id.toLowerCase(Locale.ENGLISH), false, getActivity());
        for (int i = adapter.dataSet.posts.size(); i > -1; i--) {
            try {
                if (HasSeen.getSeen(adapter.dataSet.posts.get(i))) {
                    if (forever) {
                        Hidden.setHidden(adapter.dataSet.posts.get(i));
                    }
                    o.clearPost(adapter.dataSet.posts.get(i));
                    adapter.dataSet.posts.remove(i);
                    if (adapter.dataSet.posts.isEmpty()) {
                        adapter.notifyDataSetChanged();
                    } else {
                        rv.setItemAnimator(new AlphaInAnimator());
                        adapter.notifyItemRemoved(i + 1);
                    }
                }
            } catch (IndexOutOfBoundsException e) {
            // Let the loop reset itself
            }
        }
        adapter.notifyItemRangeChanged(0, adapter.dataSet.posts.size());
        o.writeToMemoryNoStorage();
        rv.setItemAnimator(new SlideUpAlphaAnimator().withInterpolator(new LinearOutSlowInInterpolator()));
        return originalDataSetPosts;
    }
    return null;
}
Also used : AlphaInAnimator(com.mikepenz.itemanimators.AlphaInAnimator) LinearOutSlowInInterpolator(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) Submission(net.dean.jraw.models.Submission) OfflineSubreddit(me.ccrama.redditslide.OfflineSubreddit) SlideUpAlphaAnimator(com.mikepenz.itemanimators.SlideUpAlphaAnimator)

Aggregations

LinearOutSlowInInterpolator (androidx.interpolator.view.animation.LinearOutSlowInInterpolator)16 View (android.view.View)8 SlideUpAlphaAnimator (com.mikepenz.itemanimators.SlideUpAlphaAnimator)7 AlphaInAnimator (com.mikepenz.itemanimators.AlphaInAnimator)5 OfflineSubreddit (me.ccrama.redditslide.OfflineSubreddit)5 Submission (net.dean.jraw.models.Submission)5 ViewGroup (android.view.ViewGroup)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 Context (android.content.Context)3 Intent (android.content.Intent)3 RelativeLayout (android.widget.RelativeLayout)3 AlertDialog (androidx.appcompat.app.AlertDialog)3 ContextThemeWrapper (androidx.appcompat.view.ContextThemeWrapper)3 ProgressView (carbon.widget.ProgressView)3 Snackbar (com.google.android.material.snackbar.Snackbar)3 Submit (me.ccrama.redditslide.Activities.Submit)3 ColorPreferences (me.ccrama.redditslide.Visuals.ColorPreferences)3 Animator (android.animation.Animator)2 ObjectAnimator (android.animation.ObjectAnimator)2 TargetApi (android.annotation.TargetApi)2