Java 类android.support.v7.widget.RecyclerView.OnScrollListener 实例源码

项目:boohee_v5.6    文件:SearcherActivity.java   
private void initSearch() {
    this.rvSearch.setHasFixedSize(true);
    this.rvSearch.setLayoutManager(new LinearLayoutManager(this));
    this.mSearchAdapter = new SearchAdapter(this.mSearchList);
    this.rvSearch.setAdapter(this.mSearchAdapter);
    this.rvSearch.addItemDecoration(new DividerItemDecoration(this, 1));
    this.rvSearch.addOnScrollListener(new OnRecyclerLoadMoreListener() {
        public void onLoadMore() {
            SearcherActivity.this.sendSearchRequest(true);
        }
    });
    this.rvSearch.addOnScrollListener(new OnScrollListener() {
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if (SearcherActivity.this.isQuickSearch) {
                KeyBoardUtils.closeAll(SearcherActivity.this.ctx);
            }
        }
    });
}
项目:365browser    文件:SelectableListLayout.java   
/**
 * 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;
}
项目:android-Stupid-Adapter    文件:IPauseOnScrollRecycler.java   
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
    super.onScrollStateChanged(recyclerView, newState);
    switch (newState) {
    case android.widget.AbsListView.OnScrollListener.SCROLL_STATE_IDLE:
        adapter.onResume();
        break;
    case android.widget.AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
        // adapter.pause();
        adapter.onResume();
        break;
    case android.widget.AbsListView.OnScrollListener.SCROLL_STATE_FLING:
        adapter.onPause();
        break;
    }
    if (listener2 != null)
        listener2.onScrollStateChanged(recyclerView, newState);

}
项目:DominionPicker    文件:AdapterRules.java   
/** Default constructor for the adapter. */
public AdapterRules(RecyclerView target) {
    mContext = (AppCompatActivity) target.getContext();
    recycler = target;
    describer = new IconDescriber(mContext);

    // hasScroll is set to true the moment a nonzero scroll happens
    target.addOnScrollListener(new OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if(dy == 0) return;
            hasScroll = true;
            recyclerView.removeOnScrollListener(this);
        }
    });

    // retrieve the basic preferences and reload the list of options.
    SharedPreferences pref = Pref.get(mContext);
    loadPref(pref, Pref.FILT_SET, filt_set);
    loadPref(pref, Pref.FILT_COST, filt_cost);
    loadPref(pref, Pref.FILT_DEBT, filt_debt);
    reload();
}
项目:PeSanKita-android    文件:ConversationFragment.java   
private void initializeResources() {
  this.recipients     = RecipientFactory.getRecipientsForIds(getActivity(), getActivity().getIntent().getLongArrayExtra("recipients"), true);
  this.threadId       = this.getActivity().getIntent().getLongExtra("thread_id", -1);
  this.lastSeen       = this.getActivity().getIntent().getLongExtra(ConversationActivity.LAST_SEEN_EXTRA, -1);
  this.firstLoad      = true;

  OnScrollListener scrollListener = new ConversationScrollListener(getActivity());
  list.addOnScrollListener(scrollListener);
}
项目:boohee_v5.6    文件:PPRecyclerView.java   
private void initLoadMore() {
    this.mRecyclerView.setOnScrollListener(new OnScrollListener() {
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            int lastVisibleItem = PPRecyclerView.this.mLayoutManager
                    .findLastVisibleItemPosition();
            int totalItemCount = PPRecyclerView.this.mLayoutManager.getItemCount();
            if (PPRecyclerView.this.mListener != null && !PPRecyclerView.this.isLoadMore &&
                    lastVisibleItem >= totalItemCount - PPRecyclerView.this.lastNum) {
                PPRecyclerView.this.isLoadMore = true;
                PPRecyclerView.this.mListener.loadMore();
            }
        }
    });
}
项目:Cable-Android    文件:ConversationFragment.java   
private void initializeResources() {
  this.recipients     = RecipientFactory.getRecipientsForIds(getActivity(), getActivity().getIntent().getLongArrayExtra("recipients"), true);
  this.threadId       = this.getActivity().getIntent().getLongExtra("thread_id", -1);
  this.lastSeen       = this.getActivity().getIntent().getLongExtra(ConversationActivity.LAST_SEEN_EXTRA, -1);
  this.firstLoad      = true;

  OnScrollListener scrollListener = new ConversationScrollListener(getActivity());
  list.addOnScrollListener(scrollListener);
}
项目:CustomerLib    文件:XRefreshLayout.java   
private void setAbsListViewOnScrollListener() {
    if (mAbsListView != null) {
        try {
            // 通过反射获取开发者自定义的滚动监听器,并将其替换成自己的滚动监听器,触发滚动时也要通知开发者自定义的滚动监听器(非侵入式,不让开发者继承特定的控件)
            // mAbsListView.getClass().getDeclaredField("mOnScrollListener")获取不到mOnScrollListener,必须通过AbsListView.class.getDeclaredField("mOnScrollListener")获取
            Field field = AbsListView.class.getDeclaredField("mOnScrollListener");
            field.setAccessible(true);
            // 开发者自定义的滚动监听器
            final AbsListView.OnScrollListener onScrollListener = (AbsListView.OnScrollListener) field.get(mAbsListView);
            mAbsListView.setOnScrollListener(new AbsListView.OnScrollListener() {
                @Override
                public void onScrollStateChanged(AbsListView absListView, int scrollState) {
                    if ((scrollState == SCROLL_STATE_IDLE || scrollState == SCROLL_STATE_FLING) && shouldHandleAbsListViewLoadingMore(mAbsListView)) {
                        beginLoadingMore();
                    }

                    if (onScrollListener != null) {
                        onScrollListener.onScrollStateChanged(absListView, scrollState);
                    }
                }

                @Override
                public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                    if (onScrollListener != null && !mIsLoadingMore) {
                        onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:umeng_community_android    文件:RecyclerRefreshLayout.java   
/**
 * 获取ListView对象
 */
protected void getRefreshView() {
    int childs = getChildCount();
    if (childs > 0) {
        View childView = getChildAt(0);
        if (childView instanceof RecyclerView) {
            mRecyclerView = (RecyclerView) childView;
            // 设置滚动监听器给ListView, 使得滚动的情况下也可以自动加载
            mRecyclerView.setOnScrollListener(mScrollListener);
            mRecyclerView.setOnScrollListener(new OnScrollListener() {
            });
        }
    }
}
项目:FMTech    文件:PlayHighlightsOverlayView.java   
protected void onFinishInflate()
{
  super.onFinishInflate();
  this.mTitleRecycler = ((PlayRecyclerView)findViewById(2131755930));
  this.mPageIndicator = ((ScalingPageIndicator)findViewById(2131755931));
  ViewCompat.setImportantForAccessibility(this.mPageIndicator, 2);
  getContext();
  LinearLayoutManager localLinearLayoutManager = new LinearLayoutManager(0);
  this.mTitleRecycler.setLayoutManager(localLinearLayoutManager);
  this.mTitleRecycler.setHasFixedSize(true);
  this.mTitleRecycler.setFocusable(false);
  ViewCompat.setAccessibilityDelegate(this.mTitleRecycler, new AccessibilityDelegateCompat()
  {
    public final void onInitializeAccessibilityEvent(View paramAnonymousView, AccessibilityEvent paramAnonymousAccessibilityEvent)
    {
      AccessibilityRecordCompat localAccessibilityRecordCompat = AccessibilityEventCompat.asRecord(paramAnonymousAccessibilityEvent);
      AccessibilityRecordCompat.IMPL.setContentDescription(localAccessibilityRecordCompat.mRecord, null);
    }
  });
  if (Build.VERSION.SDK_INT >= 14) {
    this.mTitleRecycler.addOnScrollListener(new RecyclerView.OnScrollListener()
    {
      @TargetApi(14)
      public final void onScrolled(RecyclerView paramAnonymousRecyclerView, int paramAnonymousInt1, int paramAnonymousInt2)
      {
        super.onScrolled(paramAnonymousRecyclerView, paramAnonymousInt1, paramAnonymousInt2);
        paramAnonymousRecyclerView.getLayoutManager();
        int i = PlayHighlightsOverlayView.this.mTitleRecycler.getWidth();
        int j = PlayHighlightsOverlayView.this.mTitleRecycler.getLeft() + i / 2;
        for (int k = 0; k < paramAnonymousRecyclerView.getChildCount(); k++)
        {
          View localView = paramAnonymousRecyclerView.getChildAt(k);
          float f = Math.abs(LinearLayoutManager.getDecoratedLeft(localView) + LinearLayoutManager.getDecoratedMeasuredWidth(localView) / 2 - j) / PlayHighlightsOverlayView.this.mItemWidth;
          localView.setAlpha(Math.max(0.0F, 1.0F - PlayHighlightsOverlayView.this.mAlphaInterpolator.getInterpolation(f)));
        }
      }
    });
  }
}
项目:AndroidGeek    文件:RecyclerRefreshLayout.java   
/**
 * 获取ListView对象
 */
protected void getRefreshView() {
    int childs = getChildCount();
    if (childs > 0) {
        View childView = getChildAt(0);
        if (childView instanceof RecyclerView) {
            mRecyclerView = (RecyclerView) childView;
            // 设置滚动监听器给ListView, 使得滚动的情况下也可以自动加载
            mRecyclerView.setOnScrollListener(mScrollListener);
            mRecyclerView.setOnScrollListener(new OnScrollListener() {
            });
        }
    }
}
项目:Silence    文件:ConversationFragment.java   
private void initializeResources() {
  this.recipients     = RecipientFactory.getRecipientsForIds(getActivity(), getActivity().getIntent().getLongArrayExtra("recipients"), true);
  this.threadId       = this.getActivity().getIntent().getLongExtra("thread_id", -1);
  this.lastSeen       = this.getActivity().getIntent().getLongExtra(ConversationActivity.LAST_SEEN_EXTRA, -1);
  this.firstLoad      = true;

  OnScrollListener scrollListener = new ConversationScrollListener(getActivity());
  list.addOnScrollListener(scrollListener);
}
项目:Mondo    文件:MondoToolbar.java   
public OnScrollListener scrollListener(LinearLayoutManager layoutManager) {
    return new ScrollListener(layoutManager);
}
项目:Doctor    文件:ActivityAllAds.java   
@TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ads_reas_all);
    this.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    //initialize Views
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
    txtCityFilter = (TextView) findViewById(R.id.txtCityFilter);
    txtFilter = (TextView) findViewById(R.id.txtFilter);
    txtGroup = (TextView) findViewById(R.id.txtGroup);
    swipe = (SwipeRefreshLayout) findViewById(R.id.swipe);
    fab = (FloatingActionButton) findViewById(R.id.fab);

    //initialize RecyclerView
    recyclerView = (RecyclerView) findViewById(R.id.recycleView);
    recyclerView.setHasFixedSize(true);
    adapter = new PersonAdapter(mCommentList);
    manager = new WrapContentLinearLayoutManager(this);
    manager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(manager);
    recyclerView.setAdapter(adapter);

    txtCityFilter.setOnClickListener(this);
    txtFilter.setOnClickListener(this);
    fab.setOnClickListener(this);


    swipe.setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {
            recyclerView.setClickable(false);
            //   mCommentList.clear();
            isSwiped = true;
            previousTotal = 0;
            part = 0;
            updateJSONdata();
        }
    });


      /*
      visibleItemCount  --->>  how many item can show in screen
      totalItemCount    --->>  number of items that load in memory
      firstVisibleItem  --->>  first item that show in list
      part              --->>  how many item get from server in one step

       */

    recyclerView.addOnScrollListener(new OnScrollListener() {

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

            visibleItemCount = recyclerView.getChildCount();
            totalItemCount = manager.getItemCount();
            firstVisibleItem = manager.findFirstVisibleItemPosition();

            if (loading) {
                if (totalItemCount > previousTotal) {
                    loading = false;
                    previousTotal = totalItemCount;
                }
            }
            if (!loading && (totalItemCount - visibleItemCount)
                    <= (firstVisibleItem + visibleThreshold)) {
                part++;
                updateJSONdata();
                loading = true;
            }
        }
    });


    M.setCustomFont((ViewGroup) (getWindow().getDecorView()));

}
项目:App_2016    文件:JazzyRecyclerViewScrollListener.java   
public void setOnScrollListener(OnScrollListener l) {
    // hijack the scroll listener setter and have this list also notify the additional listener
    mAdditionalOnScrollListener = l;
}
项目:umeng_community_android    文件:SearchFragment.java   
/**
 * 添加相关用户显示</br>
 * 
 * @param users
 */
@Override
public void showRelativeUserView(List<CommUser> users) {
    mAdapter.getDataSource().clear();
    if (users == null || users.size() == 0) {
        mMoreView.setVisibility(View.GONE);
        // invalidate
        mAdapter.notifyDataSetChanged();
        return;
    }
    int itemWidth = mAdapter.computeWidth();
    LayoutParams params = mRecyclerView.getLayoutParams();
    if (users.size() > 4) {
        mMoreView.setVisibility(View.VISIBLE);
        params.width = (SearchUsersAdapter.MAX_SHOW_NUM - 1) * itemWidth;
    } else {
        params.width = users.size() * itemWidth;
        mMoreView.setVisibility(View.GONE);
    }
    mRecyclerView.setLayoutParams(params);
    mRecyclerView.invalidate();
    mAdapter.getDataSource().addAll(users);
    mAdapter.notifyDataSetChanged();
    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
    alphaAnimation.setDuration(400);
    alphaAnimation.setFillAfter(true);
    LayoutAnimationController layoutAnimationController = new LayoutAnimationController(
            alphaAnimation, 0.4f);
    mRecyclerView.setLayoutAnimation(layoutAnimationController);

    mRecyclerView.setOnScrollListener(new OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            int visibleItemCount = mLinearLayoutManager.getChildCount();
            int totalItemCount = mLinearLayoutManager.getItemCount();
            int pastVisiblesItems = mLinearLayoutManager.findFirstVisibleItemPosition();

            if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
                ((SearchPresenter) mPresenter).loadMoreUser();
            }
        }
    });
}
项目:FMTech    文件:PlayHeaderListLayout.java   
public void setOnScrollListener(RecyclerView.OnScrollListener paramOnScrollListener)
{
  this.mAppRecyclerViewOnScrollListener = paramOnScrollListener;
}
项目:FMTech    文件:PlayHeaderListLayout.java   
public void setOnScrollListener(AbsListView.OnScrollListener paramOnScrollListener)
{
  this.mAppListViewOnScrollListener = paramOnScrollListener;
}
项目:FMTech    文件:PlayHeaderListLayout.java   
public void setOnScrollListener(PlayScrollableContentView.OnScrollListener paramOnScrollListener)
{
  this.mAppContentViewOnScrollListener = paramOnScrollListener;
}
项目:AndroidGeek    文件:SearchFragment.java   
/**
 * 添加相关用户显示</br>
 * 
 * @param users
 */
