コード例 #1
0
 private void setDefaultSystemMessage() {
   ChatMessage message = localDatabase.findLastMessage(utilSrvc.getSystemID());
   if (message.getText() != null && message.getText().length() != 0) {
     systemMessage.setText(message.getText());
   } else {
     systemMessage.setHint(this.getResources().getText(R.string.chat_list_system_noMessage));
   }
 }
コード例 #2
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ChatFriend friend = this.getItem(position);
      if (convertView == null) {
        LayoutInflater layoutInflater =
            (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = layoutInflater.inflate(R.layout.activity_chat_friend_item, null);
      }
      ImageView redpoint = (ImageView) convertView.findViewById(R.id.chat_friend_new_message);
      TextView name = (TextView) convertView.findViewById(R.id.chat_friend_name);
      name.setText(friend.getName());

      TextView lastMessage = (TextView) convertView.findViewById(R.id.chat_list_last_message);
      TextView lastTime = (TextView) convertView.findViewById(R.id.chat_list_last_message_time);
      ChatMessage lastMessageText = localDatabase.findLastMessage(friend.getFriendId());
      Button delete = (Button) convertView.findViewById(R.id.chat_list_delete);
      redpoint.setVisibility(View.GONE);

      if (newMessageFriends.size() != 0) {
        for (int count = 0; count < newMessageFriends.size(); count++) {
          if (newMessageFriends.get(count) != null) {
            if (newMessageFriends.get(count).getName().equalsIgnoreCase(friend.getName())) {
              redpoint.setVisibility(View.VISIBLE);
            }
          }
        }
      }

      if (friend.getPortrait() != null) {
        ImageView portrait = (ImageView) convertView.findViewById(R.id.chat_friend_profile);
        Bitmap imageBitmap =
            BitmapFactory.decodeByteArray(friend.getPortrait(), 0, friend.getPortrait().length);
        imageBitmap = Bitmap.createScaledBitmap(imageBitmap, 50, 50, true);
        portrait.setImageBitmap(imageBitmap);
      }

      if (lastMessageText != null && lastMessageText.getDate() != null) {
        lastMessage.setText(lastMessageText.getText());
        lastTime.setText(lastMessageText.getDate().substring(5));
      }

      convertView.setOnTouchListener(new ItemTouchListener(delete, position, redpoint));
      delete.setOnClickListener(new DeleteListener(friend));

      return convertView;
    }