|
|
@@ -10,6 +10,7 @@ import com.android.billingclient.api.BillingClient;
|
|
|
import com.android.billingclient.api.Purchase;
|
|
|
import com.atmob.app.lib.handler.RxHttpHandler;
|
|
|
import com.atmob.common.logging.AtmobLog;
|
|
|
+import com.atmob.common.runtime.ContextUtil;
|
|
|
import com.atmob.voiceai.data.api.AtmobApi;
|
|
|
import com.atmob.voiceai.data.api.bean.MemberInfoBean;
|
|
|
import com.atmob.voiceai.data.api.request.BaseRequest;
|
|
|
@@ -24,6 +25,8 @@ import com.atmob.voiceai.data.api.response.UserInfoResponse;
|
|
|
import com.atmob.voiceai.data.consts.ErrorCode;
|
|
|
import com.atmob.voiceai.data.consts.EventId;
|
|
|
import com.atmob.voiceai.handlers.EventHandler;
|
|
|
+import com.atmob.voiceai.module.integral.InternalPurchaseActivity;
|
|
|
+import com.atmob.voiceai.module.subscription.SubscriptionPageActivity;
|
|
|
import com.atmob.voiceai.sdk.billing.GPBillingClient;
|
|
|
import com.atmob.voiceai.utils.BoxingUtil;
|
|
|
|
|
|
@@ -49,6 +52,8 @@ public class MemberRepository {
|
|
|
private boolean requestUserInfoDisabled;
|
|
|
private final Handler refreshMemberHandler = new Handler();
|
|
|
|
|
|
+ private long nowConsumptionTime;
|
|
|
+
|
|
|
@Inject
|
|
|
public MemberRepository(AtmobApi atmobApi, GPBillingClient gpBillingClient) {
|
|
|
this.atmobApi = atmobApi;
|
|
|
@@ -149,6 +154,26 @@ public class MemberRepository {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public void consumptionIntegral(int integral, @NonNull Runnable runnable) {
|
|
|
+ //积分是否足够
|
|
|
+ int creditValue = BoxingUtil.boxing(credit.getValue());
|
|
|
+ if (integral <= creditValue) {
|
|
|
+ runnable.run();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ long consumptionRefresh = 60 * 1000;
|
|
|
+ if (nowConsumptionTime == 0 || System.currentTimeMillis() - nowConsumptionTime > consumptionRefresh) {
|
|
|
+ nowConsumptionTime = System.currentTimeMillis();
|
|
|
+ refreshUserData();
|
|
|
+ }
|
|
|
+ if (BoxingUtil.boxing(isMember.getValue())) {
|
|
|
+ InternalPurchaseActivity.start(ContextUtil.getContext());
|
|
|
+ } else {
|
|
|
+ SubscriptionPageActivity.start(ContextUtil.getContext());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public void refreshUserData() {
|
|
|
if (requestUserInfoDisabled) {
|
|
|
return;
|