android.support.v7.widget.helper.ItemTouchHelper.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(12.4k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中android.support.v7.widget.helper.ItemTouchHelper.<init>()方法的一些代码示例,展示了ItemTouchHelper.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemTouchHelper.<init>()方法的具体详情如下:
包路径:android.support.v7.widget.helper.ItemTouchHelper
类名称:ItemTouchHelper
方法名:<init>

ItemTouchHelper.<init>介绍

暂无

代码示例

代码示例来源: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 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: 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: 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: 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: 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: iMeiji/Toutiao

private void initData() {
  final List<NewsChannelBean> enableItems = dao.query(Constant.NEWS_CHANNEL_ENABLE);
  final List<NewsChannelBean> disableItems = dao.query(Constant.NEWS_CHANNEL_DISABLE);
  GridLayoutManager manager = new GridLayoutManager(this, 4);
  recyclerView.setLayoutManager(manager);
  ItemDragHelperCallback callback = new ItemDragHelperCallback();
  final ItemTouchHelper helper = new ItemTouchHelper(callback);
  helper.attachToRecyclerView(recyclerView);
  adapter = new NewsChannelAdapter(this, helper, enableItems, disableItems);
  manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
    @Override
    public int getSpanSize(int position) {
      int viewType = adapter.getItemViewType(position);
      return viewType == NewsChannelAdapter.TYPE_MY || viewType == NewsChannelAdapter.TYPE_OTHER ? 1 : 4;
    }
  });
  recyclerView.setAdapter(adapter);
  adapter.setOnMyChannelItemClickListener((v, position) -> Toast.makeText(NewsChannelActivity.this, enableItems.get(position).getChannelName() + position, Toast.LENGTH_SHORT).show());
}

代码示例来源:origin: TeamNewPipe/NewPipe

private void buildQueue() {
  itemsList = findViewById(R.id.play_queue);
  itemsList.setLayoutManager(new LinearLayoutManager(this));
  itemsList.setAdapter(player.getPlayQueueAdapter());
  itemsList.setClickable(true);
  itemsList.setLongClickable(true);
  itemsList.clearOnScrollListeners();
  itemsList.addOnScrollListener(getQueueScrollListener());
  itemTouchHelper = new ItemTouchHelper(getItemTouchCallback());
  itemTouchHelper.attachToRecyclerView(itemsList);
  player.getPlayQueueAdapter().setSelectedListener(getOnSelectedListener());
}

代码示例来源:origin: google/ExoPlayer

@Override
public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 // Getting the cast context later than onStart can cause device discovery not to take place.
 try {
  castContext = CastContext.getSharedInstance(this);
 } catch (RuntimeException e) {
  Throwable cause = e.getCause();
  while (cause != null) {
   if (cause instanceof DynamiteModule.LoadingException) {
    setContentView(R.layout.cast_context_error_message_layout);
    return;
   }
   cause = cause.getCause();
  }
  // Unknown error. We propagate it.
  throw e;
 }
 setContentView(R.layout.main_activity);
 localPlayerView = findViewById(R.id.local_player_view);
 localPlayerView.requestFocus();
 castControlView = findViewById(R.id.cast_control_view);
 mediaQueueList = findViewById(R.id.sample_list);
 ItemTouchHelper helper = new ItemTouchHelper(new RecyclerViewCallback());
 helper.attachToRecyclerView(mediaQueueList);
 mediaQueueList.setLayoutManager(new LinearLayoutManager(this));
 mediaQueueList.setHasFixedSize(true);
 mediaQueueListAdapter = new MediaQueueListAdapter();
 findViewById(R.id.add_sample_button).setOnClickListener(this);
}

代码示例来源:origin: udacity/ud851-Exercises

new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
  @Override
  public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {

代码示例来源:origin: udacity/ud851-Exercises

new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
  @Override
  public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {

代码示例来源: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);
    }
  });
}