@Override
public void showRelativeUserView(List<CommUser> users) {
    mAdapter.getDataSource().clear();
    if (users == null || users.size() == 0) {
        mMoreView.setVisibility(View.GONE);
        // invalidate
        mAdapter.notifyDataSetChanged();
        return;
    }
    int itemWidth = mAdapter.computeWidth();
    LayoutParams params = mRecyclerView.getLayoutParams();
    if (users.size() > 4) {
        mMoreView.setVisibility(View.VISIBLE);
        params.width = (SearchUsersAdapter.MAX_SHOW_NUM - 1) * itemWidth;
    } else {
        params.width = users.size() * itemWidth;
        mMoreView.setVisibility(View.GONE);
    }
    mRecyclerView.setLayoutParams(params);
    mRecyclerView.invalidate();
    mAdapter.getDataSource().addAll(users);
    mAdapter.notifyDataSetChanged();
    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
    alphaAnimation.setDuration(400);
    alphaAnimation.setFillAfter(true);
    LayoutAnimationController layoutAnimationController = new LayoutAnimationController(
            alphaAnimation, 0.4f);
    mRecyclerView.setLayoutAnimation(layoutAnimationController);

    mRecyclerView.setOnScrollListener(new OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            int visibleItemCount = mLinearLayoutManager.getChildCount();
            int totalItemCount = mLinearLayoutManager.getItemCount();
            int pastVisiblesItems = mLinearLayoutManager.findFirstVisibleItemPosition();

            if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
                ((SearchPresenter) mPresenter).loadMoreUser();
            }
        }
    });
}
项目:365browser    文件:HistoryManager.java   
/**
 * Creates a new HistoryManager.
 * @param activity The Activity associated with the HistoryManager.
 * @param isSeparateActivity Whether the history UI will be shown in a separate activity than
 *                           the main Chrome activity.
 * @param snackbarManager The {@link SnackbarManager} used to display snackbars.
 */
