use of net.iGap.module.ResendMessage in project iGap-Android by KianIranian-STDG.
the class FragmentChat method onFailedMessageClick.
@Override
public void onFailedMessageClick(View view, final MessageObject messageObject, final int pos) {
// TODO: 12/28/20 MESSAGE_REFACTOR_NEED_TEST
final List<MessageObject> failedMessages = mAdapter.getFailedMessages();
hideKeyboard();
new ResendMessage(G.fragmentActivity, new IResendMessage() {
@Override
public void deleteMessage() {
if (pos >= 0 && mAdapter.getAdapterItemCount() > pos) {
mAdapter.remove(pos);
removeLayoutTimeIfNeed();
}
}
@Override
public void resendMessage() {
for (int i = 0; i < failedMessages.size(); i++) {
if (failedMessages.get(i).id == messageObject.id) {
if (failedMessages.get(i).getAttachment() != null) {
if (!Uploader.getInstance().isCompressingOrUploading(messageObject.id + "")) {
UploadObject fileObject = UploadObject.createForMessage(messageObject, chatType);
if (fileObject != null) {
Uploader.getInstance().upload(fileObject);
}
}
}
break;
}
}
mAdapter.updateMessageStatus(messageObject.id, ProtoGlobal.RoomMessageStatus.SENDING);
G.handler.postDelayed(new Runnable() {
@Override
public void run() {
mAdapter.notifyItemChanged(mAdapter.findPositionByMessageId(messageObject.id));
}
}, 300);
}
@Override
public void resendAllMessages() {
for (int i = 0; i < failedMessages.size(); i++) {
final int j = i;
G.handler.postDelayed(new Runnable() {
@Override
public void run() {
mAdapter.updateMessageStatus(failedMessages.get(j).id, ProtoGlobal.RoomMessageStatus.SENDING);
}
}, 1000 * i);
}
}
@Override
public void copyMessage() {
copyMessageToClipboard(messageObject, false);
}
}, messageObject.id, failedMessages);
}
Aggregations