Search in sources :

Example 1 with RequestGroupAvatarAdd

use of net.iGap.request.RequestGroupAvatarAdd 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);
}
Also used : RequestChannelAvatarAdd(net.iGap.request.RequestChannelAvatarAdd) ProtoGlobal(net.iGap.proto.ProtoGlobal) OnClientGetRoomResponse(net.iGap.observers.interfaces.OnClientGetRoomResponse) RequestClientGetRoom(net.iGap.request.RequestClientGetRoom) OnClientGetRoomResponse(net.iGap.observers.interfaces.OnClientGetRoomResponse) RequestGroupAvatarAdd(net.iGap.request.RequestGroupAvatarAdd)

Example 2 with RequestGroupAvatarAdd

use of net.iGap.request.RequestGroupAvatarAdd in project iGap-Android by KianIranian-STDG.

the class EditGroupViewModel method uploadAvatar.

public void uploadAvatar(String path) {
    long avatarId = SUID.id().get();
    long lastUploadedAvatarId = avatarId + 1L;
    Uploader.getInstance().upload(UploadObject.createForAvatar(lastUploadedAvatarId, path, null, ProtoGlobal.RoomMessageType.IMAGE, new OnUploadListener() {

        @Override
        public void onProgress(String id, int progress) {
            showUploadProgressLiveData.postValue(View.VISIBLE);
        }

        @Override
        public void onFinish(String id, String token) {
            new RequestGroupAvatarAdd().groupAvatarAdd(roomId, token);
        }

        @Override
        public void onError(String id) {
            showUploadProgressLiveData.postValue(View.GONE);
        }
    }));
}
Also used : OnUploadListener(net.iGap.helper.upload.OnUploadListener) RequestGroupAvatarAdd(net.iGap.request.RequestGroupAvatarAdd)

Aggregations

RequestGroupAvatarAdd (net.iGap.request.RequestGroupAvatarAdd)2 OnUploadListener (net.iGap.helper.upload.OnUploadListener)1 OnClientGetRoomResponse (net.iGap.observers.interfaces.OnClientGetRoomResponse)1 ProtoGlobal (net.iGap.proto.ProtoGlobal)1 RequestChannelAvatarAdd (net.iGap.request.RequestChannelAvatarAdd)1 RequestClientGetRoom (net.iGap.request.RequestClientGetRoom)1