Пример #1
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == 0 && resultCode == Activity.RESULT_OK) {
     curPageNo = 1;
     dynamicBeanList.clear();
     dataSource.clear();
     mAdapter.notifyDataSetChanged();
     initDataSource();
   }
 }
Пример #2
0
  private void parseData(List<DynamicBean> list) {
    if (!ListUtils.isEmpty(list)) {

      for (final DynamicBean bean : list) {
        Map<String, Object> map = new HashMap<>();
        map.put(from[0], JDUtils.getRemoteImagePath(bean.getIcon()));
        map.put(from[1], bean.getName());
        map.put(from[2], JDUtils.formatDate(bean.getCreateTime(), "yyyy-MM-dd HH:mm"));
        map.put(from[3], bean.getContent());
        dataSource.add(map);
      }
      mAdapter.notifyDataSetChanged();
    }
  }
  private void parseData(List<OutReservationHistoryBean> addList) {
    if (!ListUtils.isEmpty(addList)) {

      for (final OutReservationHistoryBean bean : addList) {
        Map<String, Object> map = new HashMap<>();
        map.put(from[0], bean.getClinic_flag() == 0 ? "普通号" : bean.getDoctor_name());
        map.put(from[1], bean.getVisit_name());
        map.put(from[2], bean.getRequest_date() + "   " + bean.getTime_name());
        if (!TextUtils.isEmpty(bean.getCharge_price())) {
          map.put(from[3], "¥" + String.format(bean.getCharge_price(), ".2f"));
        } else {
          map.put(from[3], "");
        }
        map.put(from[4], bean.getVisit_flag());
        map.put("data", bean);
        dataSource.add(map);
      }
    }
    mAdapter.notifyDataSetChanged();
  }
Пример #4
0
  private void initView() {
    HashMap<Integer, String[]> fromMap = new HashMap<Integer, String[]>();
    fromMap.put(RESOUCE[0], from);
    HashMap<Integer, int[]> toMap = new HashMap<Integer, int[]>();
    toMap.put(RESOUCE[0], to);
    mAdapter =
        new SocialStreamAdapter(
            getActivity(),
            dataSource,
            RESOUCE,
            fromMap,
            toMap,
            0,
            0,
            ImageLoaderUtils.headDisplayOpts);
    dynamicLv.setAdapter(mAdapter);
    dynamicLv.setOnPullRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            curPageNo = 1;
            dynamicBeanList.clear();
            dataSource.clear();
            mAdapter.notifyDataSetChanged();
            initDataSource();
          }
        });
    mAdapter.setViewBinder(
        new SocialStreamAdapter.ViewBinder() {
          @Override
          public boolean setViewValue(View view, Object data, Object comment) {
            if (view.getId() == R.id.tv_content && data != null) {
              String str = (String) data;
              TextView tv = (TextView) view;
              tv.setText(Html.fromHtml(str));
              return true;
            }
            return false;
          }
        });
    dynamicLv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(getActivity(), CollectDetailActivity.class);
            CollectDetailActivity.dynamicBeanList = dynamicBeanList;
            intent.putExtra(DynamicDetailActivity.KEY_DYNAMIC_INDEX, position);
            intent.putExtra(DynamicDetailActivity.KEY_DYNAMIC_PAGE_INDEX, curPageNo);
            startActivityForResult(intent, 0);
          }
        });
    dynamicLv.setOnLoadMoreListener(
        new FanrRefreshListView.OnLoadMoreListener() {
          @Override
          public void loadMore() {
            initDataSource();
          }
        });

    initDataSource();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_out_reservation_history);
    ButterKnife.inject(this);
    HashMap<Integer, String[]> fromMap = new HashMap<Integer, String[]>();
    fromMap.put(RESOUCE[0], from);
    HashMap<Integer, int[]> toMap = new HashMap<Integer, int[]>();
    toMap.put(RESOUCE[0], to);
    mAdapter =
        new SocialStreamAdapter(
            this, dataSource, RESOUCE, fromMap, toMap, 0, 0, ImageLoaderUtils.headDisplayOpts);
    listView.setAdapter(mAdapter);
    listView.setOnPullRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            historyBeanList.clear();
            dataSource.clear();
            mAdapter.notifyDataSetChanged();
            initDataSource();
          }
        });

    mAdapter.setViewBinder(
        new SocialStreamAdapter.ViewBinder() {
          @Override
          public boolean setViewValue(View view, Object data, Object comment) {
            if (view.getId() == R.id.tv_reservation_status
                && data != null
                && data instanceof Integer) {

              int status = (int) data;
              TextView tv = (TextView) view;
              if (status == 0) {
                tv.setTextColor(getResources().getColor(R.color.color_theme));
                tv.setCompoundDrawablesWithIntrinsicBounds(
                    getResources().getDrawable(R.drawable.tobepaid), null, null, null);
              } else {
                tv.setCompoundDrawablesWithIntrinsicBounds(
                    getResources().getDrawable(R.drawable.icon_finish), null, null, null);
                tv.setTextColor(getResources().getColor(R.color.text_74));
              }
              return true;
            }
            return false;
          }
        });
    listView.setCanLoadMore(false);

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent =
                new Intent(OutReservationHistoryActivity.this, OutReservationDetailActivity.class);
            OutReservationHistoryBean bean =
                (OutReservationHistoryBean) dataSource.get(position).get("data");
            intent.putExtra(OutReservationDetailActivity.KEY_OUT_RESERVATION_BEAN, bean);
            startActivity(intent);
          }
        });

    JDUtils.registerLocalReceiver(mReceiver, IntentConstants.ACTION_RESERVATION_REFRESH);
    initDataSource();
  }