Loading app/src/main/java/foundation/e/apps/ui/application/ApplicationViewModel.kt +13 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.aurora.gplayapi.data.models.AuthData import com.aurora.gplayapi.exceptions.ApiException import dagger.hilt.android.lifecycle.HiltViewModel import foundation.e.apps.R import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Status Loading @@ -34,6 +35,8 @@ import foundation.e.apps.data.fusedDownload.FusedManagerRepository import foundation.e.apps.data.fusedDownload.models.FusedDownload import foundation.e.apps.install.download.data.DownloadProgress import foundation.e.apps.install.download.data.DownloadProgressLD import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import javax.inject.Inject Loading Loading @@ -77,6 +80,16 @@ class ApplicationViewModel @Inject constructor( origin ) fusedApp.postValue(appData) val status = appData.second if (status != ResultStatus.OK) { EventBus.invokeEvent( AppEvent.DataLoadError( ResultSupreme.create(status, appData.first) ) ) } } catch (e: ApiException.AppNotFound) { _errorMessageLiveData.postValue(R.string.app_not_found) } catch (e: Exception) { Loading app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListViewModel.kt +4 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.fused.FusedAPIRepository import foundation.e.apps.data.fused.data.FusedApp import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import javax.inject.Inject Loading Loading @@ -71,6 +73,8 @@ class ApplicationListViewModel @Inject constructor( appListLiveData.postValue(ResultSupreme.create(ResultStatus.OK, it.first)) updateNextPageUrl(it.second) } if (!result.isSuccess()) EventBus.invokeEvent(AppEvent.DataLoadError(result)) } } Loading app/src/main/java/foundation/e/apps/ui/categories/CategoriesViewModel.kt +13 −0 Original line number Diff line number Diff line Loading @@ -22,10 +22,13 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.fused.FusedAPIRepository import foundation.e.apps.data.fused.data.FusedCategory import foundation.e.apps.data.fused.utils.CategoryType import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.launch import javax.inject.Inject Loading @@ -47,6 +50,16 @@ class CategoriesViewModel @Inject constructor( viewModelScope.launch { val categoriesData = fusedAPIRepository.getCategoriesList(type) categoriesList.postValue(categoriesData) val status = categoriesData.third if (status != ResultStatus.OK) { EventBus.invokeEvent( AppEvent.DataLoadError( ResultSupreme.create(status, categoriesData.second) ) ) } } } } app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +6 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.fused.FusedAPIRepository import foundation.e.apps.data.fused.data.FusedApp import foundation.e.apps.data.fused.data.FusedHome import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.launch import javax.inject.Inject Loading @@ -52,6 +54,10 @@ class HomeViewModel @Inject constructor( viewModelScope.launch { fusedAPIRepository.getHomeScreenData(authData).observe(lifecycleOwner) { homeScreenData.postValue(it) if (!it.isSuccess()) viewModelScope.launch { EventBus.invokeEvent(AppEvent.DataLoadError(it)) } } } } Loading app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +3 −14 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import foundation.e.apps.data.fused.data.FusedApp import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.exceptions.CleanApkException import foundation.e.apps.data.login.exceptions.GPlayException import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch Loading Loading @@ -98,20 +100,7 @@ class SearchViewModel @Inject constructor( searchResult.postValue(searchResultSupreme) if (!searchResultSupreme.isSuccess()) { val exception = if (authData.aasToken.isNotBlank() || authData.authToken.isNotBlank()) { GPlayException( searchResultSupreme.isTimeout(), searchResultSupreme.message.ifBlank { DATA_LOAD_ERROR } ) } else { CleanApkException( searchResultSupreme.isTimeout(), searchResultSupreme.message.ifBlank { DATA_LOAD_ERROR } ) } // handleException(exception) EventBus.invokeEvent(AppEvent.DataLoadError(searchResultSupreme)) } nextSubBundle = null Loading Loading
app/src/main/java/foundation/e/apps/ui/application/ApplicationViewModel.kt +13 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.aurora.gplayapi.data.models.AuthData import com.aurora.gplayapi.exceptions.ApiException import dagger.hilt.android.lifecycle.HiltViewModel import foundation.e.apps.R import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Status Loading @@ -34,6 +35,8 @@ import foundation.e.apps.data.fusedDownload.FusedManagerRepository import foundation.e.apps.data.fusedDownload.models.FusedDownload import foundation.e.apps.install.download.data.DownloadProgress import foundation.e.apps.install.download.data.DownloadProgressLD import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import javax.inject.Inject Loading Loading @@ -77,6 +80,16 @@ class ApplicationViewModel @Inject constructor( origin ) fusedApp.postValue(appData) val status = appData.second if (status != ResultStatus.OK) { EventBus.invokeEvent( AppEvent.DataLoadError( ResultSupreme.create(status, appData.first) ) ) } } catch (e: ApiException.AppNotFound) { _errorMessageLiveData.postValue(R.string.app_not_found) } catch (e: Exception) { Loading
app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListViewModel.kt +4 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.fused.FusedAPIRepository import foundation.e.apps.data.fused.data.FusedApp import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import javax.inject.Inject Loading Loading @@ -71,6 +73,8 @@ class ApplicationListViewModel @Inject constructor( appListLiveData.postValue(ResultSupreme.create(ResultStatus.OK, it.first)) updateNextPageUrl(it.second) } if (!result.isSuccess()) EventBus.invokeEvent(AppEvent.DataLoadError(result)) } } Loading
app/src/main/java/foundation/e/apps/ui/categories/CategoriesViewModel.kt +13 −0 Original line number Diff line number Diff line Loading @@ -22,10 +22,13 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.fused.FusedAPIRepository import foundation.e.apps.data.fused.data.FusedCategory import foundation.e.apps.data.fused.utils.CategoryType import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.launch import javax.inject.Inject Loading @@ -47,6 +50,16 @@ class CategoriesViewModel @Inject constructor( viewModelScope.launch { val categoriesData = fusedAPIRepository.getCategoriesList(type) categoriesList.postValue(categoriesData) val status = categoriesData.third if (status != ResultStatus.OK) { EventBus.invokeEvent( AppEvent.DataLoadError( ResultSupreme.create(status, categoriesData.second) ) ) } } } }
app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +6 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.fused.FusedAPIRepository import foundation.e.apps.data.fused.data.FusedApp import foundation.e.apps.data.fused.data.FusedHome import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.launch import javax.inject.Inject Loading @@ -52,6 +54,10 @@ class HomeViewModel @Inject constructor( viewModelScope.launch { fusedAPIRepository.getHomeScreenData(authData).observe(lifecycleOwner) { homeScreenData.postValue(it) if (!it.isSuccess()) viewModelScope.launch { EventBus.invokeEvent(AppEvent.DataLoadError(it)) } } } } Loading
app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +3 −14 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import foundation.e.apps.data.fused.data.FusedApp import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.exceptions.CleanApkException import foundation.e.apps.data.login.exceptions.GPlayException import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch Loading Loading @@ -98,20 +100,7 @@ class SearchViewModel @Inject constructor( searchResult.postValue(searchResultSupreme) if (!searchResultSupreme.isSuccess()) { val exception = if (authData.aasToken.isNotBlank() || authData.authToken.isNotBlank()) { GPlayException( searchResultSupreme.isTimeout(), searchResultSupreme.message.ifBlank { DATA_LOAD_ERROR } ) } else { CleanApkException( searchResultSupreme.isTimeout(), searchResultSupreme.message.ifBlank { DATA_LOAD_ERROR } ) } // handleException(exception) EventBus.invokeEvent(AppEvent.DataLoadError(searchResultSupreme)) } nextSubBundle = null Loading