Browse Source

[fix]超级会员显示问题

zk 1 year ago
parent
commit
6f14641ac3

+ 27 - 18
app/src/main/java/com/datarecovery/master/data/repositories/DeviceFuncRepository.java

@@ -15,9 +15,7 @@ import com.datarecovery.master.module.member.MemberType;
 import com.datarecovery.master.utils.RxHttpHandler;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 
@@ -37,10 +35,10 @@ public class DeviceFuncRepository {
     private final List<String> authsList = new ArrayList<>();
     private final AtmobApi atmobApi;
 
-    private final MutableLiveData<Boolean> isHasImageFunc = new MutableLiveData<>();
-    private final MutableLiveData<Boolean> isHasFileFunc = new MutableLiveData<>();
-    private final MutableLiveData<Boolean> isHasVideoFunc = new MutableLiveData<>();
-    private final MutableLiveData<Boolean> isHasAudioFunc = new MutableLiveData<>();
+    private final MutableLiveData<Boolean> isShowImageTrialTag = new MutableLiveData<>(false);
+    private final MutableLiveData<Boolean> isShowFileTrialTag = new MutableLiveData<>(false);
+    private final MutableLiveData<Boolean> isShowVideoTrialTag = new MutableLiveData<>(false);
+    private final MutableLiveData<Boolean> isShowAudioTrialTag = new MutableLiveData<>(false);
 
     private boolean refreshFunAuthsFlag;
 
@@ -84,10 +82,7 @@ public class DeviceFuncRepository {
                         refreshFunAuthsFlag = false;
                         authsList.clear();
                         authsList.addAll(funcAuthsResponse.getAuths());
-                        isHasImageFunc.setValue(authsList.contains(MemberType.APP_IMAGE_RECOVER));
-                        isHasFileFunc.setValue(authsList.contains(MemberType.APP_FILE_RECOVER));
-                        isHasVideoFunc.setValue(authsList.contains(MemberType.APP_VIDEO_RECOVER));
-                        isHasAudioFunc.setValue(authsList.contains(MemberType.APP_AUDIO_RECOVER));
+                        checkTrialTag();
                     }
 
                     @Override
@@ -97,20 +92,34 @@ public class DeviceFuncRepository {
                 });
     }
 
