/** Called to create this fragment's view for the first time. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_picker, container, false); ButterKnife.bind(this, view); card_list.setLayoutManager(new LinearLayoutManager(getContext())); card_list.addItemDecoration(new ListDivider(getContext())); // Disable flicker animation when an item changes // (otherwise items will flicker when selection state changes) ItemAnimator animator = card_list.getItemAnimator(); if (animator instanceof SimpleItemAnimator) ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false); final SharedPreferences pref = Pref.get(getContext()); adapter = new AdapterCardsFilter(card_list, pref.getString(Pref.FILT_CARD, ""), pref.getString(Pref.REQ_CARDS, "")); card_list.setAdapter(adapter); updateView(); return view; }
private void postDispatchSwipe(final RecoverAnimation anim, final int swipeDir) { this.mRecyclerView.post(new Runnable() { public void run() { if (ItemTouchHelper.this.mRecyclerView != null && ItemTouchHelper.this.mRecyclerView.isAttachedToWindow() && !anim.mOverridden && anim.mViewHolder.getAdapterPosition() != -1) { ItemAnimator animator = ItemTouchHelper.this.mRecyclerView.getItemAnimator(); if ((animator == null || !animator.isRunning(null)) && !ItemTouchHelper.this.hasRunningRecoverAnim()) { ItemTouchHelper.this.mCallback.onSwiped(anim.mViewHolder, swipeDir); } else { ItemTouchHelper.this.mRecyclerView.post(this); } } } }); }
public long getAnimationDuration(RecyclerView recyclerView, int animationType, float animateDx, float animateDy) { ItemAnimator itemAnimator = recyclerView.getItemAnimator(); return itemAnimator == null ? animationType == 8 ? 200 : 250 : animationType == 8 ? itemAnimator.getMoveDuration() : itemAnimator.getRemoveDuration(); }