androidx.recyclerview.widget.RecyclerView#ItemAnimator ( )源码实例Demo

下面列出了androidx.recyclerview.widget.RecyclerView#ItemAnimator ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: RecyclerViewExtensions   文件: DragDropHelper.java
private void stop(boolean now) {
    if (mState != STATE_NONE && mState != STATE_STOPPING) {
        RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
        RecyclerView.ViewHolder viewHolder = mTracker.getViewHolder();
        if (!now && mState == STATE_DRAGGING && viewHolder != null && itemAnimator != null) {
            recoverInternal(viewHolder, itemAnimator);

            // Stop internally after animations are done.
            itemAnimator.isRunning(new RecyclerView.ItemAnimator.ItemAnimatorFinishedListener() {
                @Override
                public void onAnimationsFinished() {
                    stopInternal();
                }
            });
        } else {
            if (mState == STATE_RECOVERING) {
                if (itemAnimator != null) {
                    itemAnimator.endAnimations();
                }
            } else {
                stopInternal();
            }
        }
    }
}
 
源代码2 项目: RecyclerViewExtensions   文件: DragDropHelper.java
private void recoverInternal(
        @NonNull RecyclerView.ViewHolder viewHolder, @Nullable RecyclerView.ItemAnimator itemAnimator) {
    mState = STATE_RECOVERING;

    // Setup preInfo with current translation values.
    RecyclerView.ItemAnimator.ItemHolderInfo preInfo = new RecyclerView.ItemAnimator.ItemHolderInfo();
    preInfo.left = (int) viewHolder.itemView.getTranslationX();
    preInfo.top = (int) viewHolder.itemView.getTranslationY();

    // Setup postInfo with all values at 0 (the default). The intent is to settle in the final position.
    RecyclerView.ItemAnimator.ItemHolderInfo postInfo = new RecyclerView.ItemAnimator.ItemHolderInfo();

    // Clear current translation values to prevent them from being added on top of preInfo.
    setTranslation(viewHolder, 0f, 0f);

    // Animate the move, stopping internally when done.
    if (itemAnimator != null && itemAnimator.animatePersistence(viewHolder, preInfo, postInfo)) {
        itemAnimator.runPendingAnimations();
    }
}
 
源代码3 项目: ColorPickerDialog   文件: PresetPickerView.java
@Override
protected void init() {
    inflate(getContext(), R.layout.colorpicker_layout_preset_picker, this);

    adapter = new PresetColorAdapter(DEFAULT_PRESETS).withListener(this);

    RecyclerView recycler = findViewById(R.id.recycler);
    recycler.setHasFixedSize(true);

    RecyclerView.ItemAnimator animator = recycler.getItemAnimator();
    if (animator instanceof SimpleItemAnimator)
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);

    recycler.setLayoutManager(new GridLayoutManager(getContext(), 4));
    recycler.setAdapter(adapter);
}
 
源代码4 项目: Android-nRF-Blinky   文件: ScannerActivity.java
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scanner);
    ButterKnife.bind(this);

    final MaterialToolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.app_name);
    setSupportActionBar(toolbar);

    // Create view model containing utility methods for scanning
    scannerViewModel = new ViewModelProvider(this).get(ScannerViewModel.class);
    scannerViewModel.getScannerState().observe(this, this::startScan);

    // Configure the recycler view
    final RecyclerView recyclerView = findViewById(R.id.recycler_view_ble_devices);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    final RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
    if (animator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }
    final DevicesAdapter adapter = new DevicesAdapter(this, scannerViewModel.getDevices());
    adapter.setOnItemClickListener(this);
    recyclerView.setAdapter(adapter);
}
 
private void disableItemAnimatorForRecyclerInAnimation() {
    final RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    FlipperAnimator flipperAnimator = getFlipperAnimator();
    if (itemAnimator != null && flipperAnimator != null) {
        mRecyclerView.setItemAnimator(null);
        mRecyclerView.postDelayed(new Runnable() {
            @Override
            public void run() {
                mRecyclerView.setItemAnimator(itemAnimator);
            }
        }, flipperAnimator.getDuration());
    }
}
 
