|
|
@@ -52,6 +52,7 @@ public class VoiceResultViewModel extends BaseViewModel {
|
|
|
private final String TAG = VoiceResultViewModel.class.getSimpleName();
|
|
|
|
|
|
private final VoiceAIRepository voiceAIRepository;
|
|
|
+ private final MutableLiveData<Boolean> isLoading = new MutableLiveData<>();
|
|
|
private final MutableLiveData<Boolean> isPlay = new MutableLiveData<>();
|
|
|
private final MutableLiveData<Long> totalDuration = new MutableLiveData<>();
|
|
|
private final MutableLiveData<Long> currentDuration = new MutableLiveData<>();
|
|
|
@@ -77,6 +78,10 @@ public class VoiceResultViewModel extends BaseViewModel {
|
|
|
checkScoring();
|
|
|
}
|
|
|
|
|
|
+ public LiveData<Boolean> getIsLoading() {
|
|
|
+ return isLoading;
|
|
|
+ }
|
|
|
+
|
|
|
public LiveData<Uri> getVoiceUri() {
|
|
|
return voiceUri;
|
|
|
}
|
|
|
@@ -274,23 +279,29 @@ public class VoiceResultViewModel extends BaseViewModel {
|
|
|
@Override
|
|
|
public void onSubscribe(@NonNull Disposable d) {
|
|
|
addDisposable(d);
|
|
|
+ isLoading.setValue(true);
|
|
|
AtmobLog.d(TAG, "startDownloadVoice onSubscribe: voiceUrl:" + voiceUrl);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onSuccess(@NonNull File file) {
|
|
|
+ isLoading.setValue(false);
|
|
|
AtmobLog.d(TAG, "startDownloadVoice onSuccess: " + file.getPath());
|
|
|
voiceUri.setValue(Uri.fromFile(file));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onError(@NonNull Throwable e) {
|
|
|
+ isLoading.setValue(false);
|
|
|
AtmobLog.d(TAG, "startDownloadVoice onError: " + e.getMessage());
|
|
|
voiceUri.setValue(Uri.parse(voiceUrl));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public void setIsLoading(boolean isLoading) {
|
|
|
+ this.isLoading.setValue(isLoading);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
protected void onCleared() {
|