Exemplo n.º 1
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      ViewHolder holder = null;
      if (convertView == null) {
        convertView = mInflater.inflate((R.layout.activity_need_details_item), null);
        holder = new ViewHolder();
        holder.icon = (ImageView) convertView.findViewById(R.id.tv_need_item_gs_icon);
        holder.name = (TextView) convertView.findViewById(R.id.tv_need_item_gs_name);
        holder.state = (TextView) convertView.findViewById(R.id.tv_need_item_state);
        holder.time = (TextView) convertView.findViewById(R.id.tv_need_item_time);
        holder.agree = (Button) convertView.findViewById(R.id.btn_agree);

        convertView.setTag(holder);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }

      if (!Utils.isEmpty(bankList.get(position).getImghead())) {
        String picUrl =
            Constants.getCurrUrl()
                + Constants.CASE_IMAGE_URL_HEADER
                + bankList.get(position).getImghead();
        ImageLoader.getInstance()
            .displayImage(
                picUrl,
                holder.icon,
                TopADApplication.getSelf().getImageLoaderOption(),
                new ImageLoadingListener() {
                  @Override
                  public void onLoadingStarted(String s, View view) {}

                  @Override
                  public void onLoadingFailed(String s, View view, FailReason failReason) {}

                  @Override
                  public void onLoadingComplete(String s, View view, Bitmap bitmap) {}

                  @Override
                  public void onLoadingCancelled(String s, View view) {}
                });
      }
      holder.icon.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              Intent intent = new Intent(MyNeedDetailsActivity.this, DetailsActivity.class);
              intent.putExtra("data_details", bankList.get(position));
              startActivity(intent);
            }
          });

      // 公司名
      holder.name.setText(bankList.get(position).getCompanyname());

      // 时间
      Date date = null;
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
      try {
        date = sdf.parse(bankList.get(position).getAdddate());
      } catch (ParseException e) {
        e.printStackTrace();
      }
      //            holder.time.setText(Utils.getTimeFormatText(date));
      holder.time.setVisibility(View.INVISIBLE);
      // 同意
      holder.agree.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              // 拼接url
              StringBuffer sb = new StringBuffer();
              sb.append(Constants.getCurrUrl()).append(Constants.URL_NEED_START).append("?");
              String url = sb.toString();
              RequestParams rp = new RequestParams();
              rp.add("needid", needId);
              rp.add("userid1", grabSingleBean.getUserid());
              rp.add("userid2", bankList.get(position).getUserid());
              rp.add("token", TopADApplication.getSelf().getToken());
              postWithLoading(
                  url,
                  rp,
                  false,
                  new HttpCallback() {
                    @Override
                    public <T> void onModel(int respStatusCode, String respErrorMsg, T t) {
                      mLYProductFinish.setVisibility(View.VISIBLE);
                      mFinish.setVisibility(View.VISIBLE);
                      mTVPrompt.setVisibility(View.VISIBLE);
                      //                            mLYTrust.setVisibility(View.GONE);

                      mProjectTrust.setVisibility(View.GONE);
                      mTVPrompt2.setVisibility(View.GONE);
                      mProjectCancel.setVisibility(View.GONE);
                      mListview.setVisibility(View.GONE);
                      mTVState.setVisibility(View.VISIBLE);
                      state = "1";
                      // 类别
                      if (!Utils.isEmpty(grabSingleBean.getType1())
                          && !Utils.isEmpty(grabSingleBean.getType2())) {
                        SpannableStringBuilder ssb =
                            new SpannableStringBuilder(
                                grabSingleBean.getType1() + "-" + grabSingleBean.getType2());
                        mTVTime.setText(ssb.toString());
                        mTVTime.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                      }
                      // 时间
                      if (!Utils.isEmpty(grabSingleBean.getEnddate())) {
                        String[] sourceStrArray = grabSingleBean.getEnddate().split(" ");
                        mTVType.setText(sourceStrArray[0]);
                        mTVType.setCompoundDrawablesWithIntrinsicBounds(
                            getResources().getDrawable(R.drawable.pic_time), null, null, null);
                      }

                      Message msg = new Message();
                      msg.what = GET_USERINFE;
                      Bundle b = new Bundle();
                      b.putString("userid", bankList.get(position).getUserid());
                      msg.setData(b);
                      updateHandler.sendMessage(msg);
                    }

                    @Override
                    public void onFailure(BaseBean base) {
                      int status = base.getStatus(); // 状态码
                      String msg = base.getMsg(); // 错误信息
                      //                            ToastUtil.show(mContext, "status = " + status +
                      // "\n"
                      //                                    + "msg = " + msg);
                    }
                  },
                  BaseBean.class);
            }
          });
      return convertView;
    }