private void initTokens(List<TokenBodyItem> tokens) {
    Log.d("psd", "initTokens start");
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    RecyclerView.ItemAnimator animator = rvTokens.getItemAnimator();
    if (animator instanceof DefaultItemAnimator) {
        ((DefaultItemAnimator) animator).setSupportsChangeAnimations(false);
    }

    tokenAdapter = new TokenAdapter(generateTokensGroup(tokens));
    rvTokens.setLayoutManager(layoutManager);
    rvTokens.setAdapter(tokenAdapter);
    Log.d("psd", "initTokens end");
}
 
@Override
public Animator setupChangeAnimation(RecyclerView.ItemAnimator itemAnimator, CollapsibleParentViewHolder oldHolder, CollapsibleParentViewHolder newHolder, CollapsibleParentItemInfo preInfo, CollapsibleParentItemInfo postInfo) {
  if (preInfo.isCollapsed == postInfo.isCollapsed) {
    return null;
  }
  final float rotationFrom = preInfo.isCollapsed ? CARET_ROTATION_COLLAPSED : CARET_ROTATION_EXPANDED;
  final float rotationTo = !preInfo.isCollapsed ? CARET_ROTATION_COLLAPSED : CARET_ROTATION_EXPANDED;
  final ObjectAnimator animation = ObjectAnimator.ofFloat(newHolder.caretImage, ROTATION.getName(), rotationFrom, rotationTo);
  animation.addListener(new OnAnimationFinishListener(newHolder.caretImage, rotationTo));
  return animation;
}
 
源代码8 项目: aptoide-client-v8   文件: PromotionsFragment.java
private void setupRecyclerView() {
  promotionsList.setAdapter(promotionsAdapter);
  promotionsList.setLayoutManager(
      new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
  RecyclerView.ItemAnimator animator = promotionsList.getItemAnimator();
  if (animator instanceof SimpleItemAnimator) {
    ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
  }
}
 
源代码9 项目: leafpicrevived   文件: AnimationUtils.java
public static RecyclerView.ItemAnimator getItemAnimator(RecyclerView.ItemAnimator itemAnimator) {
    if (Prefs.animationsEnabled()) {
        return itemAnimator;
    }
    return null;
}
 
源代码10 项目: MHViewer   文件: GalleryCommentsScene.java
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
                          @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_comments, container, false);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mEditPanel = ViewUtils.$$(view, R.id.edit_panel);
    mSendImage = (ImageView) ViewUtils.$$(mEditPanel, R.id.send);
    mEditText = (EditText) ViewUtils.$$(mEditPanel, R.id.edit_text);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
    mFab = (FloatingActionButton) ViewUtils.$$(view, R.id.fab);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();
    int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_sad_pandroid);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);

    mAdapter = new CommentAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context,
            RecyclerView.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
            LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor),
            LayoutUtils.dp2pix(context, 1));
    decoration.setShowLastDivider(true);
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(),
            mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom() + paddingBottomFab);
    // Cancel change animator
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator instanceof DefaultItemAnimator) {
        ((DefaultItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
    }

    mSendImage.setOnClickListener(this);
    mFab.setOnClickListener(this);

    addAboveSnackView(mEditPanel);
    addAboveSnackView(mFabLayout);

    mViewTransition = new ViewTransition(mRecyclerView, tip);

    updateView(false);

    return view;
}
 
源代码11 项目: lttrs-android   文件: ThreadFragment.java
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    final Bundle bundle = getArguments();
    final ThreadFragmentArgs arguments = ThreadFragmentArgs.fromBundle(bundle == null ? new Bundle() : bundle);
    final String threadId = arguments.getThread();
    final String label = arguments.getLabel();
    final boolean triggerRead = !Arrays.asList(arguments.getKeywords()).contains(Keyword.SEEN);
    final ViewModelProvider viewModelProvider = new ViewModelProvider(
            getViewModelStore(),
            new ThreadViewModelFactory(
                    requireActivity().getApplication(),
                    getLttrsViewModel().getAccount(),
                    threadId,
                    label,
                    triggerRead
            )
    );
    threadViewModel = viewModelProvider.get(ThreadViewModel.class);
    binding = DataBindingUtil.inflate(inflater, R.layout.fragment_thread, container, false);

    //do we want a custom layout manager that does *NOT* remember scroll position when more
    //than one item is expanded. with variable sized items this might be annoying

    threadAdapter = new ThreadAdapter(threadViewModel.expandedItems);
    threadAdapter.setSubjectWithImportance(SubjectWithImportance.of(
            threadId,
            Strings.emptyToNull(arguments.getSubject()),
            arguments.getImportant()
    ));

    //the default change animation causes UI glitches when expanding or collapsing item
    //for now it's better to just disable it. In the future we may write our own animator
    RecyclerView.ItemAnimator itemAnimator = binding.list.getItemAnimator();
    if (itemAnimator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
    }

    binding.list.setAdapter(threadAdapter);
    threadViewModel.getEmails().observe(getViewLifecycleOwner(), this::onEmailsChanged);
    threadViewModel.getSubjectWithImportance().observe(getViewLifecycleOwner(), threadAdapter::setSubjectWithImportance);
    threadViewModel.getFlagged().observe(getViewLifecycleOwner(), threadAdapter::setFlagged);
    threadViewModel.getMenuConfiguration().observe(getViewLifecycleOwner(), menuConfiguration -> {
        this.menuConfiguration = menuConfiguration;
        requireActivity().invalidateOptionsMenu();
    });
    threadAdapter.setOnFlaggedToggledListener(this);
    threadAdapter.setOnComposeActionTriggeredListener(this);
    threadViewModel.getThreadViewRedirect().observe(getViewLifecycleOwner(), this::onThreadViewRedirect);
    return binding.getRoot();
}
 
