Ejemplo n.º 1
0
  /** 获取联系人列表,并过滤掉黑名单和排序 */
  private void getContactList() {
    contactList.clear();
    // 获取本地好友列表
    Map<String, User> users = ApplicationControl.getInstance().getContactList();
    Iterator<Entry<String, User>> iterator = users.entrySet().iterator();
    while (iterator.hasNext()) {
      Entry<String, User> entry = iterator.next();
      if (!entry.getKey().equals(Constant.NEW_FRIENDS_USERNAME)
          && !entry.getKey().equals(Constant.GROUP_USERNAME)
          && !blackList.contains(entry.getKey())) contactList.add(entry.getValue());
    }
    // 排序
    Collections.sort(
        contactList,
        new Comparator<User>() {

          @Override
          public int compare(User lhs, User rhs) {
            return lhs.getUsername().compareTo(rhs.getUsername());
          }
        });

    // 加入"申请与通知"和"群聊"
    contactList.add(0, users.get(Constant.GROUP_USERNAME));
    // 把"申请与通知"添加到首位
    contactList.add(0, users.get(Constant.NEW_FRIENDS_USERNAME));
  }
Ejemplo n.º 2
0
        @Override
        public void handleMessage(Message msg) {
          if (mToast != null) {
            mToast.cancel();
          }
          String text = (String) msg.obj;
          int duration = msg.arg2;

          Toast.makeText(ApplicationControl.getInstance(), text, duration).show();
        }
Ejemplo n.º 3
0
 public static void showToast(int textResId, int duration) {
   showToast(ApplicationControl.getInstance().getString(textResId), duration);
 }