use of de.pixart.messenger.ui.adapter.MessageAdapter in project Pix-Art-Messenger by kriztan.
the class ConversationFragment method onCreateView.
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
this.binding = DataBindingUtil.inflate(inflater, R.layout.fragment_conversation, container, false);
// TODO why the fuck did we do this?
binding.getRoot().setOnClickListener(null);
binding.textinput.addTextChangedListener(new StylingHelper.MessageEditorStyler(binding.textinput));
binding.textinput.setOnEditorActionListener(mEditorActionListener);
binding.textinput.setRichContentListener(new String[] { "image/*" }, mEditorContentListener);
binding.textSendButton.setOnClickListener(this.mSendButtonListener);
binding.textSendButton.setOnLongClickListener(this.mSendButtonLongListener);
binding.messagesView.setOnScrollListener(mOnScrollListener);
binding.messagesView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
messageListAdapter = new MessageAdapter((XmppActivity) getActivity(), this.messageList);
messageListAdapter.setOnContactPictureClicked(message -> {
final boolean received = message.getStatus() <= Message.STATUS_RECEIVED;
if (received) {
if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
Jid user = message.getCounterpart();
if (user != null && !user.isBareJid()) {
if (!message.getConversation().getMucOptions().isUserInRoom(user)) {
Toast.makeText(activity, getActivity().getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show();
}
highlightInConference(user.getResourcepart());
}
return;
} else {
if (!message.getContact().isSelf()) {
String fingerprint;
if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
fingerprint = "pgp";
} else {
fingerprint = message.getFingerprint();
}
activity.switchToContactDetails(message.getContact(), fingerprint);
return;
}
}
}
Account account = message.getConversation().getAccount();
Intent intent = new Intent(activity, EditAccountActivity.class);
intent.putExtra("jid", account.getJid().toBareJid().toString());
String fingerprint;
if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
fingerprint = "pgp";
} else {
fingerprint = message.getFingerprint();
}
intent.putExtra("fingerprint", fingerprint);
startActivity(intent);
});
messageListAdapter.setOnContactPictureLongClicked(message -> {
if (message.getStatus() <= Message.STATUS_RECEIVED) {
if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
final MucOptions mucOptions = conversation.getMucOptions();
if (!mucOptions.allowPm()) {
Toast.makeText(getActivity(), R.string.private_messages_are_disabled, Toast.LENGTH_SHORT).show();
return;
}
Jid user = message.getCounterpart();
if (user != null && !user.isBareJid()) {
if (mucOptions.isUserInRoom(user)) {
privateMessageWith(user);
} else {
Toast.makeText(getActivity(), activity.getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show();
}
}
}
} else {
activity.showQrCode(conversation.getAccount().getShareableUri());
}
});
messageListAdapter.setOnQuoteListener(this::quoteText);
binding.messagesView.setAdapter(messageListAdapter);
registerForContextMenu(binding.messagesView);
return binding.getRoot();
}
Aggregations