Search in sources :

Example 6 with DrawableItemDecoration

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

the class NotificationActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notifications);
    ButterKnife.bind(this);
    errorView.setRetryClickListener((v) -> beginUpdateList());
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.addItemDecoration(new DrawableItemDecoration(this, R.attr.list_separator_drawable));
    ItemTouchHelper.Callback touchCallback = new SwipeableItemTouchHelperCallback(this, ResourceUtil.getThemedAttributeId(this, R.attr.chart_shade5), R.drawable.ic_archive_white_24dp, ResourceUtil.getThemedAttributeId(this, R.attr.secondary_text_color));
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(touchCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
    swipeRefreshLayout.setOnRefreshListener(() -> {
        swipeRefreshLayout.setRefreshing(false);
        beginUpdateList();
    });
    beginUpdateList();
    NotificationSettingsActivity.promptEnablePollDialog(this);
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) SwipeableItemTouchHelperCallback(org.wikipedia.views.SwipeableItemTouchHelperCallback) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 7 with DrawableItemDecoration

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

the class ListCardView method initRecycler.

/**
 * Called by the constructor. Override to provide custom behavior but otherwise do not call
 *        directly.
 */
protected void initRecycler(@NonNull RecyclerView recyclerView) {
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.addItemDecoration(new DrawableItemDecoration(getContext(), R.attr.list_separator_drawable));
    recyclerView.setNestedScrollingEnabled(false);
}
Also used : DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 8 with DrawableItemDecoration

use of org.wikipedia.views.DrawableItemDecoration 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 9 with DrawableItemDecoration

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

the class MostReadFragment method initRecycler.

private void initRecycler() {
    mostReadLinks.setLayoutManager(new LinearLayoutManager(getContext()));
    mostReadLinks.addItemDecoration(new DrawableItemDecoration(requireContext(), R.attr.list_separator_drawable));
    mostReadLinks.setNestedScrollingEnabled(false);
}
Also used : DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 DrawableItemDecoration (org.wikipedia.views.DrawableItemDecoration)9 RecyclerView (android.support.v7.widget.RecyclerView)4 View (android.view.View)4 BindView (butterknife.BindView)4 SearchEmptyView (org.wikipedia.views.SearchEmptyView)4 Nullable (android.support.annotation.Nullable)3 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)3 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)3 TextView (android.widget.TextView)3 PageItemView (org.wikipedia.views.PageItemView)3 Rect (android.graphics.Rect)2 MarginItemDecoration (org.wikipedia.views.MarginItemDecoration)2 SwipeableItemTouchHelperCallback (org.wikipedia.views.SwipeableItemTouchHelperCallback)2 WikiErrorView (org.wikipedia.views.WikiErrorView)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 ShareCompat (android.support.v4.app.ShareCompat)1 PopupMenu (android.support.v7.widget.PopupMenu)1