源代码12 项目: EhViewer   文件: GalleryCommentsScene.java
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_comments, container, false);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mEditPanel = ViewUtils.$$(view, R.id.edit_panel);
    mSendImage = (ImageView) ViewUtils.$$(mEditPanel, R.id.send);
    mEditText = (EditText) ViewUtils.$$(mEditPanel, R.id.edit_text);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
    mFab = (FloatingActionButton) ViewUtils.$$(view, R.id.fab);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();
    int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_sad_pandroid);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);

    mSendDrawable = DrawableManager.getVectorDrawable(context, R.drawable.v_send_dark_x24);
    mPencilDrawable = DrawableManager.getVectorDrawable(context, R.drawable.v_pencil_dark_x24);

    mAdapter = new CommentAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context,
            RecyclerView.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
            LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor),
            LayoutUtils.dp2pix(context, 1));
    decoration.setShowLastDivider(true);
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(),
            mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom() + paddingBottomFab);
    // Cancel change animator
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator instanceof DefaultItemAnimator) {
        ((DefaultItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
    }

    mSendImage.setOnClickListener(this);
    mFab.setOnClickListener(this);

    addAboveSnackView(mEditPanel);
    addAboveSnackView(mFabLayout);

    mViewTransition = new ViewTransition(mRecyclerView, tip);

    updateView(false);

    return view;
}
 
源代码13 项目: cathode   文件: RecyclerViewFragment.java
public void onViewCreated(@NonNull View view, @Nullable Bundle inState) {
  super.onViewCreated(view, inState);
  progressContainer = view.findViewById(R.id.progressContainer);
  listContainer = view.findViewById(R.id.listContainer);
  recyclerView = Views.findRequired(view, android.R.id.list);
  empty = Views.findRequired(view, android.R.id.empty);

  recyclerView.setLayoutManager(getLayoutManager());
  RecyclerView.ItemAnimator itemAnimator = getItemAnimator();
  if (itemAnimator != null) {
    recyclerView.setItemAnimator(itemAnimator);
  } else {
    ((DefaultItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
  }
  addItemDecorations(recyclerView);

  if (empty != null) {
    if (emptyText != null) {
      empty.setText(emptyText);
    }

    if (adapter != null && adapter.getItemCount() > 0) {
      empty.setVisibility(View.GONE);
    } else {
      empty.setVisibility(View.VISIBLE);
    }
  }

  if (adapter != null) {
    recyclerView.setAdapter(adapter);
  }

  if (adapter == null) {
    listContainer.setVisibility(View.GONE);
    progressContainer.setVisibility(View.VISIBLE);
    currentState = STATE_PROGRESS_VISIBLE;
  } else {
    currentState = STATE_CONTENT_VISIBLE;
    listContainer.setVisibility(View.VISIBLE);
    progressContainer.setVisibility(View.GONE);
  }
}
 
源代码14 项目: litho   文件: TestLithoRecyclerView.java
@Override
@Nullable
public RecyclerView.ItemAnimator getItemAnimator() {
  return itemAnimator;
}
 
源代码15 项目: litho   文件: TestLithoRecyclerView.java
@Override
public void setItemAnimator(@Nullable RecyclerView.ItemAnimator animator) {
  this.itemAnimator = animator;
}
 
源代码16 项目: PictureSelector   文件: PictureSelectorActivity.java
@Override
protected void initWidgets() {
    super.initWidgets();
    container = findViewById(R.id.container);
    titleViewBg = findViewById(R.id.titleViewBg);
    mIvPictureLeftBack = findViewById(R.id.pictureLeftBack);
    mTvPictureTitle = findViewById(R.id.picture_title);
    mTvPictureRight = findViewById(R.id.picture_right);
    mTvPictureOk = findViewById(R.id.picture_tv_ok);
    mCbOriginal = findViewById(R.id.cb_original);
    mIvArrow = findViewById(R.id.ivArrow);
    mTvPicturePreview = findViewById(R.id.picture_id_preview);
    mTvPictureImgNum = findViewById(R.id.picture_tvMediaNum);
    mRecyclerView = findViewById(R.id.picture_recycler);
    mBottomLayout = findViewById(R.id.rl_bottom);
    mTvEmpty = findViewById(R.id.tv_empty);
    isNumComplete(numComplete);
    if (!numComplete) {
        animation = AnimationUtils.loadAnimation(this, R.anim.picture_anim_modal_in);
    }
    mTvPicturePreview.setOnClickListener(this);
    if (config.isAutomaticTitleRecyclerTop) {
        titleViewBg.setOnClickListener(this);
    }
    mTvPicturePreview.setVisibility(config.chooseMode != PictureMimeType.ofAudio() && config.enablePreview ? View.VISIBLE : View.GONE);
    mBottomLayout.setVisibility(config.selectionMode == PictureConfig.SINGLE
            && config.isSingleDirectReturn ? View.GONE : View.VISIBLE);
    mIvPictureLeftBack.setOnClickListener(this);
    mTvPictureRight.setOnClickListener(this);
    mTvPictureOk.setOnClickListener(this);
    mTvPictureImgNum.setOnClickListener(this);
    mTvPictureTitle.setOnClickListener(this);
    mIvArrow.setOnClickListener(this);
    String title = config.chooseMode == PictureMimeType.ofAudio() ?
            getString(R.string.picture_all_audio) : getString(R.string.picture_camera_roll);
    mTvPictureTitle.setText(title);
    mTvPictureTitle.setTag(R.id.view_tag, -1);
    folderWindow = new FolderPopWindow(this, config);
    folderWindow.setArrowImageView(mIvArrow);
    folderWindow.setOnAlbumItemClickListener(this);
    mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(config.imageSpanCount,
            ScreenUtils.dip2px(this, 2), false));
    mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), config.imageSpanCount));
    if (!config.isPageStrategy) {
        mRecyclerView.setHasFixedSize(true);
    } else {
        mRecyclerView.setReachBottomRow(RecyclerPreloadView.BOTTOM_PRELOAD);
        mRecyclerView.setOnRecyclerViewPreloadListener(PictureSelectorActivity.this);
    }
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator != null) {
        ((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
        mRecyclerView.setItemAnimator(null);
    }
    loadAllMediaData();
    mTvEmpty.setText(config.chooseMode == PictureMimeType.ofAudio() ?
            getString(R.string.picture_audio_empty)
            : getString(R.string.picture_empty));
    StringUtils.tempTextFont(mTvEmpty, config.chooseMode);
    mAdapter = new PictureImageGridAdapter(getContext(), config);
    mAdapter.setOnPhotoSelectChangedListener(this);

    switch (config.animationMode) {
        case AnimationType
                .ALPHA_IN_ANIMATION:
            mRecyclerView.setAdapter(new AlphaInAnimationAdapter(mAdapter));
            break;
        case AnimationType
                .SLIDE_IN_BOTTOM_ANIMATION:
            mRecyclerView.setAdapter(new SlideInBottomAnimationAdapter(mAdapter));
            break;
        default:
            mRecyclerView.setAdapter(mAdapter);
            break;
    }
    if (config.isOriginalControl) {
        mCbOriginal.setVisibility(View.VISIBLE);
        mCbOriginal.setChecked(config.isCheckOriginalImage);
        mCbOriginal.setOnCheckedChangeListener((buttonView, isChecked) -> {
            config.isCheckOriginalImage = isChecked;
        });
    }
}
 
源代码17 项目: cathode   文件: RecyclerViewFragment.java
protected RecyclerView.ItemAnimator getItemAnimator() {
  return null;
}
 
源代码18 项目: CrazyDaily   文件: ItemTouchHelperExtension.java
/**
 * Called by the ItemTouchHelper when user action finished on a ViewHolder and now the View
 * will be animated to its final position.
 * <p>
 * Default implementation uses ItemAnimator's duration values. If
 * <code>animationType</code> is {@link #ANIMATION_TYPE_DRAG}, it returns
 * {@link RecyclerView.ItemAnimator#getMoveDuration()}, otherwise, it returns
 * {@link RecyclerView.ItemAnimator#getRemoveDuration()}. If RecyclerView does not have
 * any {@link RecyclerView.ItemAnimator} attached, this method returns
 * {@code DEFAULT_DRAG_ANIMATION_DURATION} or {@code DEFAULT_SWIPE_ANIMATION_DURATION}
 * depending on the animation type.
 *
 * @param recyclerView  The RecyclerView to which the ItemTouchHelper is attached to.
 * @param animationType The type of animation. Is one of {@link #ANIMATION_TYPE_DRAG},
 *                      {@link #ANIMATION_TYPE_SWIPE_CANCEL} or
 *                      {@link #ANIMATION_TYPE_SWIPE_SUCCESS}.
 * @param animateDx     The horizontal distance that the animation will offset
 * @param animateDy     The vertical distance that the animation will offset
 * @return The duration for the animation
 */
public long getAnimationDuration(RecyclerView recyclerView, int animationType,
                                 float animateDx, float animateDy) {
    final RecyclerView.ItemAnimator itemAnimator = recyclerView.getItemAnimator();
    if (itemAnimator == null) {
        return animationType == ANIMATION_TYPE_DRAG ? DEFAULT_DRAG_ANIMATION_DURATION
                : DEFAULT_SWIPE_ANIMATION_DURATION;
    } else {
        return animationType == ANIMATION_TYPE_DRAG ? itemAnimator.getMoveDuration()
                : itemAnimator.getRemoveDuration();
    }
}
 
源代码19 项目: Carbon   文件: ItemTouchHelper.java
/**
 * Called by the ItemTouchHelper when user action finished on a ViewHolder and now the View
 * will be animated to its final position.
 * <p>
 * Default implementation uses ItemAnimator's duration values. If
 * <code>animationType</code> is {@link #ANIMATION_TYPE_DRAG}, it returns
 * {@link RecyclerView.ItemAnimator#getMoveDuration()}, otherwise, it returns {@link
 * RecyclerView.ItemAnimator#getRemoveDuration()}. If RecyclerView does not have any {@link
 * RecyclerView.ItemAnimator} attached, this method returns {@code
 * DEFAULT_DRAG_ANIMATION_DURATION} or {@code DEFAULT_SWIPE_ANIMATION_DURATION} depending on
 * the animation type.
 *
 * @param recyclerView  The RecyclerView to which the ItemTouchHelper is attached to.
 * @param animationType The type of animation. Is one of {@link #ANIMATION_TYPE_DRAG},
 *                      {@link #ANIMATION_TYPE_SWIPE_CANCEL} or {@link
 *                      #ANIMATION_TYPE_SWIPE_SUCCESS}.
 * @param animateDx     The horizontal distance that the animation will offset
 * @param animateDy     The vertical distance that the animation will offset
 * @return The duration for the animation
 */
public long getAnimationDuration(RecyclerView recyclerView, int animationType,
                                 float animateDx, float animateDy) {
    final RecyclerView.ItemAnimator itemAnimator = recyclerView.getItemAnimator();
    if (itemAnimator == null) {
        return animationType == ANIMATION_TYPE_DRAG ? DEFAULT_DRAG_ANIMATION_DURATION
                : DEFAULT_SWIPE_ANIMATION_DURATION;
    } else {
        return animationType == ANIMATION_TYPE_DRAG ? itemAnimator.getMoveDuration()
                : itemAnimator.getRemoveDuration();
    }
}
 
/**
 * Gets the current ItemAnimator for this RecyclerView. A null return value
 * indicates that there is no animator and that item changes will happen without
 * any animations. By default, RecyclerView instantiates and
 * uses an instance of {@link DefaultItemAnimator}.
 *
 * @return ItemAnimator The current ItemAnimator. If null, no animations will occur
 * when changes occur to the items in this RecyclerView.
 */
public RecyclerView.ItemAnimator getItemAnimator() {
    return mRecyclerView.getItemAnimator();
}