コード例 #1
0
  @Override
  public void onRequestSuccess(String reqId, Object result) {

    // 账号管理信息
    if (reqId.equals(kREQ_ID_findUserAccountManagerDTOByUserId)) {
      if (result != null) {
        userAccountManagerDTOs = (List<UserAccountManagerDTO>) result;
        showAccountInfo();
      }
    }

    if (reqId.equals(kREQ_ID_updateImgInUserHomePage)) {
      if (result != null) {
        int resultCode = (Integer) result;
        if (resultCode == 0) {
          userPhotoImg.setImageBitmap(modifiedUserPhoto);
          editHeadBtn.setVisibility(View.VISIBLE);
          //                    Intent intent = new Intent(Constants.kACTION_MODIFIED_PHOTO);
          ////					sendBroadcast(intent);
          setResult(RESULT_OK);
        } else {
          Toast.makeText(this, "修改头像失败", Toast.LENGTH_SHORT).show();
        }
        if (tempFile != null) {
          tempFile.delete();
        }
      }
    }

    if (reqId.equals(kREQ_ID_bindThirdPortrait)) {
      if (result != null) {
        int resultCode = (Integer) result;
        if (resultCode == 0) {

          // editHeadBtn.setVisibility(View.VISIBLE);
          // Intent intent = new Intent(kACTION_MODIFIED_PHOTO);
          // sendBroadcast(intent);
          Log.i(TAG, "上传绑定的第三方账号的头像成功");
        } else {
          // Toast.makeText(this, "改头像失败", Toast.LENGTH_SHORT).show();
          Log.e(TAG, "上传绑定的第三方账号的头像失败");
        }
      }
    }

    // 绑定qq 账号
    if (reqId.equals(kREQ_ID_bindQQAccount)) {
      if (result != null) {
        int resultCode = (Integer) result;
        // 0 成功,-1 绑定失败,2 手机号码已经存在,3 邮箱已经存在,9 qq 已经绑定, 10 微博已经绑定
        if (resultCode == 0) {
          UserAccountManagerDTO accountManagerDTO = new UserAccountManagerDTO();
          accountManagerDTO.setBindType(BUND_TYPE_QQ);
          accountManagerDTO.setBindValue(bindOpenId);
          userAccountManagerDTOs.add(accountManagerDTO);
          showAccountInfo();
          getUserPhotoInThird(BUND_TYPE_QQ, bindOpenId);
          Toast.makeText(this, "绑定QQ账号成功", Toast.LENGTH_SHORT).show();
        }
        if (resultCode == -1) {
          Toast.makeText(this, "绑定QQ账号失败", Toast.LENGTH_SHORT).show();
        }
        if (resultCode == 9) {
          Toast.makeText(this, "该QQ已被其他账号绑定", Toast.LENGTH_SHORT).show();
        }
      }
    }
    // 綁定微信账号
    if (reqId.equals(kREQ_ID_bindWechatAccount)) {
      if (result != null) {
        int resultCode = (Integer) result;
        // 0 成功,-1失败, 44 微博已经绑定
        if (resultCode == 0) {
          UserAccountManagerDTO accountManagerDTO = new UserAccountManagerDTO();
          accountManagerDTO.setBindType(BUND_TYPE_WECHAT);
          accountManagerDTO.setBindValue(bindOpenId);
          userAccountManagerDTOs.add(accountManagerDTO);
          showAccountInfo();
          getUserPhotoInThird(BUND_TYPE_WECHAT, bindOpenId);
          Toast.makeText(this, "绑定微信账号成功", Toast.LENGTH_SHORT).show();
        }
        if (resultCode == -1) {
          Toast.makeText(this, "绑定微信账号失败", Toast.LENGTH_SHORT).show();
        }
        if (resultCode == 44) {
          Toast.makeText(this, "该微信已被其他账号绑定", Toast.LENGTH_SHORT).show();
        }
      }
    }
    // 绑定微博账号
    if (reqId.equals(kREQ_ID_bindWeiboAccount)) {
      if (result != null) {
        int resultCode = (Integer) result;
        // 0 成功,-1 绑定失败,2 手机号码已经存在,3 邮箱已经存在,9 qq 已经绑定, 10 微博已经绑定
        if (resultCode == 0) {
          UserAccountManagerDTO accountManagerDTO = new UserAccountManagerDTO();
          accountManagerDTO.setBindType(BUND_TYPE_WEIBO);
          accountManagerDTO.setBindValue(bindOpenId);
          userAccountManagerDTOs.add(accountManagerDTO);
          showAccountInfo();
          getUserPhotoInThird(BUND_TYPE_WEIBO, bindOpenId);
          Toast.makeText(this, "绑定微博账号成功", Toast.LENGTH_SHORT).show();
        }
        if (resultCode == -1) {
          Toast.makeText(this, "绑定微博账号失败", Toast.LENGTH_SHORT).show();
        }
        if (resultCode == 10) {
          Toast.makeText(this, "该微博已被其他账号绑定", Toast.LENGTH_SHORT).show();
        }
      }
    }

    if (reqId.equals(kREQ_ID_unbindQQAccount)) {
      int resultCode = (Integer) result;
      if (resultCode == 0) {
        Toast.makeText(this, "解除QQ绑定成功", Toast.LENGTH_SHORT).show();
        removeBindAccountInList(qqOpenId);
        qqOpenId = null;
        showAccountInfo();
      } else {
        Toast.makeText(this, "解除QQ绑定失败", Toast.LENGTH_SHORT).show();
      }
    }
    if (reqId.equals(kREQ_ID_unbindWechatAccount)) {
      int resultCode = (Integer) result;
      if (resultCode == 0) {
        Toast.makeText(this, "解除微信绑定成功", Toast.LENGTH_SHORT).show();
        removeBindAccountInList(wechatOpenId);
        wechatOpenId = null;
        showAccountInfo();
      } else {
        Toast.makeText(this, "解除微信绑定失败", Toast.LENGTH_SHORT).show();
      }
    }
    if (reqId.equals(kREQ_ID_unbindWeiboAccount)) {
      int resultCode = (Integer) result;
      if (resultCode == 0) {
        Toast.makeText(this, "解除微博绑定成功", Toast.LENGTH_SHORT).show();
        removeBindAccountInList(weiboOpenId);
        weiboOpenId = null;
        showAccountInfo();
      } else {
        Toast.makeText(this, "解除微博绑定失败", Toast.LENGTH_SHORT).show();
      }
    }

    // 第三方头像列表
    if (reqId.equals(kREQ_ID_findThirdImgURLDTOByUserId)) {
      if (result != null) {
        thirdImgUrlDTOs = (List<ThirdImgUrlDTO>) result;
      }
      showThirdImg();
    }
  }