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


Java OnScrollListener类代码示例

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


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

示例1: initSearch

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
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);
            }
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:SearcherActivity.java

示例2: initializeRecyclerView

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:28,代码来源:SelectableListLayout.java

示例3: onScrollStateChanged

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
@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);

}
 
开发者ID:comcp,项目名称:android-Stupid-Adapter,代码行数:20,代码来源:IPauseOnScrollRecycler.java

示例4: AdapterRules

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
/** 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();
}
 
开发者ID:Mark-Lauman,项目名称:DominionPicker,代码行数:25,代码来源:AdapterRules.java

示例5: initializeResources

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:10,代码来源:ConversationFragment.java

示例6: initLoadMore

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
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();
            }
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:PPRecyclerView.java

示例7: setAbsListViewOnScrollListener

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
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();
        }
    }
}
 
开发者ID:foreverxiongtao,项目名称:CustomerLib,代码行数:34,代码来源:XRefreshLayout.java

示例8: getRefreshView

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
/**
 * 获取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() {
            });
        }
    }
}
 
开发者ID:umeng,项目名称:umeng_community_android,代码行数:17,代码来源:RecyclerRefreshLayout.java

示例9: onFinishInflate

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
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)));
        }
      }
    });
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:40,代码来源:PlayHighlightsOverlayView.java

示例10: scrollListener

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
public OnScrollListener scrollListener(LinearLayoutManager layoutManager) {
    return new ScrollListener(layoutManager);
}
 
开发者ID:savvasdalkitsis,项目名称:Mondo,代码行数:4,代码来源:MondoToolbar.java

示例11: onCreate

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
@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()));

}
 
开发者ID:maysamrasoli,项目名称:Doctor,代码行数:82,代码来源:ActivityAllAds.java

示例12: setOnScrollListener

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
public void setOnScrollListener(OnScrollListener l) {
    // hijack the scroll listener setter and have this list also notify the additional listener
    mAdditionalOnScrollListener = l;
}
 
开发者ID:Aparoksha,项目名称:App_2016,代码行数:5,代码来源:JazzyRecyclerViewScrollListener.java

示例13: showRelativeUserView

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
/**
 * 添加相关用户显示</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();
            }
        }
    });
}
 
开发者ID:umeng,项目名称:umeng_community_android,代码行数:48,代码来源:SearchFragment.java

示例14: setOnScrollListener

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
public void setOnScrollListener(RecyclerView.OnScrollListener paramOnScrollListener)
{
  this.mAppRecyclerViewOnScrollListener = paramOnScrollListener;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:5,代码来源:PlayHeaderListLayout.java

示例15: HistoryManager

import android.support.v7.widget.RecyclerView.OnScrollListener; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:77,代码来源:HistoryManager.java


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