use of net.iGap.observers.interfaces.OnClientGetRoomResponse in project iGap-Android by KianIranian-STDG.
the class FragmentNewGroupViewModel method getRoom.
private void getRoom(final long roomId, final ProtoGlobal.Room.Type typeCreate, boolean isGroup) {
G.onClientGetRoomResponse = new OnClientGetRoomResponse() {
@Override
public void onClientGetRoomResponse(final ProtoGlobal.Room room, ProtoClientGetRoom.ClientGetRoomResponse.Builder builder, RequestClientGetRoom.IdentityClientGetRoom identity) {
if (identity.createRoomMode != RequestClientGetRoom.CreateRoomMode.requestFromOwner) {
return;
}
try {
G.handler.post(new Runnable() {
@Override
public void run() {
if (existAvatar) {
showProgressBar();
if (room.getType() == ProtoGlobal.Room.Type.GROUP) {
new RequestGroupAvatarAdd().groupAvatarAdd(roomId, token);
} else {
new RequestChannelAvatarAdd().channelAvatarAdd(roomId, token);
}
} else {
hideProgressBar();
if (isGroup) {
createdRoomId.postValue(roomId);
} else {
goToContactGroupPage.setValue(new ContactGroupFragmentModel(roomId, room.getGroupRoomExtra().getParticipantsCountLimitLabel(), typeCreate.toString(), true));
}
}
}
});
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onError(int majorCode, int minorCode) {
hideProgressBar();
}
@Override
public void onTimeOut() {
hideProgressBar();
}
};
new RequestClientGetRoom().clientGetRoom(roomId, RequestClientGetRoom.CreateRoomMode.requestFromOwner);
}
use of net.iGap.observers.interfaces.OnClientGetRoomResponse in project iGap-Android by KianIranian-STDG.
the class FragmentNewGroupViewModel method getChannelRoom.
private void getChannelRoom(final long roomId) {
G.onClientGetRoomResponse = new OnClientGetRoomResponse() {
@Override
public void onClientGetRoomResponse(final ProtoGlobal.Room room, ProtoClientGetRoom.ClientGetRoomResponse.Builder builder, RequestClientGetRoom.IdentityClientGetRoom identity) {
if (identity.createRoomMode != RequestClientGetRoom.CreateRoomMode.requestFromOwner) {
return;
}
G.onClientGetRoomResponse = null;
G.handler.post(new Runnable() {
@Override
public void run() {
mInviteLink = room.getChannelRoomExtra().getPrivateExtra().getInviteLink();
if (existAvatar) {
MessageController.getInstance(currentAccount).saveChannelAvatar(imagePath, room.getId());
} else {
hideProgressBar();
goToCreateChannelPage.setValue(new CreateChannelModel(room.getId(), mInviteLink, token));
}
}
});
}
@Override
public void onError(int majorCode, int minorCode) {
G.onClientGetRoomResponse = null;
}
@Override
public void onTimeOut() {
G.onClientGetRoomResponse = null;
}
};
new RequestClientGetRoom().clientGetRoom(roomId, RequestClientGetRoom.CreateRoomMode.requestFromOwner);
}
use of net.iGap.observers.interfaces.OnClientGetRoomResponse in project iGap-Android by KianIranian-STDG.
the class HelperUrl method goToActivityFromFCM.
public static void goToActivityFromFCM(FragmentActivity activity, final long roomId, final long peerId) {
if (roomId != FragmentChat.lastChatRoomId) {
DbManager.getInstance().doRealmTask(realm -> {
RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomId).findFirst();
if (realmRoom != null) {
// room with given roomID exists.
new GoToChatActivity(realmRoom.getId()).startActivity(activity);
} else if (peerId > 0) {
realmRoom = realm.where(RealmRoom.class).equalTo("chatRoom.peer_id", peerId).findFirst();
if (realmRoom != null) {
new GoToChatActivity(realmRoom.getId()).startActivity(activity);
} else {
G.onChatGetRoom = new OnChatGetRoom() {
@Override
public void onChatGetRoom(final ProtoGlobal.Room room) {
DbManager.getInstance().doRealmTask(new DbManager.RealmTask() {
@Override
public void doTask(Realm realm1) {
realm1.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
if (realm.where(RealmRoom.class).equalTo("id", room.getId()).findFirst() == null) {
RealmRoom realmRoom1 = RealmRoom.putOrUpdate(room, realm);
realmRoom1.setDeleted(true);
} else {
RealmRoom.putOrUpdate(room, realm);
}
}
});
}
});
G.handler.postDelayed(new Runnable() {
@Override
public void run() {
new GoToChatActivity(room.getId()).setPeerID(peerId).startActivity(activity);
G.onChatGetRoom = null;
}
}, 500);
}
@Override
public void onChatGetRoomTimeOut() {
}
@Override
public void onChatGetRoomError(int majorCode, int minorCode) {
}
};
new RequestChatGetRoom().chatGetRoom(peerId);
}
} else {
G.onClientGetRoomResponse = new OnClientGetRoomResponse() {
@Override
public void onClientGetRoomResponse(ProtoGlobal.Room room, ProtoClientGetRoom.ClientGetRoomResponse.Builder builder, RequestClientGetRoom.IdentityClientGetRoom identity) {
G.onClientGetRoomResponse = null;
G.handler.postDelayed(() -> {
new GoToChatActivity(room.getId()).setPeerID(peerId).startActivity(activity);
G.onChatGetRoom = null;
}, 500);
}
@Override
public void onError(int majorCode, int minorCode) {
}
@Override
public void onTimeOut() {
}
};
new RequestClientGetRoom().clientGetRoom(roomId, null);
Toast.makeText(activity, "Please Wait...", Toast.LENGTH_SHORT).show();
}
});
}
}
use of net.iGap.observers.interfaces.OnClientGetRoomResponse in project iGap-Android by KianIranian-STDG.
the class HelperGetOwnerInfo method checkRoomExist.
private static void checkRoomExist(long id, final Listener listener) {
DbManager.getInstance().doRealmTask(realm -> {
RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", id).findFirst();
if (realmRoom == null) {
G.onClientGetRoomResponse = new OnClientGetRoomResponse() {
@Override
public void onClientGetRoomResponse(ProtoGlobal.Room room, ProtoClientGetRoom.ClientGetRoomResponse.Builder builder, RequestClientGetRoom.IdentityClientGetRoom identity) {
if (identity.createRoomMode == RequestClientGetRoom.CreateRoomMode.requestFromOwner) {
if (listener != null) {
listener.OnResponse();
}
}
}
@Override
public void onError(int majorCode, int minorCode) {
}
@Override
public void onTimeOut() {
}
};
new RequestClientGetRoom().clientGetRoom(id, RequestClientGetRoom.CreateRoomMode.requestFromOwner);
} else {
if (listener != null) {
listener.OnResponse();
}
}
});
}
Aggregations