-    public LiveData<Boolean> getIsHasAudioFunc() {
-        return isHasAudioFunc;
+    private void checkTrialTag() {
+        if (authsList.contains(MemberType.APP_SUPER_RECOVER)) {
+            isShowImageTrialTag.setValue(false);
+            isShowFileTrialTag.setValue(false);
+            isShowVideoTrialTag.setValue(false);
+            isShowAudioTrialTag.setValue(false);
+            return;
+        }
+        isShowImageTrialTag.setValue(!authsList.contains(MemberType.APP_IMAGE_RECOVER));
+        isShowFileTrialTag.setValue(!authsList.contains(MemberType.APP_FILE_RECOVER));
+        isShowVideoTrialTag.setValue(!authsList.contains(MemberType.APP_VIDEO_RECOVER));
+        isShowAudioTrialTag.setValue(!authsList.contains(MemberType.APP_AUDIO_RECOVER));
+    }
+
+    public LiveData<Boolean> getIsShowAudioTrialTag() {
+        return isShowAudioTrialTag;
     }
 
-    public LiveData<Boolean> getIsHasFileFunc() {
-        return isHasFileFunc;
+    public LiveData<Boolean> getIsShowFileTrialTag() {
+        return isShowFileTrialTag;
     }
 
-    public LiveData<Boolean> getIsHasImageFunc() {
-        return isHasImageFunc;
+    public LiveData<Boolean> getIsShowImageTrialTag() {
+        return isShowImageTrialTag;
     }
 
-    public LiveData<Boolean> getIsHasVideoFunc() {
-        return isHasVideoFunc;
+    public LiveData<Boolean> getIsShowVideoTrialTag() {
+        return isShowVideoTrialTag;
     }
 
     public void clearAuths() {

+ 5 - 8
app/src/main/java/com/datarecovery/master/module/homepage/FunctionBean.java

@@ -1,10 +1,7 @@
 package com.datarecovery.master.module.homepage;
 
-import android.graphics.drawable.Drawable;
-
 import androidx.annotation.DrawableRes;
 import androidx.annotation.IntDef;
-import androidx.annotation.StringRes;
 import androidx.lifecycle.LiveData;
 
 import java.lang.annotation.Retention;
@@ -28,17 +25,17 @@ public class FunctionBean {
     @DrawableRes
     private int functionIcon;
 
-    private LiveData<Boolean> isHasFunc;
+    private LiveData<Boolean> isShowTrial;
 
-    public FunctionBean(@FunctionId int functionId, String functionName, int functionIcon, LiveData<Boolean> isHasFunc) {
+    public FunctionBean(@FunctionId int functionId, String functionName, int functionIcon, LiveData<Boolean> isShowTrial) {
         this.functionId = functionId;
         this.functionName = functionName;
         this.functionIcon = functionIcon;
-        this.isHasFunc = isHasFunc;
+        this.isShowTrial = isShowTrial;
     }
 
-    public LiveData<Boolean> getIsHasFunc() {
-        return isHasFunc;
+    public LiveData<Boolean> getIsShowTrial() {
+        return isShowTrial;
     }
 
     @FunctionId

+ 11 - 12
app/src/main/java/com/datarecovery/master/module/homepage/HomePageViewModel.java

@@ -29,7 +29,6 @@ import dagger.hilt.android.lifecycle.HiltViewModel;
 import android.util.Pair;
 
 import androidx.lifecycle.LiveData;
-import androidx.lifecycle.MutableLiveData;
 
 
 @HiltViewModel
@@ -56,20 +55,20 @@ public class HomePageViewModel extends BaseViewModel {
         return configRepository.getIsOpenTrialMembership();
     }
 
-    public LiveData<Boolean> getIsHasAudioFunc() {
-        return deviceFuncRepository.getIsHasAudioFunc();
+    public LiveData<Boolean> getIsShowAudioTrialTag() {
+        return deviceFuncRepository.getIsShowAudioTrialTag();
     }
 
-    public LiveData<Boolean> getIsHasFileFunc() {
-        return deviceFuncRepository.getIsHasFileFunc();
+    public LiveData<Boolean> getIsShowFileTrialTag() {
+        return deviceFuncRepository.getIsShowFileTrialTag();
     }
 
-    public LiveData<Boolean> getIsHasImageFunc() {
-        return deviceFuncRepository.getIsHasImageFunc();
+    public LiveData<Boolean> getIsShowImageTrialTag() {
+        return deviceFuncRepository.getIsShowImageTrialTag();
     }
 
-    public LiveData<Boolean> getIsHasVideoFunc() {
-        return deviceFuncRepository.getIsHasVideoFunc();
+    public LiveData<Boolean> getIsShowVideoTrialTag() {
+        return deviceFuncRepository.getIsShowVideoTrialTag();
     }
 
 
@@ -89,9 +88,9 @@ public class HomePageViewModel extends BaseViewModel {
         informationList.add(new Pair<>("153*****912 购买了音频恢复", "11分钟前"));
         informationList.add(new Pair<>("159*****864 购买了视频恢复", "15分钟前"));
 
-        functionList.add(new FunctionBean(FunctionBean.FILE_RECOVERY, ContextUtil.getContext().getString(R.string.home_page_file_recovery), R.drawable.icon_home_page_file_recovery, getIsHasFileFunc()));
-        functionList.add(new FunctionBean(FunctionBean.VIDEO_RECOVERY, ContextUtil.getContext().getString(R.string.home_page_video_recovery), R.drawable.icon_home_page_video_recovery, getIsHasVideoFunc()));
-        functionList.add(new FunctionBean(FunctionBean.AUDIO_RECOVERY, ContextUtil.getContext().getString(R.string.home_page_audio_recovery), R.drawable.icon_home_page_audio_recovery, getIsHasAudioFunc()));
+        functionList.add(new FunctionBean(FunctionBean.FILE_RECOVERY, ContextUtil.getContext().getString(R.string.home_page_file_recovery), R.drawable.icon_home_page_file_recovery, getIsShowFileTrialTag()));
+        functionList.add(new FunctionBean(FunctionBean.VIDEO_RECOVERY, ContextUtil.getContext().getString(R.string.home_page_video_recovery), R.drawable.icon_home_page_video_recovery, getIsShowVideoTrialTag()));
+        functionList.add(new FunctionBean(FunctionBean.AUDIO_RECOVERY, ContextUtil.getContext().getString(R.string.home_page_audio_recovery), R.drawable.icon_home_page_audio_recovery, getIsShowAudioTrialTag()));
         functionList.add(new FunctionBean(FunctionBean.IMG_CLEARING, ContextUtil.getContext().getString(R.string.home_page_img_clearing), R.drawable.icon_home_page_img_clearing, null));
     }
 

+ 1 - 1
app/src/main/res/layout/fragment_home_page.xml

@@ -283,7 +283,7 @@
                     app:layout_constraintWidth_percent="0.4666666666666667" />
 
                 <TextView
-                    isGone="@{!homePageViewModel.isOpenTrialMembership || homePageViewModel.isHasImageFunc}"
+                    isGone="@{!homePageViewModel.isOpenTrialMembership || !homePageViewModel.isShowImageTrialTag}"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:background="@drawable/bg_trial_tag"

+ 1 - 1
app/src/main/res/layout/item_home_page_other_function.xml

@@ -35,7 +35,7 @@
             tools:src="@drawable/icon_home_page_file_recovery" />
 
         <TextView
-            isGone="@{!isOpenTrial || bean.isHasFunc == null  || bean.isHasFunc}"
+            isGone="@{!isOpenTrial || bean.isShowTrial == null  || !bean.isShowTrial}"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginStart="-14dp"