代码示例来源:origin: mcxtzhang/ZLayoutManager

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_swipe_card);
  mRv = (RecyclerView) findViewById(R.id.rv);
  mRv.setLayoutManager(new OverLayCardLayoutManager());
  mRv.setAdapter(mAdapter = new CommonAdapter<SwipeCardBean>(this, mDatas = SwipeCardBean.initDatas(), R.layout.item_swipe_card) {
    public static final String TAG = "zxt/Adapter";
    @Override
    public void convert(ViewHolder viewHolder, SwipeCardBean swipeCardBean) {
      Log.d(TAG, "convert() called with: viewHolder = [" + viewHolder + "], swipeCardBean = [" + swipeCardBean + "]");
      viewHolder.setText(R.id.tvName, swipeCardBean.getName());
      viewHolder.setText(R.id.tvPrecent, swipeCardBean.getPostition() + " /" + mDatas.size());
      Picasso.with(SwipeCardActivity.this).load(swipeCardBean.getUrl()).into((ImageView) viewHolder.getView(R.id.iv));
    }
  });
  //初始化配置
  CardConfig.initConfig(this);
  ItemTouchHelper.Callback callback = new RenRenCallback(mRv, mAdapter, mDatas);
  ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
  itemTouchHelper.attachToRecyclerView(mRv);
  findViewById(R.id.btnRefresh).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      mDatas.add(new SwipeCardBean(100, "http://news.k618.cn/tech/201604/W020160407281077548026.jpg", "增加的"));
      mAdapter.notifyDataSetChanged();
    }
  });
}

代码示例来源:origin: udacity/ud851-Exercises

new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
  @Override
  public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {

代码示例来源:origin: hidroh/materialistic

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

代码示例来源:origin: udacity/ud851-Exercises

new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
  @Override
  public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {

代码示例来源:origin: mcxtzhang/ZLayoutManager

final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(mRv);

代码示例来源:origin: Rukey7/MvpApp

/**
 * 启动拖拽和滑动
 * @param view 视图
 * @param adapter 适配器
 */
public static void startDragAndSwipe(RecyclerView view, BaseQuickAdapter adapter) {
  SimpleItemTouchHelperCallback callback = new SimpleItemTouchHelperCallback(adapter);
  final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
  itemTouchHelper.attachToRecyclerView(view);
  adapter.setDragStartListener(new OnStartDragListener() {
    @Override
    public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
      itemTouchHelper.startDrag(viewHolder);
    }
  });
  adapter.setDragCallback(callback);
  adapter.setDragColor(Color.LTGRAY);
}

代码示例来源:origin: liaoinstan/SpringView

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_demo8);
  Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  initData();
  springView = findViewById(R.id.springview);
  springView.setType(SpringView.Type.FOLLOW);
  springView.setListener(new SpringView.OnFreshListener() {
    @Override
    public void onRefresh() {
      new Handler().postDelayed(() -> springView.onFinishFreshAndLoad(), 1000);
    }
    @Override
    public void onLoadmore() {
      new Handler().postDelayed(() -> springView.onFinishFreshAndLoad(), 1000);
    }
  });
  springView.setHeader(new DefaultHeader(this));
  springView.setFooter(new DefaultFooter(this));
  RecyclerView recyclerView = findViewById(R.id.recycle);
  recyclerView.setHasFixedSize(true);
  RecyclerAdapter recyclerAdapter = new RecyclerAdapter(R.layout.item, mDatas);
  recyclerView.setAdapter(recyclerAdapter);
  recyclerView.setLayoutManager(new LinearLayoutManager(this));
  final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new MyItemTouchCallback(recyclerAdapter));
  itemTouchHelper.attachToRecyclerView(recyclerView);
}

代码示例来源:origin: jdsjlzx/LRecyclerView

mItemTouchHelper = new ItemTouchHelper(mCallback);
mItemTouchHelper.attachToRecyclerView(mRecyclerView);

相关文章