예제 #1
0
 /** 获取用户信息 */
 private void getUserInfo() {
   SendData sendData = null;
   String url = null;
   Config.debug(TAG, "正在为获取用户信息装配数据");
   switch (Config.currentUser.getSp()) {
     case Constants.SP_TENCENT:
       sendData = new SendGet_UserInfo4Tencent(user.getUser_id());
       url = Constants.Tencent.GET_USERINFO;
       break;
     case Constants.SP_SINA:
       sendData = new SendGet_UserInfo4Sina(user.getUser_id());
       url = Constants.Sina.GET_USERINFO;
       break;
     case Constants.SP_NETEASE:
       sendData = new SendGet_UserInfo4Netease(user.getUser_id());
       url = Constants.NetEase.GET_USERINFO;
       break;
     case Constants.SP_SOHU:
       sendData = new SendGet_UserInfo4Sohu(user.getUser_id());
       url = String.format(Constants.Sohu.GET_OTHERUSERINFO, user.getUser_id());
       break;
     default:
       break;
   }
   result =
       new SendAsyncTask(activity, sendData, url, HttpType.GET, Config.currentUser, handler)
           .execute();
 }
예제 #2
0
  private void parseData(Response res) {
    boolean successed = false;
    Config.debug(TAG, res.getBody());

    try {
      Gson gson = new Gson();
      switch (Config.currentUser.getSp()) {
        case Constants.SP_TENCENT:
          GetResponse4Tencent response4Tencent =
              gson.fromJson(res.getBody(), GetResponse4Tencent.class);
          if (response4Tencent.getRet() == 0) {
            Config.debug(TAG, "成功!");
            successed = true;
          }
          break;
        case Constants.SP_SINA:
          UserInfo4Sina info4Sina = gson.fromJson(res.getBody(), UserInfo4Sina.class);
          if (info4Sina != null && info4Sina.getId() != null) {
            Config.debug(TAG, "成功!");
            successed = true;
          }
          break;
        case Constants.SP_NETEASE:
          UserInfo4Netease info4Netease = gson.fromJson(res.getBody(), UserInfo4Netease.class);
          if (info4Netease != null && info4Netease.getId() != null) {
            Config.debug(TAG, "成功!");
            successed = true;
          }
          break;
        case Constants.SP_SOHU:
          UserInfo4Sohu info4Sohu = gson.fromJson(res.getBody(), UserInfo4Sohu.class);
          if (info4Sohu != null && info4Sohu.getId() != null) {
            Config.debug(TAG, "成功!");
            successed = true;
          }
          break;
        default:
          break;
      }
    } catch (Exception e) {
      throw new NormalException(e.getMessage());
    }
    if (successed) {
      getUserInfo();
    }
  }
예제 #3
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     Config.debug(TAG, "click back catch on info");
     if (MyHandler.handler != null) {
       Message message = new Message();
       message.what = MyHandler.Handler_Back;
       MyHandler.handler.sendMessage(message);
     }
     return true;
   } else {
     return super.onKeyDown(keyCode, event);
   }
 }
예제 #4
0
  /** 展示数据 */
  private void fillData() {
    Gson gson = new Gson();
    try {
      Config.debug(TAG, response.getBody());
      switch (Config.currentUser.getSp()) {
        case Constants.SP_TENCENT:
          GetUserInfo4Tencent info4Tencent =
              gson.fromJson(response.getBody(), GetUserInfo4Tencent.class);
          if (info4Tencent.getRet() == 0) {
            user = info4Tencent.getData().conver2User();
          }
          break;
        case Constants.SP_SINA:
          UserInfo4Sina info4Sina = gson.fromJson(response.getBody(), UserInfo4Sina.class);
          user = info4Sina.conver2User();
          break;
        case Constants.SP_NETEASE:
          UserInfo4Netease info4Netease = gson.fromJson(response.getBody(), UserInfo4Netease.class);
          user = info4Netease.conver2User();
          break;
        case Constants.SP_SOHU:
          UserInfo4Sohu info4Sohu = gson.fromJson(response.getBody(), UserInfo4Sohu.class);
          user = info4Sohu.conver2User();
          break;
        default:
          break;
      }
    } catch (Exception e) {
      throw new NormalException(e.getMessage());
    }
    user_nick.setText(user.getNick());
    if (user.getName() != null && !"".equals(user.getName())) {
      user_name.setText("@" + user.getName());
    }
    user_sex.setText(user.getSex());
    user_location.setText("所在地" + user.getLocation());

    if (user.getDescription() != null && !"".equals(user.getDescription())) {
      user_description.setText(user.getDescription());
    } else {
      user_description.setText("这家伙很懒,什么都没留下");
    }
    count_followers.setText(user.getCount_followers() + "");
    count_friends.setText(user.getCount_friends() + "");
    count_statuses.setText(user.getCount_status() + "");

    // 检查是否有最近广播
    if (user.getStatus() != null) {
      last_status.setVisibility(View.VISIBLE);
      one_status.setText(TextUtils.parse(user.getStatus().getStatus(), activity));
      if (user.getStatus().getImage_s() != null) {
        one_image.setVisibility(View.VISIBLE);
        one_image.asyncLoadBitmapFromUrl(
            user.getStatus().getImage_s(),
            Config.cachePath + "s_" + user.getStatus().getStatus_id() + ".jpg");
      } else {
        one_image.setVisibility(View.GONE);
      }
      if (user.getStatus().isSource()) {
        source_one.setVisibility(View.VISIBLE);
        source_one_from.setText(user.getStatus().getSource_from());
        source_one_nick.setText(user.getStatus().getSource_nick());
        source_one_status.setText(TextUtils.parse(user.getStatus().getSource_status(), activity));
        if (user.getStatus().getSource_image_s() != null) {
          source_one_image.setVisibility(View.VISIBLE);
          source_one_image.asyncLoadBitmapFromUrl(
              user.getStatus().getSource_image_s(),
              Config.cachePath + "s_" + user.getStatus().getStatus_id() + ".jpg");
        } else {
          source_one_image.setVisibility(View.GONE);
        }
      } else {
        source_one.setVisibility(View.GONE);
      }
      one_from.setText(user.getStatus().getFrom());
      one_time.setText(user.getStatus().getTime());
    } else {
      last_status.setVisibility(View.GONE);
    }

    if (user.getHead_url() != null && URLUtil.isNetworkUrl(user.getHead_url())) {
      user_head.asyncLoadBitmapFromUrl(
          user.getHead_url(), Config.cachePath + "head_" + user.getUser_id() + ".jpg");
    }
  }
예제 #5
0
 @Override
 protected void onNewIntent(Intent intent) {
   Config.debug(TAG, "on newIntent");
 }