private void initRefreshLayout() {
    mRefreshLayout.setWaveColor(0x000);
    mRefreshLayout.setIsOverLay(true);
    mRefreshLayout.setWaveShow(true);
    mRefreshLayout.setLoadMore(true);
    mRefreshLayout.setMaterialRefreshListener(
        new MaterialRefreshListener() {
          @Override
          public void onRefresh(MaterialRefreshLayout materialRefreshLayout) {
            new Handler()
                .postDelayed(
                    new Runnable() {
                      @Override
                      public void run() {
                        mRefreshLayout.finishRefresh();
                      }
                    },
                    2000);
          }

          @Override
          public void onRefreshLoadMore(MaterialRefreshLayout materialRefreshLayout) {
            new Handler()
                .postDelayed(
                    new Runnable() {
                      @Override
                      public void run() {
                        mRefreshLayout.finishRefreshLoadMore();
                      }
                    },
                    2000);
          }
        });
  }
示例#2
0
  private void Data() {
    viewSelectorLayout.show_LoadingView();
    getWeekBookData();

    refreshLayout.setMaterialRefreshListener(
        new MaterialRefreshListener() {
          @Override
          public void onRefresh(MaterialRefreshLayout materialRefreshLayout) {
            getWeekBookData();
          }
        });
  }
  /** 初始化 */
  private void initView() {
    findViewById(R.id.tv_cancel).setOnClickListener(this);
    listView = $(R.id.lv_list);
    refreshLayout = $(R.id.refresh_layout);
    View emptyView = $(R.id.list_empty_view);
    emptyView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            getNetDatas();
          }
        });
    listView.setEmptyView(emptyView);
    scheduleUserGroupAdapter = new ScheduleUserGroupAdapter(this);
    listView.setAdapter(scheduleUserGroupAdapter);
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Creator p = scheduleUserGroupAdapter.getItem(position);
            Intent intent =
                new Intent(ScheduleOtherUserListActivity.this, ScheduleOtherListActivity.class);
            intent.putExtra("otherUserId", p.getId());
            startActivity(intent);
          }
        });
    refreshLayout.setLoadMore(true);
    refreshLayout.setMaterialRefreshListener(
        new MaterialRefreshListener() {
          @Override
          public void onRefresh(MaterialRefreshLayout materialRefreshLayout) {
            getNetDatas();
          }

          @Override
          public void onRefreshLoadMore(MaterialRefreshLayout materialRefreshLayout) {
            getNetDatasMore();
          }
        });
    getNetDatas();
  }
  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_list);
    initsToolbar();

    materialRefreshLayout = (MaterialRefreshLayout) findViewById(R.id.refresh);
    //        materialRefreshLayout.setWaveColor(0xffffffff);
    //        materialRefreshLayout.setIsOverLay(false);
    //        materialRefreshLayout.setWaveShow(false);
    //        materialRefreshLayout.setShowProgressBg(true);
    //
    // materialRefreshLayout.setProgressColors(getResources().getIntArray(R.array.material_colors));
    //        materialRefreshLayout.setShowArrow(true);
    materialRefreshLayout.setMaterialRefreshListener(
        new MaterialRefreshListener() {
          @Override
          public void onRefresh(final MaterialRefreshLayout materialRefreshLayout) {
            materialRefreshLayout.postDelayed(
                new Runnable() {
                  @Override
                  public void run() {
                    materialRefreshLayout.finishRefresh();
                  }
                },
                3000);
          }

          @Override
          public void onfinish() {
            Toast.makeText(RecyclerViewActivity.this, "finish", Toast.LENGTH_LONG).show();
          }
        });
    RecyclerView rv = (RecyclerView) findViewById(R.id.recyclerview);
    setupRecyclerView(rv);
  }