Java Code Examples for android.support.v7.widget.RecyclerView#ItemAnimator

The following examples show how to use android.support.v7.widget.RecyclerView#ItemAnimator . 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: ClassifyView.java    From ClassifyView with Apache License 2.0 7 votes vote down vote up
@NonNull
protected RecyclerView getSub(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new GridLayoutManager(context, mSubSpanCount));
    RecyclerView.ItemAnimator itemAnimator = new ClassifyItemAnimator();
    itemAnimator.setChangeDuration(CHANGE_DURATION);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 2
Source File: WeekdaysDataSource.java    From weekdays-buttons-bar with MIT License 6 votes vote down vote up
private void initRecyclerView(Context context) {
        if (mRecyclerView == null) return;
        mRecyclerView.setBackgroundColor(mBackgroundColor);
        mRecyclerView.setHasFixedSize(true);
        mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);

        mRecyclerView.setLayoutManager(mLayoutManager);
        mRecyclerView.setAdapter(createAdapter());
        mRecyclerView.setNestedScrollingEnabled(isNestedScrollEnable());


//        mRecyclerView.getItemAnimator().setSupportsChangeAnimations(true);
        RecyclerView.ItemAnimator animator = mRecyclerView.getItemAnimator();
        if (animator instanceof SimpleItemAnimator) {
            ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
        }
        onRecyclerViewInit(mRecyclerView);
    }
 
Example 3
Source File: VirtualLayoutManagerTest.java    From vlayout with MIT License 6 votes vote down vote up
public void waitForAnimationsToEnd(int timeoutInSeconds) throws InterruptedException {
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator == null) {
        return;
    }
    final CountDownLatch latch = new CountDownLatch(1);
    final boolean running = itemAnimator.isRunning(
            new RecyclerView.ItemAnimator.ItemAnimatorFinishedListener() {
                @Override
                public void onAnimationsFinished() {
                    latch.countDown();
                }
            }
    );
    if (running) {
        latch.await(timeoutInSeconds, TimeUnit.SECONDS);
    }
}
 
Example 4
Source File: MultiredditAdapter.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
public void refreshView() {
    final RecyclerView.ItemAnimator a = listView.getItemAnimator();
    listView.setItemAnimator(null);
    notifyItemChanged(clicked);
    listView.postDelayed(new Runnable() {
        @Override
        public void run() {
            listView.setItemAnimator(a);
        }
    }, 500);
}
 
Example 5
Source File: RecyclerViewUtil.java    From NIM_Android_UIKit with MIT License 5 votes vote down vote up
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: ClassifyView.java    From ClassifyView with Apache License 2.0 5 votes vote down vote up
@NonNull
protected RecyclerView getMain(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new GridLayoutManager(context, mMainSpanCount));
    RecyclerView.ItemAnimator itemAnimator = new ClassifyItemAnimator();
    itemAnimator.setChangeDuration(CHANGE_DURATION);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 7
Source File: LinearHHClassifyView.java    From ClassifyView with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected RecyclerView getSub(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false));
    RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
    itemAnimator.setChangeDuration(10);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 8
Source File: SubmissionAdapter.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
public void refreshView(boolean ignore18) {
    final RecyclerView.ItemAnimator a = listView.getItemAnimator();
    listView.setItemAnimator(null);
    notifyItemChanged(clicked);
    listView.postDelayed(new Runnable() {
        @Override
        public void run() {
            listView.setItemAnimator(a);
        }
    }, 500);
}
 
Example 9
Source File: LinearHVClassifyView.java    From ClassifyView with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected RecyclerView getSub(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
    itemAnimator.setChangeDuration(10);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 10
Source File: LinearHVClassifyView.java    From ClassifyView with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected RecyclerView getMain(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false));
    RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
    itemAnimator.setChangeDuration(10);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 11
