private void initViews() { user_nick = (TextView) findViewById(R.id.user_nick); user_head = (AsyncImageView) findViewById(R.id.user_head); user_head.setImageResource(R.drawable.head_default); user_name = (TextView) findViewById(R.id.user_name); user_sex = (TextView) findViewById(R.id.user_sex); user_location = (TextView) findViewById(R.id.user_location); count_followers = (TextView) findViewById(R.id.count_followers); count_friends = (TextView) findViewById(R.id.count_friends); count_statuses = (TextView) findViewById(R.id.count_statuses); user_description = (TextView) findViewById(R.id.user_description); last_status = (LinearLayout) findViewById(R.id.last_status); l_count_followers = (LinearLayout) findViewById(R.id.l_count_followers); l_count_friends = (LinearLayout) findViewById(R.id.l_count_friends); l_count_status = (LinearLayout) findViewById(R.id.l_count_status); // one one_status = (TextView) findViewById(R.id.one_status); one_image = (AsyncImageView) findViewById(R.id.one_image); source_one = (RelativeLayout) findViewById(R.id.source_one); source_one_nick = (TextView) findViewById(R.id.source_one_nick); source_one_status = (TextView) findViewById(R.id.source_one_status); source_one_image = (AsyncImageView) findViewById(R.id.source_one_image); source_one_from = (TextView) findViewById(R.id.source_one_from); one_from = (TextView) findViewById(R.id.one_from); one_time = (TextView) findViewById(R.id.one_time); user_description.setText("正在获取数据……"); // 注册监听器 l_count_followers.setOnClickListener(this); l_count_friends.setOnClickListener(this); l_count_status.setOnClickListener(this); }
/** 展示数据 */ 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"); } }