Java Code Examples for android.support.v7.widget.RecyclerView#getItemAnimator()
The following examples show how to use
android.support.v7.widget.RecyclerView#getItemAnimator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PathLayoutManager.java From PathLayoutManager with Apache License 2.0 | 6 votes |
/** * 通过反射替换默认的Item动画 (解决在某些机型上的crash问题) */ private void initItemAnimator() { try { Field field = RecyclerView.LayoutManager.class.getDeclaredField("mRecyclerView"); field.setAccessible(true); RecyclerView recyclerView = (RecyclerView) field.get(this); if (recyclerView != null) { recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER); recyclerView.setHorizontalScrollBarEnabled(false); recyclerView.setVerticalScrollBarEnabled(false); if (recyclerView.getItemAnimator() != mItemAnimator) { recyclerView.setItemAnimator(mItemAnimator); } } // recyclerView.setItemAnimator(null); mRecycler.setViewCacheSize(mCacheCount); } catch (Exception e) { e.printStackTrace(); } }
Example 2
Source File: SelectableListLayout.java From 365browser with Apache License 2.0 | 6 votes |
/** * Initializes the RecyclerView. * * @param adapter The adapter that provides a binding from an app-specific data set to views * that are displayed within the RecyclerView. * @return The RecyclerView itself. */ public RecyclerView initializeRecyclerView(Adapter<RecyclerView.ViewHolder> adapter) { mAdapter = adapter; mAdapter.registerAdapterDataObserver(mAdapterObserver); mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view); mRecyclerView.setAdapter(mAdapter); mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); mRecyclerView.setHasFixedSize(true); mRecyclerView.addOnScrollListener(new OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { setToolbarShadowVisibility(); } }); mItemAnimator = mRecyclerView.getItemAnimator(); return mRecyclerView; }
Example 3
Source File: ReItemTouchHelper.java From ReSwipeCard with Apache License 2.0 | 5 votes |
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(); } }
Example 4
Source File: ExpandActivity.java From expandable-recycler-view with MIT License | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_expand); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(getClass().getSimpleName()); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); LinearLayoutManager layoutManager = new LinearLayoutManager(this); // RecyclerView has some built in animations to it, using the DefaultItemAnimator. // Specifically when you call notifyItemChanged() it does a fade animation for the changing // of the data in the ViewHolder. If you would like to disable this you can use the following: RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator(); if (animator instanceof DefaultItemAnimator) { ((DefaultItemAnimator) animator).setSupportsChangeAnimations(false); } adapter = new GenreAdapter(makeGenres()); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(adapter); Button clear = (Button) findViewById(R.id.toggle_button); clear.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { adapter.toggleGroup(makeClassicGenre()); } }); }
Example 5
Source File: RecyclerViewUtil.java From NIM_Android_UIKit with MIT License | 5 votes |
public static void changeItemAnimation(RecyclerView recyclerView, boolean isOpen) { // 关闭viewholder动画效果。解决viewholder闪烁问题 RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator(); if (animator instanceof SimpleItemAnimator) { ((SimpleItemAnimator) animator).setSupportsChangeAnimations(isOpen); } }
Example 6
Source File: ItemTouchHelper.java From letv with Apache License 2.0 | 4 votes |
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(); }