Loading app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt +1 −1 Original line number Diff line number Diff line Loading @@ -381,7 +381,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize ) Status.UNAVAILABLE -> handleUnavaiable(installButton, fusedApp, downloadPB, appSize) Status.QUEUED, Status.AWAITING -> handleQueued( Status.QUEUED, Status.AWAITING, Status.DOWNLOADED -> handleQueued( installButton, fusedApp, downloadPB, Loading app/src/main/java/foundation/e/apps/applicationlist/model/ApplicationListRVAdapter.kt +1 −1 Original line number Diff line number Diff line Loading @@ -219,7 +219,7 @@ class ApplicationListRVAdapter( Status.UNAVAILABLE -> { handleUnavailable(view, searchApp, holder) } Status.QUEUED, Status.AWAITING, Status.DOWNLOADING -> { Status.QUEUED, Status.AWAITING, Status.DOWNLOADING, Status.DOWNLOADED -> { handleDownloading(view, searchApp) } Status.INSTALLING, Status.UNINSTALLING -> { Loading app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt +2 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import foundation.e.apps.home.HomeFragmentDirections import foundation.e.apps.utils.enums.Origin import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.enums.User import timber.log.Timber class HomeChildRVAdapter( private var fusedAPIInterface: FusedAPIInterface?, Loading Loading @@ -110,7 +111,7 @@ class HomeChildRVAdapter( Status.UNAVAILABLE -> { handleUnavailable(homeApp, holder, view) } Status.QUEUED, Status.AWAITING, Status.DOWNLOADING -> { Status.QUEUED, Status.AWAITING, Status.DOWNLOADING, Status.DOWNLOADED -> { handleQueued(view, homeApp) } Status.INSTALLING, Status.UNINSTALLING -> { Loading app/src/main/java/foundation/e/apps/manager/database/DatabaseRepository.kt +19 −5 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ import foundation.e.apps.OpenForTesting import foundation.e.apps.manager.database.fusedDownload.FusedDownload import foundation.e.apps.manager.database.fusedDownload.FusedDownloadDAO import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import javax.inject.Inject import javax.inject.Singleton Loading @@ -15,29 +17,41 @@ class DatabaseRepository @Inject constructor( private val fusedDownloadDAO: FusedDownloadDAO ) { private val mutex = Mutex() suspend fun addDownload(fusedDownload: FusedDownload) { mutex.withLock { return fusedDownloadDAO.addDownload(fusedDownload) } } suspend fun getDownloadList(): List<FusedDownload> { mutex.withLock { return fusedDownloadDAO.getDownloadList() } } fun getDownloadLiveList(): LiveData<List<FusedDownload>> { return fusedDownloadDAO.getDownloadLiveList() } suspend fun updateDownload(fusedDownload: FusedDownload) { mutex.withLock { fusedDownloadDAO.updateDownload(fusedDownload) } } suspend fun deleteDownload(fusedDownload: FusedDownload) { mutex.withLock { return fusedDownloadDAO.deleteDownload(fusedDownload) } } suspend fun getDownloadById(id: String): FusedDownload? { mutex.withLock { return fusedDownloadDAO.getDownloadById(id) } } fun getDownloadFlowById(id: String): Flow<FusedDownload> { return fusedDownloadDAO.getDownloadFlowById(id).asFlow() Loading app/src/main/java/foundation/e/apps/manager/fused/FusedManagerImpl.kt +1 −7 Original line number Diff line number Diff line Loading @@ -92,18 +92,15 @@ class FusedManagerImpl @Inject constructor( suspend fun updateDownloadStatus(fusedDownload: FusedDownload, status: Status) { if (status == Status.INSTALLED) { fusedDownload.status = status databaseRepository.updateDownload(fusedDownload) // databaseRepository.updateDownload(fusedDownload) DownloadManagerBR.downloadedList.clear() delay(100) flushOldDownload(fusedDownload.packageName) databaseRepository.deleteDownload(fusedDownload) } else if (status == Status.INSTALLING) { fusedDownload.downloadIdMap.all { true } fusedDownload.status = status databaseRepository.updateDownload(fusedDownload) delay(100) installApp(fusedDownload) delay(100) } } Loading Loading @@ -141,7 +138,6 @@ class FusedManagerImpl @Inject constructor( Timber.d("Unsupported application type!") fusedDownload.status = Status.INSTALLATION_ISSUE databaseRepository.updateDownload(fusedDownload) delay(100) } } } Loading @@ -157,7 +153,6 @@ class FusedManagerImpl @Inject constructor( // Reset the status before deleting download updateDownloadStatus(fusedDownload, fusedDownload.orgStatus) delay(100) databaseRepository.deleteDownload(fusedDownload) flushOldDownload(fusedDownload.packageName) Loading Loading @@ -199,7 +194,6 @@ class FusedManagerImpl @Inject constructor( fusedDownload.status = Status.DOWNLOADING databaseRepository.updateDownload(fusedDownload) DownloadProgressLD.setDownloadId(-1) delay(100) fusedDownload.downloadURLList.forEach { count += 1 val packagePath: File = if (fusedDownload.files.isNotEmpty()) { Loading Loading
app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt +1 −1 Original line number Diff line number Diff line Loading @@ -381,7 +381,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize ) Status.UNAVAILABLE -> handleUnavaiable(installButton, fusedApp, downloadPB, appSize) Status.QUEUED, Status.AWAITING -> handleQueued( Status.QUEUED, Status.AWAITING, Status.DOWNLOADED -> handleQueued( installButton, fusedApp, downloadPB, Loading
app/src/main/java/foundation/e/apps/applicationlist/model/ApplicationListRVAdapter.kt +1 −1 Original line number Diff line number Diff line Loading @@ -219,7 +219,7 @@ class ApplicationListRVAdapter( Status.UNAVAILABLE -> { handleUnavailable(view, searchApp, holder) } Status.QUEUED, Status.AWAITING, Status.DOWNLOADING -> { Status.QUEUED, Status.AWAITING, Status.DOWNLOADING, Status.DOWNLOADED -> { handleDownloading(view, searchApp) } Status.INSTALLING, Status.UNINSTALLING -> { Loading
app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt +2 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import foundation.e.apps.home.HomeFragmentDirections import foundation.e.apps.utils.enums.Origin import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.enums.User import timber.log.Timber class HomeChildRVAdapter( private var fusedAPIInterface: FusedAPIInterface?, Loading Loading @@ -110,7 +111,7 @@ class HomeChildRVAdapter( Status.UNAVAILABLE -> { handleUnavailable(homeApp, holder, view) } Status.QUEUED, Status.AWAITING, Status.DOWNLOADING -> { Status.QUEUED, Status.AWAITING, Status.DOWNLOADING, Status.DOWNLOADED -> { handleQueued(view, homeApp) } Status.INSTALLING, Status.UNINSTALLING -> { Loading
app/src/main/java/foundation/e/apps/manager/database/DatabaseRepository.kt +19 −5 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ import foundation.e.apps.OpenForTesting import foundation.e.apps.manager.database.fusedDownload.FusedDownload import foundation.e.apps.manager.database.fusedDownload.FusedDownloadDAO import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import javax.inject.Inject import javax.inject.Singleton Loading @@ -15,29 +17,41 @@ class DatabaseRepository @Inject constructor( private val fusedDownloadDAO: FusedDownloadDAO ) { private val mutex = Mutex() suspend fun addDownload(fusedDownload: FusedDownload) { mutex.withLock { return fusedDownloadDAO.addDownload(fusedDownload) } } suspend fun getDownloadList(): List<FusedDownload> { mutex.withLock { return fusedDownloadDAO.getDownloadList() } } fun getDownloadLiveList(): LiveData<List<FusedDownload>> { return fusedDownloadDAO.getDownloadLiveList() } suspend fun updateDownload(fusedDownload: FusedDownload) { mutex.withLock { fusedDownloadDAO.updateDownload(fusedDownload) } } suspend fun deleteDownload(fusedDownload: FusedDownload) { mutex.withLock { return fusedDownloadDAO.deleteDownload(fusedDownload) } } suspend fun getDownloadById(id: String): FusedDownload? { mutex.withLock { return fusedDownloadDAO.getDownloadById(id) } } fun getDownloadFlowById(id: String): Flow<FusedDownload> { return fusedDownloadDAO.getDownloadFlowById(id).asFlow() Loading
app/src/main/java/foundation/e/apps/manager/fused/FusedManagerImpl.kt +1 −7 Original line number Diff line number Diff line Loading @@ -92,18 +92,15 @@ class FusedManagerImpl @Inject constructor( suspend fun updateDownloadStatus(fusedDownload: FusedDownload, status: Status) { if (status == Status.INSTALLED) { fusedDownload.status = status databaseRepository.updateDownload(fusedDownload) // databaseRepository.updateDownload(fusedDownload) DownloadManagerBR.downloadedList.clear() delay(100) flushOldDownload(fusedDownload.packageName) databaseRepository.deleteDownload(fusedDownload) } else if (status == Status.INSTALLING) { fusedDownload.downloadIdMap.all { true } fusedDownload.status = status databaseRepository.updateDownload(fusedDownload) delay(100) installApp(fusedDownload) delay(100) } } Loading Loading @@ -141,7 +138,6 @@ class FusedManagerImpl @Inject constructor( Timber.d("Unsupported application type!") fusedDownload.status = Status.INSTALLATION_ISSUE databaseRepository.updateDownload(fusedDownload) delay(100) } } } Loading @@ -157,7 +153,6 @@ class FusedManagerImpl @Inject constructor( // Reset the status before deleting download updateDownloadStatus(fusedDownload, fusedDownload.orgStatus) delay(100) databaseRepository.deleteDownload(fusedDownload) flushOldDownload(fusedDownload.packageName) Loading Loading @@ -199,7 +194,6 @@ class FusedManagerImpl @Inject constructor( fusedDownload.status = Status.DOWNLOADING databaseRepository.updateDownload(fusedDownload) DownloadProgressLD.setDownloadId(-1) delay(100) fusedDownload.downloadURLList.forEach { count += 1 val packagePath: File = if (fusedDownload.files.isNotEmpty()) { Loading