Esempio n. 1
0
 @Override
 protected void onResume() {
   user = GeekApplication.getUser();
   if (user != null) {
     userId = user.getId();
     token = user.getToken();
   }
   getAddressList();
   super.onResume();
 }
 @Override
 public void onResponse(User o) {
   loadingDialog.dismiss();
   if (o.getStatus() == 200) {
     if (time == null) {
       time = new TimeCount(60000, 1000);
     }
     time.start();
   } else {
     new ToastView(BindAccountActivity.this, o.getErrorMsg()).show();
   }
 }
 private void authRegister() {
   if (mPhoneET.getText().toString().length() == 0) {
     new ToastView(this, "请输入手机号").show();
     return;
   }
   if (mCodeET.getText().toString().length() == 0) {
     new ToastView(this, "请输入验证码").show();
     return;
   }
   if (user != null) {
     APIControl.getInstance()
         .authRegister(
             this,
             user.getOpenId(),
             mPhoneET.getText().toString(),
             mCodeET.getText().toString(),
             user.getAccessToken(),
             type,
             user.getImgUrl(),
             user.getNickname(),
             user.getSex(),
             new DataResponseListener<UserData>() {
               @Override
               public void onResponse(UserData user) {
                 //                sendBroadcast(new Intent("com.geek.geekmall.action.auth"));
                 if (user.getStatus() != 200) {
                   new ToastView(BindAccountActivity.this, user.getErrorMsg()).show();
                 } else {
                   GeekApplication.setUser(user.getData().getUserInfo());
                   SharedPreUtil.getInstance().putUser(user.getData().getUserInfo());
                   GeekApplication.setAgentInfo(user.getData().getAgentInfo());
                   GeekApplication.setOrderInfo(user.getData().getOrderInfo());
                   GeekApplication.setUserMoney(user.getData().getUserMoney());
                   //                    sendBroadcast(new
                   // Intent("com.geek.geekmall.action.auth.sina"));
                   //                            Intent intent = new
                   // Intent(BindAccountActivity.this, MainActivity.class);
                   //                            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                   //                            startActivity(intent);
                   sendBroadcast(new Intent("com.geek.geekmall.action.user_login"));
                   finish();
                 }
               }
             },
             errorListener(""));
   }
 }
  @Override
  protected void onResume() {
    super.onResume();
    user = GeekApplication.getUser();
    if (user != null) {
      userId = user.getId();
      token = user.getToken();
      getCarts();

    } else {
      userId = "";
      token = "";
      mListView.setVisibility(View.GONE);
      mBottomLayout.setVisibility(View.GONE);
      mEmptyLayout.setVisibility(View.VISIBLE);
    }
    getGuessLike();
  }
  private void initView() {
    mBackView = (TextView) findViewById(R.id.back);
    mBackView.setOnClickListener(this);
    mTitleView = (TextView) findViewById(R.id.title);
    mCodeBtn = (Button) findViewById(R.id.code_btn);
    mCodeBtn.setOnClickListener(this);
    mNextBtn = (Button) findViewById(R.id.next);
    mNextBtn.setOnClickListener(this);
    mNameView = (TextView) findViewById(R.id.name);
    mAvatorView = (ImageView) findViewById(R.id.avator);

    mPhoneET = (EditText) findViewById(R.id.phone);
    mCodeET = (EditText) findViewById(R.id.code);
    mPhoneET.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void afterTextChanged(Editable s) {

            Pattern pattern = Pattern.compile(Constant.MOBILE_REG);
            if (pattern.matcher(mPhoneET.getText().toString()).matches()) {
              mCodeBtn.setEnabled(true);
            } else {
              mCodeBtn.setEnabled(false);
            }
          }
        });
    if (user != null) {
      mNameView.setText(user.getNickname());
      ImageLoader.getInstance(this)
          .getPicasso()
          .load(user.getImgUrl())
          .transform(ImageLoader.getInstance(this).new RoundedCornersTransformation(120))
          .placeholder(R.drawable.avatar_default)
          .into(mAvatorView);
    }
  }
Esempio n. 6
0
  private void deleteAddress(final Address address) {
    loadingDialog.show();
    APIControl.getInstance()
        .deleteAddress(
            this,
            address.getId(),
            user.getId(),
            user.getToken(),
            new DataResponseListener<CommonData>() {

              @Override
              public void onResponse(CommonData o) {
                loadingDialog.dismiss();
                if (o.getStatus() == 200) {
                  getAddressList();
                } else {

                }
              }
            },
            errorListener(""));
  }