|
|
@@ -8,7 +8,9 @@ import androidx.lifecycle.LiveData;
|
|
|
import androidx.lifecycle.MutableLiveData;
|
|
|
|
|
|
import com.atmob.app.lib.handler.RxHttpHandler;
|
|
|
+import com.atmob.common.runtime.ActivityUtil;
|
|
|
import com.atmob.common.runtime.ContextUtil;
|
|
|
+import com.atmob.voiceai.R;
|
|
|
import com.atmob.voiceai.data.api.AtmobApi;
|
|
|
import com.atmob.voiceai.data.api.bean.CloneVoiceListBean;
|
|
|
import com.atmob.voiceai.data.api.request.BaseRequest;
|
|
|
@@ -16,9 +18,12 @@ import com.atmob.voiceai.data.api.request.CloneDeleteRequest;
|
|
|
import com.atmob.voiceai.data.api.request.VoiceCloneRequest;
|
|
|
import com.atmob.voiceai.data.api.response.VoiceCloneListResponse;
|
|
|
import com.atmob.voiceai.data.api.response.VoiceCloneResponse;
|
|
|
+import com.atmob.voiceai.data.consts.ErrorCode;
|
|
|
import com.atmob.voiceai.data.consts.EventId;
|
|
|
import com.atmob.voiceai.handlers.EventHandler;
|
|
|
import com.atmob.voiceai.helper.ErrorHelper;
|
|
|
+import com.atmob.voiceai.module.integral.InternalPurchaseActivity;
|
|
|
+import com.atmob.voiceai.module.subscription.SubscriptionPageActivity;
|
|
|
import com.atmob.voiceai.utils.ReflectionUtil;
|
|
|
import com.atmob.voiceai.utils.ToastUtil;
|
|
|
import com.google.gson.annotations.SerializedName;
|
|
|
@@ -121,10 +126,22 @@ public class CloneRepository {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(@NonNull Throwable e) {
|
|
|
+ public void onError(@NonNull Throwable throwable) {
|
|
|
requestCloneFlag = false;
|
|
|
cloneUploadState.setValue(UploadState.ERROR);
|
|
|
- ErrorHelper.errorThrowableToast(e, ToastUtil.LENGTH_SHORT);
|
|
|
+ if (throwable instanceof RxHttpHandler.ServerErrorException) {
|
|
|
+ RxHttpHandler.ServerErrorException serverErrorException = (RxHttpHandler.ServerErrorException) throwable;
|
|
|
+ if (serverErrorException.getCode() == ErrorCode.ERROR_NOT_SUBSCRIBED) {
|
|
|
+ SubscriptionPageActivity.start(ActivityUtil.getTopActivity());
|
|
|
+ } else if (serverErrorException.getCode() == ErrorCode.ERROR_INTEGRAL_NOT_ENOUGH) {
|
|
|
+ InternalPurchaseActivity.start(ActivityUtil.getTopActivity());
|
|
|
+ } else {
|
|
|
+ ToastUtil.show(serverErrorException.getMsg(), ToastUtil.LENGTH_SHORT);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ToastUtil.show(R.string.net_error_message, ToastUtil.LENGTH_SHORT);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
}
|