Пример #1
0
  private void setContactInfo(String content) {
    final FeedbackAgent fb = new FeedbackAgent(mContext);
    UserInfo userInfo = fb.getUserInfo();
    if (userInfo == null) {
      userInfo = new UserInfo();
    }
    Map<String, String> contact = userInfo.getContact();
    if (contact == null || contact.isEmpty()) {
      contact = new HashMap<String, String>();
    }
    int position = spContactType.getSelectedItemPosition();
    contact.put(keys[position], content);
    userInfo.setContact(contact);
    fb.setUserInfo(userInfo);

    new Thread(
            new Runnable() {
              @Override
              public void run() {
                fb.updateUserInfo();
              }
            })
        .start();
    types[position] = content;
    showContactInfo();
  }
Пример #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.umeng_fb_activity_conversation);
    agent = new FeedbackAgent(this);

    layoutBack = (LinearLayout) findViewById(R.id.umeng_left_layout);

    // backBtn = (ImageView) this.findViewById(com.umeng.fb.res.IdMapper.umeng_fb_back(this));
    // saveBtn = (ImageView) this.findViewById(com.umeng.fb.res.IdMapper.umeng_fb_save(this));
    // contactInfoEdit = (EditText)
    // this.findViewById(com.umeng.fb.res.IdMapper.umeng_fb_contact_info(this));
    contactInfoEdit = (EditText) findViewById(R.id.umeng_fb_reply_content);
    // lastUpdateAtText = (TextView)
    // this.findViewById(com.umeng.fb.res.IdMapper.umeng_fb_contact_update_at(this));
    lastUpdateAtText = (TextView) findViewById(R.id.umeng_fb_contact_update_at);
    try {
      String contact_info = agent.getUserInfo().getContact().get(KEY_UMENG_CONTACT_INFO_PLAIN_TEXT);
      contactInfoEdit.setText(contact_info);

      long time = agent.getUserInfoLastUpdateAt();

      if (time > 0) {
        Date date = new Date(time);
        // String prefix =
        // this.getResources().getString(com.umeng.fb.res.StringMapper.umeng_fb_contact_update_at(this));
        String prefix = this.getResources().getString(R.string.umeng_fb_contact_update_at);
        lastUpdateAtText.setText(prefix + SimpleDateFormat.getDateTimeInstance().format(date));
        lastUpdateAtText.setVisibility(View.VISIBLE);
      } else {
        lastUpdateAtText.setVisibility(View.GONE);
      }

      // If user has never entered any contact information, request focus
      // on the edittext on startup.
      if (Utility.isNullOrEmpty(contact_info)) {
        contactInfoEdit.requestFocus();
        InputMethodManager imm =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
      }

    } catch (NullPointerException e) {
      e.printStackTrace();
    }

    layoutBack.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            back();
          }
        });
    saveBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            try {
              UserInfo info = agent.getUserInfo();
              if (info == null) info = new UserInfo();
              Map<String, String> contact = info.getContact();
              if (contact == null) contact = new HashMap<String, String>();
              String contact_info = contactInfoEdit.getEditableText().toString();
              contact.put(KEY_UMENG_CONTACT_INFO_PLAIN_TEXT, contact_info);
              info.setContact(contact);

              //					Map<String, String> remark = info.getRemark();
              //					if (remark == null)
              //						remark = new HashMap<String, String>();
              //					remark.put("tag1", "game");
              //					info.setRemark(remark);

              agent.setUserInfo(info);

            } catch (Exception e) {
              e.printStackTrace();
            }
            back();
          }
        });
  }