androidx.recyclerview.widget.ItemTouchHelper.<init>()方法的使用及代码示例

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

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

ItemTouchHelper.<init>介绍

暂无

代码示例

代码示例来源:origin: airbnb/epoxy

new ItemTouchHelper(new EpoxyModelTouchCallback<U>(controller, targetModelClass) {

代码示例来源:origin: airbnb/epoxy

new ItemTouchHelper(new EpoxyModelTouchCallback<U>(null, targetModelClass) {

代码示例来源:origin: guardianproject/haven

ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);

代码示例来源:origin: mikepenz/FastAdapter

touchHelper = new ItemTouchHelper(touchCallback); // Create ItemTouchHelper and pass with parameter the SimpleDragCallback

代码示例来源:origin: mikepenz/FastAdapter

.withLeaveBehindSwipeRight(leaveBehindDrawableRight);
touchHelper = new ItemTouchHelper(touchCallback); // Create ItemTouchHelper and pass with parameter the SimpleDragCallback

代码示例来源:origin: guardianproject/haven

ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleCallback);
itemTouchHelper.attachToRecyclerView(mRecyclerView);

代码示例来源:origin: lisawray/groupie

ItemTouchHelper itemTouchHelper = new ItemTouchHelper(touchCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);

代码示例来源:origin: nickbutcher/plaid

dataManager.loadAllDataSources();
ItemTouchHelper.Callback callback = new FilterTouchHelperCallback(filtersAdapter, this);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(filtersList);
checkEmptyState();

代码示例来源:origin: mikepenz/FastAdapter

touchHelper = new ItemTouchHelper(touchCallback); // Create ItemTouchHelper and pass with parameter the SimpleDragCallback

代码示例来源:origin: westnordost/StreetComplete

@Override public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView)
{
  super.onAttachedToRecyclerView(recyclerView);
  ItemTouchHelper ith = new ItemTouchHelper(new TouchHelperCallback());
  ith.attachToRecyclerView(recyclerView);
}

代码示例来源:origin: iTXTech/Daedalus

adapter = new DNSServerAdapter();
recyclerView.setAdapter(adapter);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() {
  @Override
  public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {

代码示例来源:origin: iTXTech/Daedalus

adapter = new RuleAdapter();
recyclerView.setAdapter(adapter);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() {
  @Override
  public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {

代码示例来源:origin: gotev/recycler-adapter

/**
 * Applies swipe gesture detection on a RecyclerView items.
 *
 * @param recyclerView recycler view o which to apply the swipe gesture
 * @param listener     listener called when a swipe is performed on one of the items
 */
public static void applySwipeGesture(RecyclerView recyclerView, final SwipeListener listener) {
  new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(
      0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
    @Override
    public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
               RecyclerView.ViewHolder target) {
      return false;
    }
    @Override
    public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
      listener.onItemSwiped(viewHolder.getAdapterPosition(), swipeDir);
    }
  }).attachToRecyclerView(recyclerView);
}

代码示例来源:origin: gotev/recycler-adapter

/**
 * Enables reordering of the list through drag and drop, which is activated when the user
 * long presses on an item.
 *
 * @param recyclerView recycler view on which to apply the drag and drop
 */
public void enableDragDrop(RecyclerView recyclerView) {
  ItemTouchHelper touchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() {
    @Override
    public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
      return makeFlag(ItemTouchHelper.ACTION_STATE_DRAG, DOWN | UP | START | END);
    }
    @Override
    public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
      int sourcePosition = viewHolder.getAdapterPosition();
      int targetPosition = target.getAdapterPosition();
      Collections.swap(getItems(), sourcePosition, targetPosition);
      notifyItemMoved(sourcePosition, targetPosition);
      return true;
    }
    @Override
    public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
      //Do nothing here
    }
  });
  touchHelper.attachToRecyclerView(recyclerView);
}

代码示例来源:origin: MCMrARM/revolution-irc

public void enableDragDrop(RecyclerView recyclerView) {
  ItemTouchHelper.Callback callback = new MyItemTouchHelperCallback(recyclerView.getContext());
  mItemTouchHelper = new ItemTouchHelper(callback);
  mItemTouchHelper.attachToRecyclerView(recyclerView);
}

