Search in sources :

Example 1 with MarginItemDecoration

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

the class OnThisDayCardView method initRecycler.

private void initRecycler() {
    pagesRecycler.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
    pagesRecycler.addItemDecoration(new MarginItemDecoration(getContext(), R.dimen.view_horizontal_scrolling_list_card_item_margin_horizontal, R.dimen.view_horizontal_scrolling_list_card_item_margin_vertical, R.dimen.view_horizontal_scrolling_list_card_item_margin_horizontal, R.dimen.view_horizontal_scrolling_list_card_item_margin_vertical));
    pagesRecycler.addOnItemTouchListener(new DontInterceptTouchListener());
    pagesRecycler.setNestedScrollingEnabled(false);
}
Also used : DontInterceptTouchListener(org.wikipedia.views.DontInterceptTouchListener) MarginItemDecoration(org.wikipedia.views.MarginItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 2 with MarginItemDecoration

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

the class ReadingListFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_reading_list, container, false);
    unbinder = ButterKnife.bind(this, view);
    getAppCompatActivity().setSupportActionBar(toolbar);
    getAppCompatActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getAppCompatActivity().getSupportActionBar().setTitle("");
    DeviceUtil.updateStatusBarTheme(requireActivity(), toolbar, true);
    appBarLayout.addOnOffsetChangedListener(appBarListener);
    toolBarLayout.setCollapsedTitleTextColor(ResourceUtil.getThemedColor(requireContext(), R.attr.main_toolbar_icon_color));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        toolBarLayout.setStatusBarScrimColor(ResourceUtil.getThemedColor(requireContext(), R.attr.main_status_bar_color));
    }
    ItemTouchHelper.Callback touchCallback = new SwipeableItemTouchHelperCallback(requireContext());
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(touchCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(adapter);
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    recyclerView.addItemDecoration(new DrawableItemDecoration(requireContext(), R.attr.list_separator_drawable, false));
    recyclerView.addItemDecoration(new MarginItemDecoration(0, 0, 0, DimenUtil.roundedDpToPx(DimenUtil.getDimension(R.dimen.floating_queue_container_height))) {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            if (parent.getChildAdapterPosition(view) == adapter.getItemCount() - 1 && floatingQueueView.getVisibility() == View.VISIBLE) {
                super.getItemOffsets(outRect, view, parent, state);
            }
        }
    });
    headerView = new ReadingListItemView(getContext());
    headerView.setCallback(headerCallback);
    headerView.setClickable(false);
    headerView.setThumbnailVisible(false);
    headerView.setTitleTextAppearance(R.style.ReadingListTitleTextAppearance);
    readingListId = getArguments().getLong(EXTRA_READING_LIST_ID);
    disposables.add(WikipediaApp.getInstance().getBus().subscribe(new EventBusConsumer()));
    floatingQueueView.setCallback(this);
    swipeRefreshLayout.setColorSchemeResources(getThemedAttributeId(requireContext(), R.attr.colorAccent));
    swipeRefreshLayout.setOnRefreshListener(() -> ReadingListsFragment.refreshSync(ReadingListFragment.this, swipeRefreshLayout));
    if (ReadingListSyncAdapter.isDisabledByRemoteConfig()) {
        swipeRefreshLayout.setEnabled(false);
    }
    appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> swipeRefreshLayout.setEnabled(verticalOffset == 0));
    return view;
}
Also used : Rect(android.graphics.Rect) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) MarginItemDecoration(org.wikipedia.views.MarginItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) FloatingQueueView(org.wikipedia.main.floatingqueue.FloatingQueueView) PageItemView(org.wikipedia.views.PageItemView) BindView(butterknife.BindView) View(android.view.View) SearchEmptyView(org.wikipedia.views.SearchEmptyView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) RecyclerView(android.support.v7.widget.RecyclerView) SwipeableItemTouchHelperCallback(org.wikipedia.views.SwipeableItemTouchHelperCallback) Nullable(android.support.annotation.Nullable)

Example 3 with MarginItemDecoration

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

the class HorizontalScrollingListCardView method initRecycler.

