Ejemplo n.º 1
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.iv_back:
        this.finish();
        break;
      case R.id.modify_user_info:
        if (!((String) UserInfoUtils.getUserInfo(getApplicationContext(), Constants.USERID, ""))
            .equals(userId)) {
          showDeleteFriendDialog();
        } else {
          infoIntent = new Intent(this, DataActivity.class);
          infoIntent.putExtra("isFromUserInfoActivity", true);
          startActivity(infoIntent);
        }
        break;
      case R.id.user_addfriend:
        addFriend();
        break;

      case R.id.user_friends:
        Intent friendsIntent = new Intent(this, FriendsActivity.class);
        // friendsIntent.putExtra("user", user);
        friendsIntent.putExtra("userId", user.getId() + "");
        friendsIntent.putExtra("userName", user.getNickname());
        friendsIntent.putExtra("isSelf", false);
        startActivity(friendsIntent);
        break;
      case R.id.user_groups:
        Intent groupsIntent = new Intent(this, TeamListActivity.class);
        groupsIntent.putExtra("userId", user.getId() + "");
        groupsIntent.putExtra("userName", user.getNickname());
        startActivity(groupsIntent);
        break;
      case R.id.accept_addfriend:
        // 接受添加好友
        OxygenApplication.cachedThreadPool.execute(
            new Runnable() {
              public void run() {
                HttpUtil.Get(
                    UrlConstants.ADD_FRIEND_ACCEPT + userId + ".json", handler, ADD_FRIEND_ACCEPT);
              }
            });
        break;
      case R.id.rl_level_coin:
        Intent levelIntent = new Intent(this, LevelCoinActivity.class);
        startActivity(levelIntent);
        break;
      default:
        break;
    }
  }
Ejemplo n.º 2
0
 /** 兴趣运动 */
 private void setUserSports() {
   if (!TextUtils.isEmpty(user.getSports())) {
     ll_sports.removeAllViews();
     String[] picNames = user.getSports().split(",");
     for (int i = 0; i < picNames.length; i++) {
       if (i < 5) {
         ImageView imageView = new ImageView(this);
         imageView.setLayoutParams(
             new LinearLayout.LayoutParams(
                 (int) (20 * OxygenApplication.ppi), (int) (20 * OxygenApplication.ppi)));
         imageView.setBackgroundDrawable(
             GDUtil.engSporttodrawable(this, "icon_index_" + picNames[i].replace(" ", "")));
         ll_sports.addView(imageView);
       }
     }
   }
 }
Ejemplo n.º 3
0
 /** 设置用户的信息 */
 private void setUserInfo() {
   tv_name.setText(nickname);
   ImageUtil.showImage(headImgUrl, user_headimg, R.drawable.icon_default_head);
   if ("1".equals(sex)) {
     user_sex.setBackgroundResource(R.drawable.user_sex_man);
   } else if ("2".equals(sex)) {
     user_sex.setBackgroundResource(R.drawable.user_sex_woman);
   }
   user_age.setText(age);
   user_friends_count.setText("( " + friendCounts + " )");
   user_group_count.setText("( " + groupCounts + " )");
   add_event_count.setText(eventCounts + "");
   tv_level.setText("LV" + user.getLevel());
   tv_coin.setText("  " + user.getCoins() + "  ");
   int hourIndex = 0;
   int minuteIndex = 0;
   if (duration.contains("小时")) {
     hourIndex = duration.indexOf("小时");
     sport_time_hour.setText(duration.substring(0, hourIndex));
     minuteIndex = duration.indexOf("分钟");
     if (minuteIndex != -1) {
       sport_time_minute.setText(duration.substring(hourIndex + 2, minuteIndex));
     } else {
       sport_time_minute.setText("0");
     }
   } else if (duration.contains("分钟")) {
     minuteIndex = duration.indexOf("分钟");
     sport_time_hour.setText("0");
     sport_time_minute.setText(duration.substring(0, minuteIndex));
   } else {
     sport_time_hour.setText("0");
     sport_time_minute.setText("0");
   }
   tv_calorie.setText(calorie.replace("大卡", ""));
   setUserSports();
 }
Ejemplo n.º 4
0
  /** 解析用户信息 */
  private void getUserInfo() {
    relationship = user.getNew_relationship();
    if ("myself".equals(relationship)) {
      rl_level_coin.setClickable(true);
      rl_add_friend.setVisibility(View.GONE);
      modify_user_info.setVisibility(View.VISIBLE);

      UserInfoUtils.setUserInfo(getApplicationContext(), Constants.LEVEL, user.level);
      UserInfoUtils.setUserInfo(getApplicationContext(), Constants.COINS, user.coins);
      UserInfoUtils.setUserInfo(getApplicationContext(), Constants.POINTS, user.points);
    } else if ("stranger".equals(relationship)) {
      rl_add_friend.setVisibility(View.VISIBLE);
      user_addfriend.setVisibility(View.VISIBLE);
      modify_user_info.setVisibility(View.GONE);
      Drawable drawable = getResources().getDrawable(R.drawable.icon_goldcoin);
      drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
      tv_coin.setCompoundDrawables(drawable, null, null, null);
      rl_level_coin.setClickable(false);
    } else if ("pending".equals(relationship)) {
      rl_add_friend.setVisibility(View.VISIBLE);
      user_invalidation.setVisibility(View.VISIBLE);
      Drawable drawable = getResources().getDrawable(R.drawable.icon_goldcoin);
      drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
      tv_coin.setCompoundDrawables(drawable, null, null, null);
      rl_level_coin.setClickable(false);
    } else if ("friend".equals(relationship)) {
      modify_user_info.setVisibility(View.VISIBLE);
      Drawable drawable = getResources().getDrawable(R.drawable.icon_goldcoin);
      drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
      tv_coin.setCompoundDrawables(drawable, null, null, null);
      rl_level_coin.setClickable(false);
      // 1 代表小乐助手  则不显示好友和团队
      if ("1".equals(userId)) {
        user_friend_group.setVisibility(View.GONE);
        modify_user_info.setVisibility(View.GONE);
        // 不是自己时修改右上角按钮的样式
      } else if (!((String)
              UserInfoUtils.getUserInfo(getApplicationContext(), Constants.USERID, ""))
          .equals(userId)) {
        modify_user_info.setImageResource(R.drawable.icon_eventdetail_rankmore);
        modify_user_info.setVisibility(View.VISIBLE);
      } else {
        modify_user_info.setVisibility(View.VISIBLE);
      }

    } else if ("tbc".equals(relationship)) { // 别人请求添加我为好友 等待我确认
      rl_add_friend.setVisibility(View.VISIBLE);
      accept_addfriend.setVisibility(View.VISIBLE);
      Drawable drawable = getResources().getDrawable(R.drawable.icon_goldcoin);
      drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
      tv_coin.setCompoundDrawables(drawable, null, null, null);
      rl_level_coin.setClickable(false);
    }
    headImgUrl = user.getHeadimgurl();
    nickname = user.getNickname();
    sex = user.getSex() + "";
    age = user.getAge() + "";
    intro = user.getIntro();
    sport = user.getSports();
    eventCounts = user.getEvent_count();
    friendCounts = user.getFriend_count();
    groupCounts = user.getGroup_count();
    calorie = user.getTotal_calorie();
    duration = user.getTotal_duration();
    setUserInfo();
  }