Exemple #1
0
  private void setupComments() {
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    rvComments.setLayoutManager(linearLayoutManager);
    rvComments.setHasFixedSize(true);

    botAdapter = new BotAdapter(this);
    rvComments.setAdapter(botAdapter);
    rvComments.setOverScrollMode(View.OVER_SCROLL_NEVER);
    rvComments.setOnScrollListener(
        new RecyclerView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
              botAdapter.setAnimationsLocked(true);
            }
          }
        });
  }
  public void initRecyclerView(View view) {
    recyclerView = (RecyclerView) view.findViewById(R.id.v_scroll);
    recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);

    LinearLayoutManager mLayoutMgr = new LinearLayoutManager(getContext());
    recyclerView.setLayoutManager(mLayoutMgr);

    recyclerAdapter = new RecyclerAdapter();
    recyclerView.setAdapter(recyclerAdapter);
    recyclerView.addOnScrollListener(mOnScrollListener);

    if (mLoadingFooter == null) {
      mLoadingFooter = new LoadingFooter(getContext());
      recyclerAdapter.setFooterView(mLoadingFooter);
    }

    getDataTask();
  }
  private void setupAdapter() {

    this.swipeRefreshLayout.setColorSchemeResources(Constants.colors);

    this.compositeSubscription.add(
        RxSwipeRefreshLayout.refreshes(swipeRefreshLayout)
            .compose(ListActivity.this.<Void>bindUntilEvent(ActivityEvent.DESTROY))
            .subscribe(
                new SimpleObserver<Void>() {
                  @Override
                  public void onNext(Void o) {
                    /*refresh*/
                    listPresenter.loadData();
                  }
                }));

    gridLayoutManager = new GridLayoutManager(ListActivity.this, 2);
    gridLayoutManager.setSmoothScrollbarEnabled(true);

    gridLayoutManager.setSpanSizeLookup(
        new GridLayoutManager.SpanSizeLookup() {
          @Override
          public int getSpanSize(int position) {
            /*position == 0*/
            return forecastAdapter.isHeader(position) ? gridLayoutManager.getSpanCount() : 1;
          }
        });

    forecastAdapter = new ForecastAdapter(ListActivity.this);
    forecastAdapter.setCallback(ListActivity.this);

    recyclerView.setLayoutManager(gridLayoutManager);
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(forecastAdapter);
    recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    recyclerView.addItemDecoration(new GridDecoration(ListActivity.this));
  }
 public void setOverScrollMode(int overScrollMode) {
   super.setOverScrollMode(overScrollMode);
   this.mOverScrollMode = overScrollMode;
 }