use of androidx.recyclerview.widget.ItemTouchHelper in project materialistic by hidroh.
the class SinglePageItemRecyclerViewAdapter method attach.
@Override
public void attach(Context context, RecyclerView recyclerView) {
super.attach(context, recyclerView);
mLevelIndicatorWidth = AppUtils.getDimensionInDp(mContext, R.dimen.level_indicator_width);
mColors = mResourcesProvider.obtainTypedArray(R.array.color_codes);
mItemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
Item item = getItem(viewHolder.getAdapterPosition());
if (item == null || item.getKidCount() == 0) {
return 0;
}
return super.getSwipeDirs(recyclerView, viewHolder);
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
int position = viewHolder.getAdapterPosition();
Item item = getItem(position);
if (item != null) {
notifyItemChanged(position);
toggleKids(item);
}
}
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
float swipeWidth = viewHolder.itemView.getWidth() * getSwipeThreshold(viewHolder);
dX = Math.max(dX, -swipeWidth);
dX = Math.min(dX, swipeWidth);
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
@Override
public float getSwipeThreshold(RecyclerView.ViewHolder viewHolder) {
return 0.1f;
}
});
mItemTouchHelper.attachToRecyclerView(recyclerView);
recyclerView.addOnScrollListener(mScrollListener);
}
use of androidx.recyclerview.widget.ItemTouchHelper in project kdeconnect-android by KDE.
the class CustomDevicesAdapter method onAttachedToRecyclerView.
@Override
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelperCallback(adapterPos -> callback.onCustomDeviceDismissed(customDevices.get(adapterPos))));
itemTouchHelper.attachToRecyclerView(recyclerView);
}
use of androidx.recyclerview.widget.ItemTouchHelper in project iterable-android-sdk by Iterable.
the class IterableInboxFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
IterableLogger.printInfo();
Bundle arguments = getArguments();
if (arguments != null) {
if (arguments.get(INBOX_MODE) instanceof InboxMode) {
inboxMode = (InboxMode) arguments.get(INBOX_MODE);
}
if (arguments.getInt(ITEM_LAYOUT_ID, 0) != 0) {
itemLayoutId = arguments.getInt(ITEM_LAYOUT_ID);
}
if (arguments.getString(IterableConstants.NO_MESSAGES_TITLE) != null) {
noMessagesTitle = arguments.getString(IterableConstants.NO_MESSAGES_TITLE);
}
if (arguments.getString(IterableConstants.NO_MESSAGES_BODY) != null) {
noMessagesBody = arguments.getString(IterableConstants.NO_MESSAGES_BODY);
}
}
RelativeLayout relativeLayout = (RelativeLayout) inflater.inflate(R.layout.iterable_inbox_fragment, container, false);
recyclerView = relativeLayout.findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
IterableInboxAdapter adapter = new IterableInboxAdapter(IterableApi.getInstance().getInAppManager().getInboxMessages(), IterableInboxFragment.this, adapterExtension, comparator, filter, dateMapper);
recyclerView.setAdapter(adapter);
noMessagesTitleTextView = relativeLayout.findViewById(R.id.emptyInboxTitle);
noMessagesBodyTextView = relativeLayout.findViewById(R.id.emptyInboxMessage);
noMessagesTitleTextView.setText(noMessagesTitle);
noMessagesBodyTextView.setText(noMessagesBody);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new IterableInboxTouchHelper(getContext(), adapter));
itemTouchHelper.attachToRecyclerView(recyclerView);
return relativeLayout;
}
use of androidx.recyclerview.widget.ItemTouchHelper in project Signal-Android by signalapp.
the class StickerManagementActivity method initView.
private void initView() {
this.list = findViewById(R.id.sticker_management_list);
this.adapter = new StickerManagementAdapter(GlideApp.with(this), this, DeviceProperties.shouldAllowApngStickerAnimation(this));
list.setLayoutManager(new LinearLayoutManager(this));
list.setAdapter(adapter);
new ItemTouchHelper(new StickerManagementItemTouchHelper(new ItemTouchCallback())).attachToRecyclerView(list);
}
Aggregations