Example #1
0
  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));
  }
Example #2
0
 @Override
 public void showError(int messageId) {
   RxSwipeRefreshLayout.refreshing(swipeRefreshLayout).call(false);
   if (!progressLayout.isError()) progressLayout.showError(messageId, retryClickListener);
 }
Example #3
0
 @Override
 public void showContent() {
   RxSwipeRefreshLayout.refreshing(swipeRefreshLayout).call(false);
   if (!progressLayout.isContent()) progressLayout.showContent();
 }