|
@@ -19,6 +19,7 @@ import com.atmob.voiceai.data.repositories.VoiceAIRepository;
|
|
|
import com.atmob.voiceai.handlers.EventHandler;
|
|
import com.atmob.voiceai.handlers.EventHandler;
|
|
|
import com.atmob.voiceai.utils.DateUtil;
|
|
import com.atmob.voiceai.utils.DateUtil;
|
|
|
import com.atmob.voiceai.utils.MediaStoreHelper;
|
|
import com.atmob.voiceai.utils.MediaStoreHelper;
|
|
|
|
|
+import com.atmob.voiceai.utils.ScoringUtils;
|
|
|
import com.atmob.voiceai.utils.ShareUtils;
|
|
import com.atmob.voiceai.utils.ShareUtils;
|
|
|
import com.atmob.voiceai.utils.ToastUtil;
|
|
import com.atmob.voiceai.utils.ToastUtil;
|
|
|
import com.atmob.voiceai.utils.VoiceFileUtil;
|
|
import com.atmob.voiceai.utils.VoiceFileUtil;
|
|
@@ -29,6 +30,7 @@ import java.util.Random;
|
|
|
import java.util.Timer;
|
|
import java.util.Timer;
|
|
|
import java.util.TimerTask;
|
|
import java.util.TimerTask;
|
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
import javax.inject.Inject;
|
|
import javax.inject.Inject;
|
|
|
|
|
|
|
@@ -37,7 +39,9 @@ import atmob.reactivex.rxjava3.annotations.NonNull;
|
|
|
import atmob.reactivex.rxjava3.core.SingleObserver;
|
|
import atmob.reactivex.rxjava3.core.SingleObserver;
|
|
|
import atmob.reactivex.rxjava3.core.SingleSource;
|
|
import atmob.reactivex.rxjava3.core.SingleSource;
|
|
|
import atmob.reactivex.rxjava3.disposables.Disposable;
|
|
import atmob.reactivex.rxjava3.disposables.Disposable;
|
|
|
|
|
+import atmob.reactivex.rxjava3.functions.Action;
|
|
|
import atmob.reactivex.rxjava3.functions.Function;
|
|
import atmob.reactivex.rxjava3.functions.Function;
|
|
|
|
|
+import atmob.rxjava.utils.RxJavaUtil;
|
|
|
import dagger.hilt.android.lifecycle.HiltViewModel;
|
|
import dagger.hilt.android.lifecycle.HiltViewModel;
|
|
|
|
|
|
|
|
@HiltViewModel
|
|
@HiltViewModel
|
|
@@ -50,7 +54,7 @@ public class VoiceResultViewModel extends BaseViewModel {
|
|
|
private final MutableLiveData<Long> currentDuration = new MutableLiveData<>();
|
|
private final MutableLiveData<Long> currentDuration = new MutableLiveData<>();
|
|
|
private final SingleLiveEvent<?> refreshAudioCurrentProgress = new SingleLiveEvent<>();
|
|
private final SingleLiveEvent<?> refreshAudioCurrentProgress = new SingleLiveEvent<>();
|
|
|
private final MutableLiveData<List<VoiceListBean>> voiceList = new MutableLiveData<>();
|
|
private final MutableLiveData<List<VoiceListBean>> voiceList = new MutableLiveData<>();
|
|
|
-
|
|
|
|
|
|
|
+ private final SingleLiveEvent<?> showScoringEvent = new SingleLiveEvent<>();
|
|
|
private final MutableLiveData<UserVoiceBean> userVoiceBean = new MutableLiveData<>();
|
|
private final MutableLiveData<UserVoiceBean> userVoiceBean = new MutableLiveData<>();
|
|
|
private final OkHttpClient okHttpClient;
|
|
private final OkHttpClient okHttpClient;
|
|
|
private boolean isSeekbarChanging;
|
|
private boolean isSeekbarChanging;
|
|
@@ -58,18 +62,25 @@ public class VoiceResultViewModel extends BaseViewModel {
|
|
|
|
|
|
|
|
private boolean downloadFileDisposable;
|
|
private boolean downloadFileDisposable;
|
|
|
|
|
|
|
|
|
|
+ private boolean isCanShowScoring;
|
|
|
|
|
+
|
|
|
@Inject
|
|
@Inject
|
|
|
public VoiceResultViewModel(VoiceAIRepository voiceAIRepository, OkHttpClient okHttpClient) {
|
|
public VoiceResultViewModel(VoiceAIRepository voiceAIRepository, OkHttpClient okHttpClient) {
|
|
|
this.voiceAIRepository = voiceAIRepository;
|
|
this.voiceAIRepository = voiceAIRepository;
|
|
|
this.okHttpClient = okHttpClient;
|
|
this.okHttpClient = okHttpClient;
|
|
|
refreshVoiceRecommendList();
|
|
refreshVoiceRecommendList();
|
|
|
EventHandler.report(EventId.generateok_001);
|
|
EventHandler.report(EventId.generateok_001);
|
|
|
|
|
+ checkScoring();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public LiveData<List<VoiceListBean>> getVoiceList() {
|
|
public LiveData<List<VoiceListBean>> getVoiceList() {
|
|
|
return voiceList;
|
|
return voiceList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public LiveData<?> getShowScoringEvent() {
|
|
|
|
|
+ return showScoringEvent;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public LiveData<Boolean> getIsPlay() {
|
|
public LiveData<Boolean> getIsPlay() {
|
|
|
return isPlay;
|
|
return isPlay;
|
|
|
}
|
|
}
|
|
@@ -91,6 +102,17 @@ public class VoiceResultViewModel extends BaseViewModel {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ private void checkScoring() {
|
|
|
|
|
+ isCanShowScoring = ScoringUtils.checkShowScoring();
|
|
|
|
|
+ if (!isCanShowScoring) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ addDisposable(RxJavaUtil.timer(5, TimeUnit.SECONDS, () -> {
|
|
|
|
|
+ isCanShowScoring = false;
|
|
|
|
|
+ showScoringEvent.call();
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void setVoicePlay(boolean isPlay) {
|
|
public void setVoicePlay(boolean isPlay) {
|
|
|
this.isPlay.setValue(isPlay);
|
|
this.isPlay.setValue(isPlay);
|
|
|
}
|
|
}
|
|
@@ -193,10 +215,6 @@ public class VoiceResultViewModel extends BaseViewModel {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private String getVoiceFileName() {
|
|
|
|
|
- //月日年时分毫秒+3位随机数
|
|
|
|
|
- return "VoiceAI_" + DateUtil.formatNormalDate("ddMMyyyyHHmmssSSS", System.currentTimeMillis()) + (new Random().nextInt(900) + 100) + ".mp3";
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
public void onShareClick() {
|
|
public void onShareClick() {
|
|
|
EventHandler.report(EventId.generateokshare_001);
|
|
EventHandler.report(EventId.generateokshare_001);
|
|
@@ -248,4 +266,11 @@ public class VoiceResultViewModel extends BaseViewModel {
|
|
|
timer = null;
|
|
timer = null;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void checkShowScoring() {
|
|
|
|
|
+ if (isCanShowScoring) {
|
|
|
|
|
+ isCanShowScoring = false;
|
|
|
|
|
+ showScoringEvent.call();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|