代码示例来源:origin: realm/realm-android-adapters

private void setUpRecyclerView() {
  adapter = new MyRecyclerViewAdapter(realm.where(Parent.class).findFirst().getItemList());
  recyclerView.setLayoutManager(new LinearLayoutManager(this));
  recyclerView.setAdapter(adapter);
  recyclerView.setHasFixedSize(true);
  recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
  TouchHelperCallback touchHelperCallback = new TouchHelperCallback();
  ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
  touchHelper.attachToRecyclerView(recyclerView);
}

代码示例来源:origin: Gwokhov/Deadline

private void setupEventList() {
  RecyclerView recyclerView = mBinding.listEvents;
  mEventsAdapter = new EventsAdapter(getContext(), mViewModel);
  recyclerView.setAdapter(mEventsAdapter);
  ItemTouchHelper touchHelper = new ItemTouchHelper(new EventTouchHelperCallback(mEventsAdapter));
  touchHelper.attachToRecyclerView(recyclerView);
  LayoutAnimationController animationController = AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.layout_fall_down);
  recyclerView.setLayoutAnimation(animationController);
  mEventsAdapter.setEventItemActionListener(new EventItemActionListener() {
    @Override
    public void onItemClicked(String eventId) {
      Bundle bundle = new Bundle();
      bundle.putString(EditFragment.ARG_EDIT_EVENT_ID, eventId);
      Navigation.findNavController(getView()).navigate(R.id.action_events_to_edit, bundle);
    }
  });
}

代码示例来源:origin: googlecast/CastVideos-android

mItemTouchHelper = new ItemTouchHelper(callback);
mItemTouchHelper.attachToRecyclerView(recyclerView);

代码示例来源:origin: darkskygit/VirtualApp

private void initLaunchpad() {
  mLauncherView.setHasFixedSize(true);
  StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, OrientationHelper.VERTICAL);
  mLauncherView.setLayoutManager(layoutManager);
  mLaunchpadAdapter = new LaunchpadAdapter(this);
  SmartRecyclerAdapter wrap = new SmartRecyclerAdapter(mLaunchpadAdapter);
  View footer = new View(this);
  footer.setLayoutParams(new StaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, VUiKit.dpToPx(this, 60)));
  wrap.setFooterView(footer);
  mLauncherView.setAdapter(wrap);
  mLauncherView.addItemDecoration(new ItemOffsetDecoration(this, R.dimen.desktop_divider));
  ItemTouchHelper touchHelper = new ItemTouchHelper(new LauncherTouchCallback());
  touchHelper.attachToRecyclerView(mLauncherView);
  mLaunchpadAdapter.setAppClickListener((pos, data) -> {
    if (!data.isLoading()) {
      if (data instanceof AddAppButton) {
        onAddAppButtonClick();
      }
      mLaunchpadAdapter.notifyItemChanged(pos);
      mPresenter.launchApp(data);
      finish();
    }
  });
}

代码示例来源:origin: MCMrARM/revolution-irc

@Override
public void bind(ExpandableColorSetting entry) {
  super.bind(entry);
  SavedColorListAdapter adapter = new SavedColorListAdapter(entry.mSavedColors);
  adapter.setListener((c) -> setColor(c, null, true));
  adapter.setResetColor(entry.mDefaultColor, () -> {
    setColor(entry.getDefaultColor(), null, false);
    getEntry().resetColor(true);
  });
  adapter.setAddColorListener(() -> {
    adapter.addColor(getEntry().getSelectedColor());
  });
  mSavedColors.setAdapter(adapter);
  if (mSavedColorsTouchHelper != null)
    mSavedColorsTouchHelper.attachToRecyclerView(null);
  mSavedColorsTouchHelper = new ItemTouchHelper(adapter.createTouchHelperCallbacks());
  mSavedColorsTouchHelper.attachToRecyclerView(mSavedColors);
  setColor(entry.getSelectedColor(), null, false);
}

相关文章