@Override
protected void initRecycler(@NonNull RecyclerView recyclerView) {
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
    recyclerView.addItemDecoration(new MarginItemDecoration(getContext(), R.dimen.view_horizontal_scrolling_list_card_item_margin_horizontal, R.dimen.view_horizontal_scrolling_list_card_item_margin_vertical, R.dimen.view_horizontal_scrolling_list_card_item_margin_horizontal, R.dimen.view_horizontal_scrolling_list_card_item_margin_vertical));
    recyclerView.addOnItemTouchListener(new DontInterceptTouchListener());
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.setClipToPadding(false);
    MarginLayoutParams params = (MarginLayoutParams) recyclerView.getLayoutParams();
    final int height = DimenUtil.roundedDpToPx(228);
    params.height = height;
    final int padding = DimenUtil.roundedDpToPx(12);
    recyclerView.setPadding(padding, 0, padding, 0);
}
Also used : DontInterceptTouchListener(org.wikipedia.views.DontInterceptTouchListener) MarginItemDecoration(org.wikipedia.views.MarginItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 4 with MarginItemDecoration

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

the class ReadingListsFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_reading_lists, container, false);
    unbinder = ButterKnife.bind(this, view);
    searchEmptyView.setEmptyText(R.string.search_reading_lists_no_results);
    readingListView.setLayoutManager(new LinearLayoutManager(getContext()));
    readingListView.setAdapter(adapter);
    readingListView.addItemDecoration(new DrawableItemDecoration(requireContext(), R.attr.list_separator_drawable, false));
    readingListView.addItemDecoration(new MarginItemDecoration(0, 0, 0, DimenUtil.roundedDpToPx(DimenUtil.getDimension(R.dimen.floating_queue_container_height))) {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            if (parent.getChildAdapterPosition(view) == adapter.getItemCount() - 1 && ((MainActivity) requireActivity()).isFloatingQueueEnabled() && readingLists.size() > 1) {
                super.getItemOffsets(outRect, view, parent, state);
            }
        }
    });
    disposables.add(WikipediaApp.getInstance().getBus().subscribe(new EventBusConsumer()));
    contentContainer.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
    emptyContainer.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
    ((ViewGroup) emptyContainer.getChildAt(0)).getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
    swipeRefreshLayout.setColorSchemeResources(getThemedAttributeId(requireContext(), R.attr.colorAccent));
    swipeRefreshLayout.setOnRefreshListener(() -> refreshSync(ReadingListsFragment.this, swipeRefreshLayout));
    if (ReadingListSyncAdapter.isDisabledByRemoteConfig()) {
        swipeRefreshLayout.setEnabled(false);
    }
    return view;
}
Also used : Rect(android.graphics.Rect) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) RecyclerView(android.support.v7.widget.RecyclerView) MarginItemDecoration(org.wikipedia.views.MarginItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) SearchEmptyView(org.wikipedia.views.SearchEmptyView) TextView(android.widget.TextView) ReadingListsOverflowView(org.wikipedia.views.ReadingListsOverflowView) RecyclerView(android.support.v7.widget.RecyclerView) OnboardingView(org.wikipedia.onboarding.OnboardingView)

Example 5 with MarginItemDecoration

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

the class HistoryFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_history, container, false);
    unbinder = ButterKnife.bind(this, view);
    searchEmptyView.setEmptyText(R.string.search_history_no_results);
    ItemTouchHelper.Callback touchCallback = new SwipeableItemTouchHelperCallback(requireContext());
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(touchCallback);
    itemTouchHelper.attachToRecyclerView(historyList);
    historyList.setLayoutManager(new LinearLayoutManager(getContext()));
    historyList.setAdapter(adapter);
    historyList.addItemDecoration(new MarginItemDecoration(0, 0, 0, DimenUtil.roundedDpToPx(DimenUtil.getDimension(R.dimen.floating_queue_container_height))) {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            if (parent.getChildAdapterPosition(view) == adapter.getItemCount() - 1 && ((MainActivity) requireActivity()).isFloatingQueueEnabled()) {
                super.getItemOffsets(outRect, view, parent, state);
            }
        }
    });
    requireActivity().getSupportLoaderManager().initLoader(HISTORY_FRAGMENT_LOADER_ID, null, loaderCallback);
    return view;
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView) SwipeableItemTouchHelperCallback(org.wikipedia.views.SwipeableItemTouchHelperCallback) MarginItemDecoration(org.wikipedia.views.MarginItemDecoration) MainActivity(org.wikipedia.main.MainActivity) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) PageItemView(org.wikipedia.views.PageItemView) BindView(butterknife.BindView) View(android.view.View) SearchEmptyView(org.wikipedia.views.SearchEmptyView) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

MarginItemDecoration (org.wikipedia.views.MarginItemDecoration)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 Rect (android.graphics.Rect)3 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 BindView (butterknife.BindView)3 DontInterceptTouchListener (org.wikipedia.views.DontInterceptTouchListener)3 SearchEmptyView (org.wikipedia.views.SearchEmptyView)3 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)2 TextView (android.widget.TextView)2 DrawableItemDecoration (org.wikipedia.views.DrawableItemDecoration)2 HeaderMarginItemDecoration (org.wikipedia.views.HeaderMarginItemDecoration)2 PageItemView (org.wikipedia.views.PageItemView)2 SwipeableItemTouchHelperCallback (org.wikipedia.views.SwipeableItemTouchHelperCallback)2 Nullable (android.support.annotation.Nullable)1 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 MainActivity (org.wikipedia.main.MainActivity)1 FloatingQueueView (org.wikipedia.main.floatingqueue.FloatingQueueView)1 OnboardingView (org.wikipedia.onboarding.OnboardingView)1