Java Code Examples for android.support.v7.widget.RecyclerView#OnFlingListener
The following examples show how to use
android.support.v7.widget.RecyclerView#OnFlingListener .
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: PagerLayoutManager.java From YCScrollPager with Apache License 2.0 | 6 votes |
/** * attach到window窗口时,该方法必须调用 * @param recyclerView recyclerView */ @Override public void onAttachedToWindow(RecyclerView recyclerView){ if (recyclerView == null) { throw new IllegalArgumentException("The attach RecycleView must not null!!"); } super.onAttachedToWindow(recyclerView); this.mRecyclerView = recyclerView; if (mPagerSnapHelper==null){ init(); } try { //attachToRecyclerView源码上的方法可能会抛出IllegalStateException异常,这里手动捕获一下 RecyclerView.OnFlingListener onFlingListener = mRecyclerView.getOnFlingListener(); //源码中判断了,如果onFlingListener已经存在的话,再次设置就直接抛出异常,那么这里可以判断一下 if (onFlingListener==null){ mPagerSnapHelper.attachToRecyclerView(mRecyclerView); } } catch (IllegalStateException e){ e.printStackTrace(); } mRecyclerView.addOnChildAttachStateChangeListener(mChildAttachStateChangeListener); }
Example 2
Source File: RefreshContentWrapper.java From CollapsingRefresh with Apache License 2.0 | 5 votes |
void attach(RecyclerView recyclerView) { //获得原始监听器,用作转发 Field[] declaredFields = RecyclerView.class.getDeclaredFields(); if (declaredFields != null) { for (Field field : declaredFields) { if (RecyclerView.OnFlingListener.class.equals(field.getType())) { try { field.setAccessible(true); Object listener = field.get(recyclerView); if (listener != null && !recyclerView.equals(listener)) { mFlingListener = (RecyclerView.OnFlingListener) listener; } } catch (IllegalAccessException e) { e.printStackTrace(); } } } } recyclerView.addOnScrollListener(this); recyclerView.setOnFlingListener(new RecyclerView.OnFlingListener() { @Override public boolean onFling(int velocityX, int velocityY) { if (mFlingListener != null) { mFlingListener.onFling(velocityX, velocityY); } lastFlingTime = System.currentTimeMillis(); return false; } }); }
Example 3
Source File: FragmentPageSnapAdapter.java From RecyclerPager with Apache License 2.0 | 5 votes |
@Override public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) { super.onAttachedToRecyclerView(recyclerView); RecyclerView.OnFlingListener flingListener = recyclerView.getOnFlingListener(); if (flingListener instanceof SnapHelper) { mSnapHelper = (SnapHelper) flingListener; } recyclerView.addOnScrollListener(mScrollListener); }
Example 4
Source File: RecyclerWidget.java From relight with Apache License 2.0 | 4 votes |
public RecyclerWidget<V> onFling(@Nullable RecyclerView.OnFlingListener onFlingListener) { view.setOnFlingListener(onFlingListener); return self(); }
Example 5
Source File: RecyclerViewv7DSL.java From anvil with MIT License | 4 votes |
public static Void onFling(RecyclerView.OnFlingListener arg) { return BaseDSL.attr("onFling", arg); }
Example 6
Source File: IRecyclerView.java From tenor-android-core with Apache License 2.0 | 2 votes |
/** * @since v24.2.0 */ RecyclerView.OnFlingListener getOnFlingListener();
Example 7
Source File: IRecyclerView.java From tenor-android-core with Apache License 2.0 | 2 votes |
/** * @since v24.2.0 */ void setOnFlingListener(RecyclerView.OnFlingListener onFlingListener);