@SuppressWarnings("unchecked") // mSelectableListLayout
public HistoryManager(
        Activity activity, boolean isSeparateActivity, SnackbarManager snackbarManager) {
    mActivity = activity;
    mIsSeparateActivity = isSeparateActivity;
    mSnackbarManager = snackbarManager;

    mSelectionDelegate = new SelectionDelegate<>();
    mSelectionDelegate.addObserver(this);
    mHistoryAdapter = new HistoryAdapter(mSelectionDelegate, this,
            sProviderForTests != null ? sProviderForTests : new BrowsingHistoryBridge());

    // 1. Create SelectableListLayout.
    mSelectableListLayout =
            (SelectableListLayout<HistoryItem>) LayoutInflater.from(activity).inflate(
                    R.layout.history_main, null);

    // 2. Initialize RecyclerView.
    mRecyclerView = mSelectableListLayout.initializeRecyclerView(mHistoryAdapter);

    // 3. Initialize toolbar.
    mToolbar = (HistoryManagerToolbar) mSelectableListLayout.initializeToolbar(
            R.layout.history_toolbar, mSelectionDelegate, R.string.menu_history, null,
            R.id.normal_menu_group, R.id.selection_mode_menu_group,
            R.color.default_primary_color, this);
    mToolbar.setManager(this);
    mToolbar.initializeSearchView(this, R.string.history_manager_search, R.id.search_menu_id);

    // 4. Width constrain the SelectableListLayout.
    mSelectableListLayout.configureWideDisplayStyle();

    // 5. Initialize empty view.
    mEmptyView = mSelectableListLayout.initializeEmptyView(
            VectorDrawableCompat.create(
                    mActivity.getResources(), R.drawable.history_big, mActivity.getTheme()),
            R.string.history_manager_empty, R.string.history_manager_no_results);

    // 6. Create large icon bridge.
    mLargeIconBridge = new LargeIconBridge(Profile.getLastUsedProfile().getOriginalProfile());
    ActivityManager activityManager = ((ActivityManager) ContextUtils
            .getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE));
    int maxSize = Math.min((activityManager.getMemoryClass() / 4) * MEGABYTES_TO_BYTES,
            FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    // 7. Initialize the adapter to load items.
    mHistoryAdapter.initialize();

    // 8. Add scroll listener to page in more items when necessary.
    mRecyclerView.addOnScrollListener(new OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (!mHistoryAdapter.canLoadMoreItems()) return;

            // Load more items if the scroll position is close to the bottom of the list.
            LinearLayoutManager layoutManager =
                    (LinearLayoutManager) recyclerView.getLayoutManager();
            if (layoutManager.findLastVisibleItemPosition()
                    > (mHistoryAdapter.getItemCount() - 25)) {
                mHistoryAdapter.loadMoreItems();
                recordUserActionWithOptionalSearch("LoadMoreOnScroll");
            }
        }});

    // 9. Listen to changes in sign in state.
    SigninManager.get(mActivity).addSignInStateObserver(this);

    recordUserAction("Show");
}
项目:android-Stupid-Adapter    文件:XRecylerAdapter.java   
public IPauseOnScrollRecycler getOnScrollListener(OnScrollListener l) {
    return new IPauseOnScrollRecycler(this, l);
}
项目:android-Stupid-Adapter    文件:IPauseOnScrollRecycler.java   
public IPauseOnScrollRecycler(IXPauseListener adapter,
        OnScrollListener listener) {
    this.adapter = adapter;
    this.listener2 = listener;
}
项目:JazzyListView    文件:JazzyRecyclerViewScrollListener.java   
public void setOnScrollListener(OnScrollListener l) {
    // hijack the scroll listener setter and have this list also notify the additional listener
    mAdditionalOnScrollListener = l;
}
项目:umeng_community_android    文件:RecyclerRefreshLayout.java   
/**
 * 使外部可以监听到listview的滚动
 * 
 * @param listener
 */
public void addOnScrollListener(OnScrollListener listener) {
    mListViewOnScrollListener = listener;
}
项目:AndroidGeek    文件:RecyclerRefreshLayout.java   
/**
 * 使外部可以监听到listview的滚动
 * 
 * @param listener
 */
public void addOnScrollListener(OnScrollListener listener) {
    mListViewOnScrollListener = listener;
}