Example #1
0
  @Override
  public Void doInBackground(Void... params) {

    // 返回
    if (isRunning) return null;

    User user = BookApp.getUser();

    EditText input = (EditText) caller.findViewById(R.id.consume_zfb_input);

    double money = 0;
    if (StringUtils.isNotBlank(input.getText().toString()) && user != null) {
      money = Double.parseDouble(input.getText().toString());
      if (money < Constants.CONSUME_PAY_MIN) {
        return null;
      }

      AliPayBean aliPayBean = HttpImpl.alipayApp(user.getUid(), money);

      final String orderInfo = URLDecoder.decode(aliPayBean.getContent());
      final String encodeStrSign = aliPayBean.getSign();
      final String signType = aliPayBean.getSign_type();

      aliPayBean = new AliPayBean();

      HANDLER.post(
          new Runnable() {

            @Override
            public void run() {
              // 执行支付
              alipay.pay(orderInfo, encodeStrSign, signType);
            }
          });
    } else {
      HANDLER.post(
          new Runnable() {
            @Override
            public void run() {
              //						Toast.makeText(caller, "最低充值限额" + Constants.CONSUME_PAY_MIN + "元",
              // Toast.LENGTH_LONG).show();
              ViewUtils.showDialog(caller, "请输入20以上的整数", R.drawable.infoicon, null);
            }
          });
    }

    return null;
  }
Example #2
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.updateinfo);
    CloseActivity.add(this);

    setTopBar();

    email = (EditText) findViewById(R.id.updateInfo_email);

    update = (Button) findViewById(R.id.updateInfo_over);
    update.setOnClickListener(this);

    user = BookApp.getUser();
    uid = user.getUid();
    token = user.getToken();

    if (user == null) {
      Toast.makeText(UpdateInfo.this, "您尚未登录,请先登录!", Toast.LENGTH_LONG).show();
      Intent intent = new Intent(UpdateInfo.this, LoginActivity.class);
      startActivity(intent);
      finish();
      return;
    }

    new Thread() {
      public void run() {
        JSONObject json = HttpImpl.syncUserInfo(uid, token);
        if (json == null) {
          handler.sendEmptyMessage(123);
          return;
        }
        user2 = JsonToBean.JsonToUser(json);
        if (user2 != null) {
          handler.sendEmptyMessage(124);
        }
      };
    }.start();

    right1.setOnClickListener(this);
  }
Example #3
0
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case 123:
              Toast.makeText(UpdateInfo.this, getString(R.string.network_err), Toast.LENGTH_LONG)
                  .show();
              finish();
              break;
            case 124:
              username = (TextView) findViewById(R.id.updateInfo_username);
              username.setText(user2.getUsername());
              email.setText(user2.getEmail());
              break;
            case 1:
              if (progress != null && progress.isShowing()) {
                progress.dismiss();
              }
              Toast.makeText(UpdateInfo.this, "修改成功!", Toast.LENGTH_SHORT).show();

              Intent intent = new Intent(UpdateInfo.this, MainActivity.class);
              intent.putExtra("id", R.id.main_usercenter);
              startActivity(intent);

              BookApp.getUser().setEmail(e);

              finish();
              break;
            case 2:
              if (progress != null && progress.isShowing()) {
                progress.dismiss();
              }
              Toast.makeText(UpdateInfo.this, "修改失败,请稍后再试!", Toast.LENGTH_SHORT).show();

              Intent i = new Intent(UpdateInfo.this, MainActivity.class);
              i.putExtra("id", R.id.main_usercenter);
              startActivity(i);

              finish();
              break;
          }
        };