Search in sources :

Example 1 with OnUploadListener

use of net.iGap.helper.upload.OnUploadListener 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)

Example 2 with OnUploadListener

use of net.iGap.helper.upload.OnUploadListener in project iGap-Android by KianIranian-STDG.

the class FragmentRegistrationNicknameViewModel method uploadAvatar.

public void uploadAvatar(String path) {
    existAvatar = false;
    pathImageUser = path;
    int lastUploadedAvatarId = idAvatar + 1;
    prgVisibility.set(View.VISIBLE);
    Uploader.getInstance().upload(UploadObject.createForAvatar(lastUploadedAvatarId, pathImageUser, null, ProtoGlobal.RoomMessageType.IMAGE, new OnUploadListener() {

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

        @Override
        public void onFinish(String id, String token) {
            Log.wtf(this.getClass().getName(), "onFinish: id: " + id);
            existAvatar = true;
            new RequestUserAvatarAdd().userAddAvatar(token);
        }

        @Override
        public void onError(String id) {
            Log.wtf(this.getClass().getName(), "onError: id: " + id);
            existAvatar = true;
            prgVisibility.set(View.GONE);
        }
    }));
}
Also used : OnUploadListener(net.iGap.helper.upload.OnUploadListener) RequestUserAvatarAdd(net.iGap.request.RequestUserAvatarAdd)

Example 3 with OnUploadListener

use of net.iGap.helper.upload.OnUploadListener in project iGap-Android by KianIranian-STDG.

the class UserProfileViewModel method uploadAvatar.

public void uploadAvatar(String path) {
    pathSaveImage = path;
    long lastUploadedAvatarId = idAvatar + 1L;
    showLoading.set(View.VISIBLE);
    Uploader.getInstance().upload(UploadObject.createForAvatar(lastUploadedAvatarId, pathSaveImage, null, ProtoGlobal.RoomMessageType.IMAGE, new OnUploadListener() {

        @Override
        public void onProgress(String id, int progress) {
        }

        @Override
        public void onFinish(String id, String token) {
            new RequestUserAvatarAdd().userAddAvatar(token);
        }

        @Override
        public void onError(String id) {
            G.handler.post(() -> showLoading.set(View.GONE));
        }
    }));
}
Also used : OnUploadListener(net.iGap.helper.upload.OnUploadListener) HelperString(net.iGap.helper.HelperString) RequestUserAvatarAdd(net.iGap.request.RequestUserAvatarAdd)

Aggregations

OnUploadListener (net.iGap.helper.upload.OnUploadListener)3 RequestUserAvatarAdd (net.iGap.request.RequestUserAvatarAdd)2 HelperString (net.iGap.helper.HelperString)1 RequestGroupAvatarAdd (net.iGap.request.RequestGroupAvatarAdd)1