当前位置: 首页>>代码示例>>Java>>正文


Java ScaleInOutItemAnimator类代码示例

本文整理汇总了Java中it.gmariotti.recyclerview.itemanimator.ScaleInOutItemAnimator的典型用法代码示例。如果您正苦于以下问题:Java ScaleInOutItemAnimator类的具体用法?Java ScaleInOutItemAnimator怎么用?Java ScaleInOutItemAnimator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ScaleInOutItemAnimator类属于it.gmariotti.recyclerview.itemanimator包,在下文中一共展示了ScaleInOutItemAnimator类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivityCreated

import it.gmariotti.recyclerview.itemanimator.ScaleInOutItemAnimator; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mComments = new ArrayList<CommentItem>();
    mAdapter = new CommentsAdapter(getActivity(), mComments);
    if(mRecyclerView != null) {
        mRecyclerView.setAdapter(mAdapter);
        LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
        mRecyclerView.setLayoutManager(mLayoutManager);
        mRecyclerView.setItemAnimator(new ScaleInOutItemAnimator(mRecyclerView));
    }
    mSwipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mComments.clear();
            mAdapter.notifyDataSetChanged();
            fetchComments(commentIDs, true);
        }
    });

}
 
开发者ID:saleemaoc,项目名称:hackernews,代码行数:23,代码来源:CommentsFragment.java

示例2: onActivityCreated

import it.gmariotti.recyclerview.itemanimator.ScaleInOutItemAnimator; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mStories = new ArrayList<StoryItem>();
    mAdapter = new StoryAdapter(getActivity(), mStories);
    if(mRecyclerView != null) {
        mRecyclerView.setAdapter(mAdapter);
        final LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
        mRecyclerView.setLayoutManager(mLayoutManager);
        mRecyclerView.setItemAnimator(new ScaleInOutItemAnimator(mRecyclerView));
        mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                totalItemCount = mStoriesWorker.totalStories.size();
                int totalLoadedItems = Math.max(mLayoutManager.getItemCount(), mStories.size());
                int lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
                if (loading) {
                    if (totalLoadedItems > previousTotal) {
                        loading = false;
                        previousTotal = totalLoadedItems;
                    }
                }
                // load more items if we have reached the end of the scroll
                // log(lastVisibleItem + "; " + totalLoadedItems + "; " + totalItemCount+ "; " + loading);
                if(!loading && (lastVisibleItem >= (totalLoadedItems - 1) && totalLoadedItems < totalItemCount)) {
                    if(mStoriesWorker.isLoading()) {
                       // log("already loading data.. ");
                        return;
                    }
                    // log("scroll end reached");
                    mSwipeLayout.setRefreshing(true);
                    loading = true;
                    mStoriesWorker.loadMore(lastVisibleItem + 1, lastVisibleItem + 1 + visibleThreshold);
                }
            }
        });
    }

    fetchStories(false  );
    mSwipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mStories.clear();
            mAdapter.notifyDataSetChanged();
            fetchStories(true);
        }
    });
}
 
开发者ID:saleemaoc,项目名称:hackernews,代码行数:53,代码来源:StoryFragment.java


注:本文中的it.gmariotti.recyclerview.itemanimator.ScaleInOutItemAnimator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。