use of org.wikipedia.views.SwipeableItemTouchHelperCallback 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;
}
use of org.wikipedia.views.SwipeableItemTouchHelperCallback 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);
}
use of org.wikipedia.views.SwipeableItemTouchHelperCallback 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;
}
Aggregations