Exemplo n.º 2
0
  @Override
  public void onClick(View v) {
    super.onClick(v);
    switch (v.getId()) {
        // 项目完成
      case R.id.btn_finish:
        DialogManager.showDialog(
            MyNeedDetailsActivity.this,
            null,
            "点击确定,将完成项目。托管的项目款将直接打入接单方钱包。",
            "确定",
            "",
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                // 拼接url
                StringBuffer sb = new StringBuffer();
                sb.append(Constants.getCurrUrl()).append(Constants.URL_NEED_ENDPRJ).append("?");
                String url = sb.toString();
                RequestParams rp = new RequestParams();
                rp.add("needid", needId);
                rp.add("userid", grabSingleBean.getUserid());
                rp.add("token", TopADApplication.getSelf().getToken());
                postWithLoading(
                    url,
                    rp,
                    false,
                    new HttpCallback() {
                      @Override
                      public <T> void onModel(int respStatusCode, String respErrorMsg, T t) {
                        mFinish.setVisibility(View.GONE);
                        mProjectTrust.setVisibility(View.GONE);
                        mTVPrompt2.setVisibility(View.GONE);
                        mTVPrompt.setVisibility(View.GONE);
                        mTVProgectState.setText("项目已完成");
                      }

                      @Override
                      public void onFailure(BaseBean base) {
                        int status = base.getStatus(); // 状态码
                        String msg = base.getMsg(); // 错误信息
                        //                        ToastUtil.show(mContext, "status = " + status +
                        // "\n"
                        //                                + "msg = " + msg);
                      }
                    },
                    BaseBean.class);
              }
            },
            null,
            true,
            null);

        break;

        // 项目款托管
      case R.id.btn_project_trust:
        AliPayUtil aliPayUtil = new AliPayUtil(MyNeedDetailsActivity.this);
        aliPayUtil.aliPay(
            MyNeedDetailsActivity.this,
            "项目款托管",
            TopADApplication.getSelf().getUserId() + "|3|" + grabSingleBean.getId(),
            grabSingleBean.getBudget());
        break;

        // 项目取消
      case R.id.btn_project_cancel:
        // 拼接url
        StringBuffer sbcancel = new StringBuffer();
        sbcancel.append(Constants.getCurrUrl()).append(Constants.URL_NEED_DELPROJECT).append("?");
        String urlcancel = sbcancel.toString();
        RequestParams rpcancel = new RequestParams();
        rpcancel.add("needid", needId);
        rpcancel.add("userid", grabSingleBean.getUserid());
        rpcancel.add("token", TopADApplication.getSelf().getToken());
        postWithLoading(
            urlcancel,
            rpcancel,
            false,
            new HttpCallback() {
              @Override
              public <T> void onModel(int respStatusCode, String respErrorMsg, T t) {
                finish();
              }

              @Override
              public void onFailure(BaseBean base) {
                int status = base.getStatus(); // 状态码
                String msg = base.getMsg(); // 错误信息
                ToastUtil.show(mContext, "status = " + status + "\n" + "msg = " + msg);
              }
            },
            BaseBean.class);
        break;

      default:
        break;
    }
  }