|
|
@@ -1,5 +1,6 @@
|
|
|
package com.atmob.voiceai.module.subscription;
|
|
|
|
|
|
+import android.os.Bundle;
|
|
|
import android.os.SystemClock;
|
|
|
|
|
|
import androidx.lifecycle.LiveData;
|
|
|
@@ -20,7 +21,10 @@ import com.atmob.voiceai.data.api.AtmobApi;
|
|
|
import com.atmob.voiceai.data.api.bean.GoodsBean;
|
|
|
import com.atmob.voiceai.data.api.bean.PayOptionsBean;
|
|
|
import com.atmob.voiceai.data.api.response.OrderPayResponse;
|
|
|
+import com.atmob.voiceai.data.consts.ErrorCode;
|
|
|
+import com.atmob.voiceai.data.consts.EventId;
|
|
|
import com.atmob.voiceai.data.repositories.MemberRepository;
|
|
|
+import com.atmob.voiceai.handlers.EventHandler;
|
|
|
import com.atmob.voiceai.helper.ErrorHelper;
|
|
|
import com.atmob.voiceai.sdk.billing.GPBillingClient;
|
|
|
import com.atmob.voiceai.utils.BoxingUtil;
|
|
|
@@ -73,6 +77,7 @@ public class SubscriptionPageViewModel extends BaseViewModel {
|
|
|
init();
|
|
|
refreshSubscriptionDetail();
|
|
|
gpBillingClient.startUrgentConnection();
|
|
|
+ EventHandler.report(EventId.purchase_001);
|
|
|
}
|
|
|
|
|
|
public void setCheckGoodsBean(GoodsBean checkGoodsBean) {
|
|
|
@@ -120,6 +125,7 @@ public class SubscriptionPageViewModel extends BaseViewModel {
|
|
|
}
|
|
|
|
|
|
public void onBackClick() {
|
|
|
+ EventHandler.report(EventId.purchaseclose_001);
|
|
|
if (isShowRetentionDialog()) {
|
|
|
showRetentionDialogEvent.call();
|
|
|
} else {
|
|
|
@@ -128,6 +134,7 @@ public class SubscriptionPageViewModel extends BaseViewModel {
|
|
|
}
|
|
|
|
|
|
public void onRestoreClick() {
|
|
|
+ EventHandler.report(EventId.restoreclick_001);
|
|
|
memberRepository.subscriptionResume()
|
|
|
.subscribe(new SingleObserver<Object>() {
|
|
|
@Override
|
|
|
@@ -137,12 +144,21 @@ public class SubscriptionPageViewModel extends BaseViewModel {
|
|
|
|
|
|
@Override
|
|
|
public void onSuccess(@NonNull Object object) {
|
|
|
+ EventHandler.report(EventId.restoresuccess_001);
|
|
|
ToastUtil.show(R.string.member_restore_success, ToastUtil.LENGTH_SHORT);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onError(@NonNull Throwable e) {
|
|
|
- ErrorHelper.errorThrowableToast(e, R.string.member_restore_fail, ToastUtil.LENGTH_SHORT);
|
|
|
+ if (e instanceof RxHttpHandler.ServerErrorException) {
|
|
|
+ RxHttpHandler.ServerErrorException serverErrorException = (RxHttpHandler.ServerErrorException) e;
|
|
|
+ if (serverErrorException.getCode() != ErrorCode.ERROR_SUBSCRIPTION_NOT_FOUND) {
|
|
|
+ EventHandler.report(EventId.restorefail_001);
|
|
|
+ }
|
|
|
+ ToastUtil.show(serverErrorException.getMsg(), ToastUtil.LENGTH_SHORT);
|
|
|
+ } else {
|
|
|
+ ToastUtil.show(R.string.net_error_message, ToastUtil.LENGTH_SHORT);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -175,6 +191,11 @@ public class SubscriptionPageViewModel extends BaseViewModel {
|
|
|
@Override
|
|
|
public void onSuccess(@NonNull List<GoodsBean> goodsBeanList) {
|
|
|
goodsList.setValue(goodsBeanList);
|
|
|
+ if (gpBillingClient.isSupportProductDetails()) {
|
|
|
+ EventHandler.report(EventId.playsethigh_001);
|
|
|
+ } else {
|
|
|
+ EventHandler.report(EventId.playsetlow_001);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -209,6 +230,9 @@ public class SubscriptionPageViewModel extends BaseViewModel {
|
|
|
PayOptionsBean payOptionsBean = payList.get(0);
|
|
|
int payPlatform = payOptionsBean.getPayPlatform();
|
|
|
int payMethod = payOptionsBean.getPayMethod();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(EventId.ID, String.valueOf(checkGoodsBean.getId()));
|
|
|
+ EventHandler.report(EventId.purchasesubclick_001, bundle);
|
|
|
memberRepository.requestGoodsPayOrder(checkGoodsBean.getId(), payPlatform, payMethod)
|
|
|
.subscribe(new SingleObserver<OrderPayResponse>() {
|
|
|
@Override
|
|
|
@@ -282,7 +306,6 @@ public class SubscriptionPageViewModel extends BaseViewModel {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
protected void onCleared() {
|
|
|
super.onCleared();
|