Source File: SubmissionAdapter.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
public void refreshView() {
    final RecyclerView.ItemAnimator a = listView.getItemAnimator();
    listView.setItemAnimator(null);
    notifyItemChanged(clicked);
    listView.postDelayed(new Runnable() {
        @Override
        public void run() {
            listView.setItemAnimator(a);
        }
    }, 500);
}
 
Example 12
Source File: LinearVVClassifyView.java    From ClassifyView with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected RecyclerView getMain(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
    itemAnimator.setChangeDuration(10);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 13
Source File: MultiredditAdapter.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
public void refreshView(ArrayList<Integer> seen) {
    listView.setItemAnimator(null);
    final RecyclerView.ItemAnimator a = listView.getItemAnimator();

    for (int i : seen) {
        notifyItemChanged(i + 1);
    }
    listView.postDelayed(new Runnable() {
        @Override
        public void run() {
            listView.setItemAnimator(a);
        }
    }, 500);
}
 
Example 14
Source File: ExpandActivity.java    From expandable-recycler-view with MIT License 5 votes vote down vote up
@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 15
Source File: ReItemTouchHelper.java    From ReSwipeCard with Apache License 2.0 5 votes vote down vote up
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 16
Source File: PullRecycler.java    From DoingDaily with Apache License 2.0 4 votes vote down vote up
public void setItemAnimator(RecyclerView.ItemAnimator itemAnimator) {
    if (itemAnimator != null) {
        mRecyclerView.setItemAnimator(itemAnimator);
    }
}
 
Example 17
Source File: MultiFuncRecyclerView.java    From TestChat with Apache License 2.0 4 votes vote down vote up
public void setItemAnimator(RecyclerView.ItemAnimator itemAnimator) {
        if (itemAnimator != null) {
                display.setItemAnimator(itemAnimator);
        }
}
 
Example 18
Source File: GlobalSearchBaseFragment.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
private void showSearch() {
    if (isSearchVisible) {
        return;
    }
    isSearchVisible = true;

    searchDisplay = messenger().buildSearchDisplayList();
    searchDisplay.setBindHook(new BindedDisplayList.BindHook<SearchEntity>() {
        @Override
        public void onScrolledToEnd() {
            scrolledToEnd = true;
            checkGlobalSearch();
        }

        @Override
        public void onItemTouched(SearchEntity item) {

        }
    });
    searchAdapter = new SearchAdapter(getActivity(), searchDisplay, new OnItemClickedListener<SearchEntity>() {
        @Override
        public void onClicked(SearchEntity item) {
            onPeerPicked(item.getPeer());
            searchMenu.collapseActionView();
        }

        @Override
        public boolean onLongClicked(SearchEntity item) {
            return false;
        }
    });
    HeaderViewRecyclerAdapter recyclerAdapter = new HeaderViewRecyclerAdapter(searchAdapter);

    View header = new View(getActivity());
    header.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(0)));
    header.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    recyclerAdapter.addHeaderView(header);

    searchList.setAdapter(recyclerAdapter);

    RecyclerView.ItemAnimator animator = searchList.getItemAnimator();

    if (animator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }


    searchDisplay.addListener(searchListener);
    showView(searchHintView, false);
    goneView(searchEmptyView, false);

    showView(searchContainer, false);

    Fragment parent = getParentFragment();
    if (parent != null && parent instanceof GlobalSearchStateDelegate) {
        ((GlobalSearchStateDelegate) parent).onGlobalSearchStarted();
    }
}
 
Example 19
Source File: ItemAnimatorFactory.java    From onboarding-examples-android with Apache License 2.0 4 votes vote down vote up
static public RecyclerView.ItemAnimator slidein() {
    SlideInUpDelayedAnimator animator = new SlideInUpDelayedAnimator(new DecelerateInterpolator(1.2f));
    animator.setAddDuration(600);
    return animator;
}
 
Example 20
Source File: EasyRecyclerView.java    From BookReader with Apache License 2.0 4 votes vote down vote up
public void setItemAnimator(RecyclerView.ItemAnimator animator) {
    mRecycler.setItemAnimator(animator);
}