Search in sources :

Example 1 with HeaderMarginItemDecoration

use of org.wikipedia.views.HeaderMarginItemDecoration in project apps-android-wikipedia by wikimedia.

the class FeedView method init.

private void init() {
    setVerticalScrollBarEnabled(true);
    recyclerLayoutManager = new StaggeredGridLayoutManager(getColumns(), StaggeredGridLayoutManager.VERTICAL);
    setItemAnimator(new FeedItemAnimator());
    setLayoutManager(recyclerLayoutManager);
    addItemDecoration(new MarginItemDecoration(getContext(), R.dimen.view_list_card_margin_horizontal, R.dimen.view_list_card_margin_vertical, R.dimen.view_list_card_margin_horizontal, R.dimen.view_list_card_margin_vertical));
    addItemDecoration(new HeaderMarginItemDecoration(getContext(), R.dimen.view_feed_padding_top, R.dimen.view_feed_search_padding_bottom));
    setCallback(new RecyclerViewColumnCallback());
    setClipChildren(false);
}
Also used : HeaderMarginItemDecoration(org.wikipedia.views.HeaderMarginItemDecoration) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) MarginItemDecoration(org.wikipedia.views.MarginItemDecoration) HeaderMarginItemDecoration(org.wikipedia.views.HeaderMarginItemDecoration)

Example 2 with HeaderMarginItemDecoration

use of org.wikipedia.views.HeaderMarginItemDecoration in project apps-android-wikipedia by wikimedia.

the class OnThisDayFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_on_this_day, container, false);
    AnimationUtil.setSharedElementTransitions(requireActivity());
    unbinder = ButterKnife.bind(this, view);
    int age = requireActivity().getIntent().getIntExtra(AGE, 0);
    wiki = requireActivity().getIntent().getParcelableExtra(WIKISITE);
    date = DateUtil.getDefaultDateFor(age);
    setUpToolbar();
    eventsRecycler.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
    final int topDecorationDp = 24;
    eventsRecycler.addItemDecoration(new HeaderMarginItemDecoration(topDecorationDp, 0));
    setUpRecycler(eventsRecycler);
    errorView.setBackClickListener(v -> requireActivity().finish());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && requireActivity().getWindow().getSharedElementEnterTransition() != null && savedInstanceState == null) {
        final int animDelay = 500;
        dayText.postDelayed(() -> {
            if (!isAdded() || dayText == null) {
                return;
            }
            updateContents(age);
            ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), dayText.getCurrentTextColor(), ResourceUtil.getThemedColor(requireContext(), R.attr.main_toolbar_title_color));
            colorAnimation.addUpdateListener(animator -> {
                if (dayText != null) {
                    dayText.setTextColor((Integer) animator.getAnimatedValue());
                }
            });
            colorAnimation.start();
        }, animDelay);
    } else {
        dayText.setTextColor(ResourceUtil.getThemedColor(requireContext(), R.attr.main_toolbar_title_color));
        updateContents(age);
    }
    eventsRecycler.setVisibility(View.GONE);
    errorView.setVisibility(View.GONE);
    return view;
}
Also used : HeaderMarginItemDecoration(org.wikipedia.views.HeaderMarginItemDecoration) ArgbEvaluator(android.animation.ArgbEvaluator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) WikiErrorView(org.wikipedia.views.WikiErrorView)

Example 3 with HeaderMarginItemDecoration

use of org.wikipedia.views.HeaderMarginItemDecoration in project apps-android-wikipedia by wikimedia.

the class EditTasksFragment method setUpRecyclerView.

private void setUpRecyclerView() {
    tasksRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
    final int topDecorationDp = 16;
    tasksRecyclerView.addItemDecoration(new HeaderMarginItemDecoration(topDecorationDp, 0));
    tasksRecyclerView.addItemDecoration(new FooterMarginItemDecoration(0, topDecorationDp));
    setUpTasks();
    RecyclerAdapter adapter = new RecyclerAdapter(tasks);
    tasksRecyclerView.setAdapter(adapter);
}
Also used : HeaderMarginItemDecoration(org.wikipedia.views.HeaderMarginItemDecoration) FooterMarginItemDecoration(org.wikipedia.views.FooterMarginItemDecoration) DefaultRecyclerAdapter(org.wikipedia.views.DefaultRecyclerAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

HeaderMarginItemDecoration (org.wikipedia.views.HeaderMarginItemDecoration)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 ArgbEvaluator (android.animation.ArgbEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 RecyclerView (android.support.v7.widget.RecyclerView)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 DefaultRecyclerAdapter (org.wikipedia.views.DefaultRecyclerAdapter)1 FooterMarginItemDecoration (org.wikipedia.views.FooterMarginItemDecoration)1 MarginItemDecoration (org.wikipedia.views.MarginItemDecoration)1 WikiErrorView (org.wikipedia.views.WikiErrorView)1