use of net.iGap.observers.interfaces.OnChatEditMessageResponse in project iGap-Android by KianIranian-STDG.
the class FragmentChat method initCallbacks.
/**
* initialize some callbacks that used in this page
*/
public void initCallbacks() {
getSendMessageUtil().setOnChatSendMessageResponseChatPage(this);
// G.chatUpdateStatusUtil.setOnChatUpdateStatusResponse(this);
G.onChatSendMessage = new OnChatSendMessage() {
@Override
public void Error(int majorCode, int minorCode, final int waitTime, long messageId) {
if (majorCode == 234) {
G.handler.post(new Runnable() {
@Override
public void run() {
try {
if (G.fragmentActivity.hasWindowFocus()) {
showErrorDialog(waitTime);
}
} catch (Exception e) {
}
}
});
} else if (majorCode == 233 && minorCode == 1) {
G.handler.post(new Runnable() {
@Override
public void run() {
if (getContext() != null && mAdapter != null) {
mAdapter.removeMessage(messageId);
}
}
});
}
}
};
G.onChatEditMessageResponse = new OnChatEditMessageResponse() {
@Override
public void onChatEditMessage(long roomId, final long messageId, long messageVersion, final String message, ProtoResponse.Response response) {
if (mRoomId == roomId && mAdapter != null) {
// I'm in the room
G.handler.post(new Runnable() {
@Override
public void run() {
// update message text in adapter
mAdapter.updateMessageText(messageId, message);
}
});
}
}
@Override
public void onError(int majorCode, int minorCode) {
}
};
onMusicListener = new OnComplete() {
@Override
public void complete(boolean result, String messageID, String MessageTwo) {
if (result) {
updateShowItemInScreen();
} else {
onPlayMusic(messageID);
}
}
};
iUpdateLogItem = new // TODO: 12/29/20 MESSAGE_REFACTOR_NEED_TEST
IUpdateLogItem() {
@Override
public void onUpdate(byte[] log, long messageId) {
if (getActivity() == null || getActivity().isFinishing())
return;
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (mAdapter == null) {
return;
}
for (int i = mAdapter.getAdapterItemCount() - 1; i >= 0; i--) {
try {
AbstractMessage item = mAdapter.getAdapterItem(i);
if (item.messageObject != null && item.messageObject.id == messageId) {
// bagi May crash
item.messageObject.log.data = log;
mAdapter.notifyAdapterItemChanged(i);
break;
}
} catch (Exception e) {
e.printStackTrace();
HelperLog.getInstance().setErrorLog(e);
}
}
}
});
}
};
/**
* after get position from gps
*/
complete = new OnComplete() {
@Override
public void complete(boolean result, final String messageOne, String MessageTwo) {
try {
if (getActivity() != null) {
String[] split = messageOne.split(",");
Double latitude = Double.parseDouble(split[0]);
Double longitude = Double.parseDouble(split[1]);
NewFragmentMap fragment = NewFragmentMap.newInstance(latitude, longitude);
new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
}
} catch (Exception e) {
HelperLog.getInstance().setErrorLog(e);
}
}
};
G.onHelperSetAction = new OnHelperSetAction() {
@Override
public void onAction(ProtoGlobal.ClientAction ClientAction) {
HelperSetAction.setActionFiles(mRoomId, messageId, ClientAction, chatType);
}
};
G.onDeleteChatFinishActivity = new OnDeleteChatFinishActivity() {
@Override
public void onFinish() {
G.handler.post(new Runnable() {
@Override
public void run() {
// finish();
finishChat();
}
});
}
};
G.onUpdateUserStatusInChangePage = (peerId, status, lastSeen) -> {
if (chatType == CHAT) {
setUserStatus(status, lastSeen);
new RequestUserInfo().userInfo(peerId);
}
};
}
Aggregations