|
|
@@ -3,6 +3,7 @@ package com.datarecovery.master.module.homepage;
|
|
|
import com.atmob.app.lib.base.BaseViewModel;
|
|
|
import com.atmob.app.lib.livedata.SingleLiveEvent;
|
|
|
import com.atmob.common.runtime.ActivityUtil;
|
|
|
+import com.atmob.common.runtime.ContextUtil;
|
|
|
import com.datarecovery.master.R;
|
|
|
import com.datarecovery.master.data.consts.EventId;
|
|
|
import com.datarecovery.master.data.repositories.ConfigRepository;
|
|
|
@@ -28,6 +29,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel;
|
|
|
import android.util.Pair;
|
|
|
|
|
|
import androidx.lifecycle.LiveData;
|
|
|
+import androidx.lifecycle.MutableLiveData;
|
|
|
|
|
|
|
|
|
@HiltViewModel
|
|
|
@@ -40,14 +42,37 @@ public class HomePageViewModel extends BaseViewModel {
|
|
|
private final SingleLiveEvent<?> requestManagePermission = new SingleLiveEvent<>();
|
|
|
private final SingleLiveEvent<?> requestAndroidDataPermission = new SingleLiveEvent<>();
|
|
|
private final DeviceFuncRepository deviceFuncRepository;
|
|
|
+ private final ConfigRepository configRepository;
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
- public HomePageViewModel(DeviceFuncRepository deviceFuncRepository) {
|
|
|
+ public HomePageViewModel(DeviceFuncRepository deviceFuncRepository, ConfigRepository configRepository) {
|
|
|
this.deviceFuncRepository = deviceFuncRepository;
|
|
|
+ this.configRepository = configRepository;
|
|
|
initList();
|
|
|
}
|
|
|
|
|
|
+ public LiveData<Boolean> getIsOpenTrialMembership() {
|
|
|
+ return configRepository.getIsOpenTrialMembership();
|
|
|
+ }
|
|
|
+
|
|
|
+ public LiveData<Boolean> getIsHasAudioFunc() {
|
|
|
+ return deviceFuncRepository.getIsHasAudioFunc();
|
|
|
+ }
|
|
|
+
|
|
|
+ public LiveData<Boolean> getIsHasFileFunc() {
|
|
|
+ return deviceFuncRepository.getIsHasFileFunc();
|
|
|
+ }
|
|
|
+
|
|
|
+ public LiveData<Boolean> getIsHasImageFunc() {
|
|
|
+ return deviceFuncRepository.getIsHasImageFunc();
|
|
|
+ }
|
|
|
+
|
|
|
+ public LiveData<Boolean> getIsHasVideoFunc() {
|
|
|
+ return deviceFuncRepository.getIsHasVideoFunc();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public List<FunctionBean> getFunctionList() {
|
|
|
return functionList;
|
|
|
}
|
|
|
@@ -64,10 +89,10 @@ 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, R.string.home_page_file_recovery, R.drawable.icon_home_page_file_recovery));
|
|
|
- functionList.add(new FunctionBean(FunctionBean.VIDEO_RECOVERY, R.string.home_page_video_recovery, R.drawable.icon_home_page_video_recovery));
|
|
|
- functionList.add(new FunctionBean(FunctionBean.AUDIO_RECOVERY, R.string.home_page_audio_recovery, R.drawable.icon_home_page_audio_recovery));
|
|
|
- functionList.add(new FunctionBean(FunctionBean.IMG_CLEARING, R.string.home_page_img_clearing, R.drawable.icon_home_page_img_clearing));
|
|
|
+ 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.IMG_CLEARING, ContextUtil.getContext().getString(R.string.home_page_img_clearing), R.drawable.icon_home_page_img_clearing, null));
|
|
|
}
|
|
|
|
|
|
public LiveData<?> getRequestManagePermission() {
|
|
|
@@ -94,7 +119,7 @@ public class HomePageViewModel extends BaseViewModel {
|
|
|
reportFirstClickFunction(type);
|
|
|
if (deviceFuncRepository.isHaveAuth(type)) {
|
|
|
if (stepCallback != null) stepCallback.onNextStep(false);
|
|
|
- } else if (ConfigRepository.isConformTrialAuths(type)) {
|
|
|
+ } else if (configRepository.isConformTrialAuths(type)) {
|
|
|
if (stepCallback != null) stepCallback.onNextStep(true);
|
|
|
} else {
|
|
|
MemberActivity.start(ActivityUtil.getTopActivity(), type);
|
|
|
@@ -102,7 +127,7 @@ public class HomePageViewModel extends BaseViewModel {
|
|
|
}
|
|
|
|
|
|
public void reportFirstClickFunction(@MemberType String type) {
|
|
|
- if (ConfigRepository.isIsOpenTrialMembership()) {
|
|
|
+ if (configRepository.isIsOpenTrialMembership()) {
|
|
|
if (ReportUtil.isRecordOneEvent(EventId.hf1001116)) {
|
|
|
EventHelper.report(EventId.hf1001130, Maps.asMap(EventId.EVENT_ID, ReportUtil.getReportId(type)));
|
|
|
return;
|