本文整理了Java中android.support.v7.widget.helper.ItemTouchHelper
类的一些代码示例,展示了ItemTouchHelper
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemTouchHelper
类的具体详情如下:
包路径:android.support.v7.widget.helper.ItemTouchHelper
类名称:ItemTouchHelper
暂无
代码示例来源:origin: EverythingMe/overscroll-decor
protected void setUpTouchHelperCallback(final ItemTouchHelper.Callback itemTouchHelperCallback) {
new ItemTouchHelper(new ItemTouchHelperCallbackWrapper(itemTouchHelperCallback) {
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
mIsItemTouchInEffect = actionState != 0;
super.onSelectedChanged(viewHolder, actionState);
}
}).attachToRecyclerView(mRecyclerView);
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void drag(LocalItem selectedItem, RecyclerView.ViewHolder viewHolder) {
if (itemTouchHelper != null) itemTouchHelper.startDrag(viewHolder);
}
});
代码示例来源:origin: mcxtzhang/ZLayoutManager
@Override
public void onClick(View v) {
//mRv.setLayoutManager(new OverLayCardLayoutManager();
itemTouchHelper.attachToRecyclerView(mRv);
}
});
代码示例来源:origin: hidroh/materialistic
mItemTouchHelper = new ItemTouchHelper(mCallback);
代码示例来源:origin: hidroh/materialistic
@Override
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
super.onDetachedFromRecyclerView(recyclerView);
mItemTouchHelper.attachToRecyclerView(null);
}
代码示例来源:origin: hidroh/materialistic
public FavoriteRecyclerViewAdapter(Context context, ActionModeDelegate actionModeDelegate) {
super(context);
mActionModeDelegate = actionModeDelegate;
mMenuTintDelegate = new MenuTintDelegate();
mMenuTintDelegate.onActivityCreated(mContext);
mItemTouchHelper = new ItemTouchHelper(new ItemTouchHelperCallback(mContext) {
@Override
public int getSwipeDirs(RecyclerView recyclerView,
RecyclerView.ViewHolder viewHolder) {
if (mActionModeDelegate != null && mActionModeDelegate.isInActionMode()) {
return 0;
}
return super.getSwipeDirs(recyclerView, viewHolder);
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
if (direction == ItemTouchHelper.LEFT) {
dismiss(viewHolder.itemView, viewHolder.getAdapterPosition());
} else {
Favorite item = getItem(viewHolder.getAdapterPosition());
if (item != null) {
mSyncScheduler.scheduleSync(mContext, item.getId());
}
notifyItemChanged(viewHolder.getAdapterPosition());
}
}
});
}
代码示例来源:origin: north2016/T-MVP
@Override
public void initView() {
adapter = new RecyclerListAdapter();
mViewBinding.recyclerview.setHasFixedSize(true);
mViewBinding.recyclerview.setAdapter(adapter);
mItemTouchHelper = new ItemTouchHelper(new SimpleItemTouchHelperCallback());
mItemTouchHelper.attachToRecyclerView(mViewBinding.recyclerview);
}
代码示例来源:origin: mcxtzhang/ZLayoutManager
@Override
public void onClick(View v) {
mRv.setLayoutManager(new FlowLayoutManager());//自己写的流式布局
itemTouchHelper.attachToRecyclerView(null);
}
});
代码示例来源:origin: mcxtzhang/ZLayoutManager
final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onStartDrag(PlayQueueItemHolder viewHolder) {
if (itemTouchHelper != null) itemTouchHelper.startDrag(viewHolder);
}
};
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onViewCreated(@NonNull View rootView, @Nullable Bundle savedInstanceState) {
super.onViewCreated(rootView, savedInstanceState);
initButton(rootView);
RecyclerView listSelectedTabs = rootView.findViewById(R.id.selectedTabs);
listSelectedTabs.setLayoutManager(new LinearLayoutManager(requireContext()));
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(getItemTouchCallback());
itemTouchHelper.attachToRecyclerView(listSelectedTabs);
selectedTabsAdapter = new SelectedTabsAdapter(requireContext(), itemTouchHelper);
listSelectedTabs.setAdapter(selectedTabsAdapter);
}
代码示例来源:origin: hidroh/materialistic
@Override
public void onAttachedToRecyclerView(final RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
mItemTouchHelper.attachToRecyclerView(recyclerView);
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onStartDrag(PlayQueueItemHolder viewHolder) {
if (itemTouchHelper != null) itemTouchHelper.startDrag(viewHolder);
}
};
代码示例来源:origin: TeamNewPipe/NewPipe
private void buildQueue() {
itemsList.setAdapter(playQueueAdapter);
itemsList.setClickable(true);
itemsList.setLongClickable(true);
itemsList.clearOnScrollListeners();
itemsList.addOnScrollListener(getQueueScrollListener());
itemTouchHelper = new ItemTouchHelper(getItemTouchCallback());
itemTouchHelper.attachToRecyclerView(itemsList);
playQueueAdapter.setSelectedListener(getOnSelectedListener());
itemsListCloseButton.setOnClickListener(view -> onQueueClosed());
}
代码示例来源:origin: hidroh/materialistic
@Override
public void detach(Context context, RecyclerView recyclerView) {
super.detach(context, recyclerView);
recyclerView.removeOnScrollListener(mScrollListener);
mColors.recycle();
mItemTouchHelper.attachToRecyclerView(null);
}
代码示例来源:origin: Rukey7/MvpApp
@Override
public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
itemTouchHelper.startDrag(viewHolder);
}
});
代码示例来源:origin: jaydenxiao2016/AndroidFire
@Override
public void returnMineNewsChannels(List<NewsChannelTable> newsChannelsMine) {
channelAdapterMine = new ChannelAdapter(mContext,R.layout.item_news_channel);
newsChannelMineRv.setLayoutManager(new GridLayoutManager(this, 4, LinearLayoutManager.VERTICAL, false));
newsChannelMineRv.setItemAnimator(new DefaultItemAnimator());
newsChannelMineRv.setAdapter(channelAdapterMine);
channelAdapterMine.replaceAll(newsChannelsMine);
channelAdapterMine.setOnItemClickListener(new ChannelAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
NewsChannelTable newsChannel = channelAdapterMine.get(position);
channelAdapterMore.add(newsChannel);
channelAdapterMine.removeAt(position);
mPresenter.onItemAddOrRemove((ArrayList<NewsChannelTable>) channelAdapterMine.getAll(), (ArrayList<NewsChannelTable>)channelAdapterMore.getAll());
}
});
ItemDragHelperCallback itemDragHelperCallback = new ItemDragHelperCallback(channelAdapterMine);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemDragHelperCallback);
itemTouchHelper.attachToRecyclerView(newsChannelMineRv);
channelAdapterMine.setItemDragHelperCallback(itemDragHelperCallback);
}
代码示例来源:origin: hidroh/materialistic
@Override
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
super.onDetachedFromRecyclerView(recyclerView);
MaterialisticDatabase.getInstance(recyclerView.getContext()).getLiveData().removeObserver(mObserver);
mItemTouchHelper.attachToRecyclerView(null);
mPrefObservable.unsubscribe(recyclerView.getContext());
}
代码示例来源:origin: TeamNewPipe/NewPipe
@SuppressLint("ClickableViewAccessibility")
private View.OnTouchListener getOnTouchListener(final RecyclerView.ViewHolder item) {
return (view, motionEvent) -> {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
if (itemTouchHelper != null && getItemCount() > 1) {
itemTouchHelper.startDrag(item);
return true;
}
}
return false;
};
}
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
protected void initListeners() {
super.initListeners();
headerTitleView.setOnClickListener(view -> createRenameDialog());
itemTouchHelper = new ItemTouchHelper(getItemTouchCallback());
itemTouchHelper.attachToRecyclerView(itemsList);
itemListAdapter.setSelectedListener(new OnClickGesture<LocalItem>() {
@Override
public void selected(LocalItem selectedItem) {
if (selectedItem instanceof PlaylistStreamEntry) {
final PlaylistStreamEntry item = (PlaylistStreamEntry) selectedItem;
NavigationHelper.openVideoDetailFragment(getFragmentManager(),
item.serviceId, item.url, item.title);
}
}
@Override
public void held(LocalItem selectedItem) {
if (selectedItem instanceof PlaylistStreamEntry) {
showStreamItemDialog((PlaylistStreamEntry) selectedItem);
}
}
@Override
public void drag(LocalItem selectedItem, RecyclerView.ViewHolder viewHolder) {
if (itemTouchHelper != null) itemTouchHelper.startDrag(viewHolder);
}
});
}
内容来源于网络,如有侵权,请联系作者删除!