public String getLastMessageText (Message lastMessage) { String messageText = Strings.t(R.string.no_messages); if (lastMessage != null) { messageText = Strings.payloadAsString(lastMessage); } return messageText; }
public String getLastMessageDateAsString (Date date) { if (date != null) { return Strings.dateTime(date); } return null; }
public static String t (int resId) { return t(ChatSDK.shared().context(), resId); }
protected void initActionBar () { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { final ActionBar ab = readyActionBarToCustomView(); /* * http://stackoverflow.com/questions/16026818/actionbar-custom-view-with-centered-imageview-action-items-on-sides */ actionBarView = getLayoutInflater().inflate(R.layout.chat_sdk_actionbar_chat_activity, null); actionBarView.setOnClickListener(v -> { if (ChatSDK.config().threadDetailsEnabled) { openThreadDetailsActivity(); } }); TextView textView = actionBarView.findViewById(R.id.tvName); String displayName = Strings.nameForThread(thread); setTitle(displayName); textView.setText(displayName); subtitleTextView = actionBarView.findViewById(R.id.tvSubtitle); final SimpleDraweeView circleImageView = actionBarView.findViewById(R.id.ivAvatar); ThreadImageBuilder.load(circleImageView, thread); ab.setCustomView(actionBarView); } }
public static String payloadAsString (Message message) { MessageDisplayHandler handler = ChatSDK.ui().getMessageHandler(message.getMessageType()); if (handler != null) { return handler.displayName(message); } return t(R.string.unknown_message); }
protected void initViews() { actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(Strings.nameForThread(thread)); actionBar.setHomeButtonEnabled(true); } final View actionBarView = getLayoutInflater().inflate(R.layout.chat_sdk_activity_thread_details, null); // Allow the thread name to be modified by a long click actionBarView.setOnLongClickListener(v -> { // TODO: Implement this return true; }); threadImageView = findViewById(R.id.chat_sdk_thread_image_view); }
public static String nameForThread (Thread thread) { if (StringUtils.isNotEmpty(thread.getDisplayName())) { return thread.getDisplayName(); } // Due to the bundle printing when the app execute on debug this sometime is null. User currentUser = ChatSDK.currentUser(); String name = ""; if (thread.typeIs(ThreadType.Private)) { for (User user : thread.getUsers()){ if (!user.getId().equals(currentUser.getId())) { String n = user.getName(); if (StringUtils.isNotEmpty(n)) { name += (!name.equals("") ? ", " : "") + n; } } } } if(name.length() == 0) { name = Strings.t(R.string.no_name); } return name; }
holder.nameTextView.setText(Strings.nameForThread(thread));