예제 #1
0
 private void initValues() {
   loginType = getIntent().getStringExtra("loginType");
   rl_userinfo_modify.setVisibility(View.VISIBLE);
   userinfo_sex.setVisibility(View.GONE);
   iv_next.setVisibility(View.GONE);
   handler = new MyHandler(this);
   userinfo_title.setText("你的昵称");
   KeyBoardUtils.openKeybord(userinfo_modify, this);
   userinfo_modify.setInputType(android.text.InputType.TYPE_CLASS_TEXT);
   userinfo_modify.setFilters(new InputFilter[] {new InputFilter.LengthFilter(16)});
   userinfo_sex.check(R.id.rb_userinfo_man);
   sex = "男";
   if (!"phoneNumber".equals(loginType)) {
     count = 2;
     rl_userinfo_modify.setVisibility(View.GONE);
     userinfo_sex.setVisibility(View.VISIBLE);
     tv_nickname_modified.setText(
         (String) UserInfoUtils.getUserInfo(this, Constants.NICKNAME, ""));
     tv_nickname_modified.setVisibility(View.VISIBLE);
     userinfo_title.setText("男生or女生?");
     iv_next.setVisibility(View.VISIBLE);
   }
 }
예제 #2
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.iv_next:
       switch (count) {
         case 1:
           KeyBoardUtils.closeKeybord(userinfo_modify, this);
           iv_next.setVisibility(View.VISIBLE);
           count = count + 1;
           userinfo_title.setText("男生or女生?");
           rl_userinfo_modify.setVisibility(View.GONE);
           userinfo_sex.setVisibility(View.VISIBLE);
           String nickName = userinfo_modify.getText().toString().trim();
           params.put("nickname", nickName);
           UserInfoUtils.setUserInfo(getApplicationContext(), Constants.NICKNAME, nickName);
           tv_nickname_modified.setText(nickName);
           tv_nickname_modified.setVisibility(View.VISIBLE);
           userinfo_modify.setText("");
           break;
         case 2:
           iv_next.setVisibility(View.GONE);
           userinfo_modify.setInputType(android.text.InputType.TYPE_CLASS_PHONE);
           KeyBoardUtils.openKeybord(userinfo_modify, this);
           userinfo_sex.setVisibility(View.GONE);
           rl_userinfo_modify.setVisibility(View.VISIBLE);
           count = count + 1;
           UserInfoUtils.setUserInfo(getApplicationContext(), Constants.SEX, sex);
           if (getResources().getString(R.string.man).equals(sex)) {
             params.put("sex", 1 + "");
             iv_sex_modified.setImageResource(R.drawable.icon_userinfo_man_select);
           } else {
             params.put("sex", 2 + "");
             iv_sex_modified.setImageResource(R.drawable.icon_userinfo_women_select);
           }
           iv_sex_modified.setVisibility(View.VISIBLE);
           userinfo_title.setText("请输入你的身高");
           userinco_unit.setText("cm");
           break;
         case 3:
           KeyBoardUtils.openKeybord(userinfo_modify, this);
           iv_next.setVisibility(View.GONE);
           String height = userinfo_modify.getText().toString().trim();
           userinfo_modify.setText("");
           UserInfoUtils.setUserInfo(getApplicationContext(), Constants.HEIGHT, height);
           params.put("height", height);
           userinfo_title.setText("请输入你的体重");
           userinco_unit.setText("kg");
           count = count + 1;
           Spannable heightSpan = new SpannableString(height + "cm");
           heightSpan.setSpan(
               new AbsoluteSizeSpan(18),
               heightSpan.length() - 2,
               heightSpan.length(),
               Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
           tv_age_modified.setText(heightSpan);
           tv_age_modified.setVisibility(View.VISIBLE);
           userinfo_modify.setText("");
           break;
         case 4:
           KeyBoardUtils.openKeybord(userinfo_modify, this);
           iv_next.setVisibility(View.GONE);
           String weight = userinfo_modify.getText().toString().trim();
           UserInfoUtils.setUserInfo(getApplicationContext(), Constants.WEIGHT, weight);
           params.put("weight", weight);
           userinfo_title.setText("请输入你的年龄");
           userinco_unit.setText("岁");
           count = count + 1;
           Spannable weightSpan = new SpannableString(weight + "kg");
           weightSpan.setSpan(
               new AbsoluteSizeSpan(18),
               weightSpan.length() - 2,
               weightSpan.length(),
               Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
           tv_height_modified.setText(weightSpan);
           tv_height_modified.setVisibility(View.VISIBLE);
           userinfo_modify.setText("");
           break;
         case 5:
           KeyBoardUtils.closeKeybord(userinfo_modify, this);
           String age = userinfo_modify.getText().toString().trim();
           UserInfoUtils.setUserInfo(getApplicationContext(), Constants.AGE, age);
           params.put("age", age);
           userinfo_title.setText("选择感兴趣的运动");
           userinfo_sex.setVisibility(View.GONE);
           userinfo_modify.setVisibility(View.GONE);
           rl_sports_like.setVisibility(View.VISIBLE);
           count = count + 1;
           Spannable ageSpan = new SpannableString(age + "岁");
           ageSpan.setSpan(
               new AbsoluteSizeSpan(18),
               ageSpan.length() - 1,
               ageSpan.length(),
               Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
           tv_weight_modified.setText(ageSpan);
           tv_weight_modified.setVisibility(View.VISIBLE);
           gridViewAdapter = new MyGridViewAdapter(this, new ArrayList<String>());
           gv_sports_like.setAdapter(gridViewAdapter);
           break;
       }
       break;
     case R.id.userinfo_complete:
       UserInfoUtils.setUserInfo(
           getApplicationContext(),
           Constants.SPORT_SELECTED,
           gridViewAdapter
               .sportSelectedNames
               .toString()
               .replace(" ", "")
               .replace("[", "")
               .replace("]", ""));
       params.put(
           "sports",
           gridViewAdapter
               .sportSelectedNames
               .toString()
               .replace(" ", "")
               .replace("[", "")
               .replace("]", ""));
       saveAndPostUserInfo(params);
       break;
     default:
       break;
   }
 }