Browse Source

完成首页其他内容点击功能

zk 1 year ago
parent
commit
3c89acdced

+ 5 - 2
app/src/main/java/com/atmob/voiceai/data/repositories/VoiceAIRepository.java

@@ -21,6 +21,7 @@ import com.atmob.voiceai.data.api.response.TextToSpeechResponse;
 import com.atmob.voiceai.data.api.response.VoiceInfoResponse;
 import com.atmob.voiceai.data.api.response.VoiceListResponse;
 import com.atmob.voiceai.data.api.response.VoiceTypeResponse;
+import com.atmob.voiceai.utils.BoxingUtil;
 import com.atmob.voiceai.utils.ToastUtil;
 
 import java.util.ArrayList;
@@ -41,6 +42,7 @@ public class VoiceAIRepository {
 
     private final AtmobApi atmobApi;
     private final GenerateApi generateApi;
+    private final AccountRepository accountRepository;
 
     private boolean textToSpeechRequest;
     private final MutableLiveData<Integer> adFreeGenerateNumber = new MutableLiveData<>();
@@ -65,9 +67,10 @@ public class VoiceAIRepository {
     }
 
     @Inject
-    public VoiceAIRepository(AtmobApi atmobApi, GenerateApi generateApi) {
+    public VoiceAIRepository(AtmobApi atmobApi, GenerateApi generateApi, AccountRepository accountRepository) {
         this.atmobApi = atmobApi;
         this.generateApi = generateApi;
+        this.accountRepository = accountRepository;
         refreshVoiceInfo();
     }
 
@@ -101,7 +104,7 @@ public class VoiceAIRepository {
 
 
     private void refreshVoiceInfo() {
-        if (isRequestFreeGenerate) {
+        if (isRequestFreeGenerate || BoxingUtil.boxing(accountRepository.getIsMember().getValue())) {
             return;
         }
         requestVoiceInfo().subscribe(new SingleObserver<VoiceInfoResponse>() {

+ 4 - 0
app/src/main/java/com/atmob/voiceai/module/voiceai/VoiceAIViewModel.java

@@ -348,6 +348,10 @@ public class VoiceAIViewModel extends BaseViewModel {
         SubscriptionPageActivity.start(ActivityUtil.getTopActivity());
     }
 
+    public void onGetMoreClick() {
+        SubscriptionPageActivity.start(ActivityUtil.getTopActivity());
+    }
+
     @Override
     protected void onCleared() {
         super.onCleared();

+ 2 - 0
app/src/main/res/layout/fragment_voice_ai.xml

@@ -123,6 +123,7 @@
                     app:layout_constraintTop_toTopOf="parent" />
 
                 <View
+                    android:onClick="@{()-> voiceAIViewModel.onGetMoreClick()}"
                     android:id="@+id/v_free_get_bg"
                     android:layout_width="match_parent"
                     android:layout_height="0dp"
@@ -346,6 +347,7 @@
                     app:layout_constraintTop_toTopOf="@+id/v_generate" />
 
                 <ImageView
+                    isGone="@{voiceAIViewModel.isMember()}"
                     android:id="@+id/iv_ad"
                     android:layout_width="0dp"
                     android:layout_height="0dp"