Ejemplo n.º 1
0
 @Override
 public void handleMessage(Message msg) {
   super.handleMessage(msg);
   if (swipe != null && adapter != null) {
     swipe.setRefreshing(false);
     swipe.setLoading(false);
     adapter.notifyDataSetChanged();
   }
 }
Ejemplo n.º 2
0
  private void operateView() {
    adapter = new MyTestAdapter(getActivity(), billList);
    mBillLv.setAdapter(adapter);
    swipe.setColorSchemeResources(R.color.default_green_light, R.color.default_green_dark);
    swipe.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            if (!swipe.isLoading()) {
              currentPage = 1;
              refreshOrLoad();
            } else {
              swipe.setRefreshing(false);
            }
          }
        });
    swipe.setOnLoadListener(
        new LoadRefreshLayout.OnLoadListener() {
          @Override
          public void load() {
            if (currentPage == Constants.totalPage) {
              UIUtils.showToastSafe("no more data!");
            }
            if (!swipe.isRefreshing()
                && Constants.totalPage > 1
                && currentPage < Constants.totalPage) {
              currentPage++;
              refreshOrLoad();
            } else {
              swipe.setLoading(false);
            }
          }
        });

    mBillLv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (billList != null && billList.size() >= position) {
              BillBean bean = billList.get(position);
              ((MainActivity) getActivity()).onBillDetailClick(bean);
            }
          }
        });
  }