Example #1
0
  /**
   * 显示高清头像
   *
   * @param user
   * @return
   */
  public static String getUserPhoto(WeiBoUser user) {
    if (user == null) return "";

    if (AppSettings.isLargePhoto()) {
      return user.getAvatar_large();
    }

    return user.getProfile_image_url();
  }
Example #2
0
 public static String getGender(WeiBoUser user) {
   Resources res = GlobalContext.getInstance().getResources();
   if (user != null) {
     if ("m".equals(user.getGender())) {
       return res.getString(R.string.msg_male);
     } else if ("f".equals(user.getGender())) {
       return res.getString(R.string.msg_female);
     } else if ("n".equals(user.getGender())) {
       return res.getString(R.string.msg_gender_unknow);
     }
   }
   return "";
 }
Example #3
0
    @Override
    public WeiBoUser workInBackground(String... params) throws TaskException {
      // 1、请求授权
      AccessToken accessToken = SinaSDK.getInstance(null).getAccessToken(params[0]);
      AccountBean account = new AccountBean();
      account.setToken(accessToken);

      // 2、加载用户信息
      publishProgress(R.string.account_load_userinfo);
      WeiBoUser user = SinaSDK.getInstance(accessToken).userShow(accessToken.getUid(), null);

      // 3、加载分组信息
      publishProgress(R.string.account_load_groups);
      Groups groups = SinaSDK.getInstance(accessToken).friendshipGroups();

      // 4、更新新账户到DB
      account.setUser(user);
      account.setGroups(groups);
      account.setAccount(mAccount);
      account.setPassword(mPassword);
      account.setUserId(user.getIdstr());
      // 2014-09-18 移除了所有账户信息,包括LoggedIn,所以需要调用AccountFragment.login()
      AccountDB.remove(account.getUserId());
      AccountDB.newAccount(account);

      if (AppContext.isLogedin()
          &&
          // 2014-09-18 仅更新登录用户数据
          AppContext.getUser().getIdstr().equals(user.getIdstr())) {
        AccountFragment.login(account, false);
      }

      if (getActivity() != null) {
        Intent data = new Intent();
        data.putExtra("token", accessToken);
        getActivity().setResult(Activity.RESULT_OK, data);
      }

      return user;
    }
Example #4
0
  public static void setImageVerified(ImageView imgVerified, WeiBoUser user) {
    // 2014-08-27 新增判断,VerifiedType存在为null的情况
    if (user == null || user.getVerified_type() == null) {
      imgVerified.setVisibility(View.GONE);
      return;
    }

    // 黄V
    if (user.getVerified_type() == 0) {
      imgVerified.setImageResource(R.drawable.avatar_vip);
    }
    // 200:初级达人 220:高级达人
    else if (user.getVerified_type() == 200 || user.getVerified_type() == 220) {
      imgVerified.setImageResource(R.drawable.avatar_grassroot);
    }
    // 蓝V
    else if (user.getVerified_type() > 0) {
      imgVerified.setImageResource(R.drawable.avatar_enterprise_vip);
    }
    if (user.getVerified_type() >= 0) imgVerified.setVisibility(View.VISIBLE);
    else imgVerified.setVisibility(View.GONE);
  }
Example #5
0
 public static String getUserKey(String key, WeiBoUser user) {
   return key + "-" + user.getIdstr();
 }
Example #6
0
  public static String getUserScreenName(WeiBoUser user) {
    if (AppSettings.isShowRemark() && !TextUtils.isEmpty(user.getRemark())) return user.getRemark();

    return user.getScreen_name();
  }
Example #7
0
 public static boolean isLoggedUser(WeiBoUser user) {
   return user.getIdstr().equalsIgnoreCase(AppContext.getUser().getIdstr());
 }