Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b656005b authored by Hasib Prince's avatar Hasib Prince
Browse files

intoduced iterfaces for downloading stuffs

parent fa8e1e93
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
package foundation.e.apps.api


interface DownloadInfoFetcher {
    suspend fun getDownloadInfo(idOrPackageName: String, versionCode: Any? = null, offerType: Int = -1): Any
}
 No newline at end of file
+12 −0
Original line number Original line Diff line number Diff line
package foundation.e.apps.api

import foundation.e.apps.manager.database.fusedDownload.FusedDownload

interface OnDemandModuleFetcher {
    suspend fun getOnDemandModule(
        packageName: String,
        moduleName: String,
        versionCode: Int,
        offerType: Int
    ): Any
}
 No newline at end of file
+2 −0
Original line number Original line Diff line number Diff line
@@ -26,4 +26,6 @@ interface StoreRepository {
    suspend fun getSearchSuggestions(query: String): Any
    suspend fun getSearchSuggestions(query: String): Any
    suspend fun getAppsByCategory(category: String, paginationParameter: Any? = null): Any
    suspend fun getAppsByCategory(category: String, paginationParameter: Any? = null): Any
    suspend fun getCategories(type: CategoryType? = null): Any
    suspend fun getCategories(type: CategoryType? = null): Any
    suspend fun getAppDetails(packageNameOrId: String): Any?
    suspend fun getAppsDetails(packageNamesOrIds: List<String>): Any
}
}
+27 −1
Original line number Original line Diff line number Diff line
@@ -18,16 +18,21 @@


package foundation.e.apps.api.cleanapk
package foundation.e.apps.api.cleanapk


import foundation.e.apps.api.DownloadInfoFetcher
import foundation.e.apps.api.StoreRepository
import foundation.e.apps.api.StoreRepository
import foundation.e.apps.api.cleanapk.data.app.Application
import foundation.e.apps.api.cleanapk.data.categories.Categories
import foundation.e.apps.api.cleanapk.data.categories.Categories
import foundation.e.apps.api.cleanapk.data.download.Download
import foundation.e.apps.api.cleanapk.data.home.HomeScreen
import foundation.e.apps.api.cleanapk.data.home.HomeScreen
import foundation.e.apps.api.cleanapk.data.search.Search
import foundation.e.apps.api.cleanapk.data.search.Search
import foundation.e.apps.api.fused.utils.CategoryType
import foundation.e.apps.api.fused.utils.CategoryType
import foundation.e.apps.manager.database.fusedDownload.FusedDownload
import retrofit2.Response
import retrofit2.Response


class CleanApkAppsRepository(
class CleanApkAppsRepository(
    private val cleanAPKInterface: CleanAPKInterface,
    private val cleanAPKInterface: CleanAPKInterface,
) : StoreRepository {
    private val cleanApkAppDetailApi: CleanApkAppDetailApi
) : StoreRepository, DownloadInfoFetcher {


    override suspend fun getHomeScreenData(): Response<HomeScreen> {
    override suspend fun getHomeScreenData(): Response<HomeScreen> {
        return cleanAPKInterface.getHomeScreenData(
        return cleanAPKInterface.getHomeScreenData(
@@ -70,4 +75,25 @@ class CleanApkAppsRepository(
            CleanAPKInterface.APP_SOURCE_FOSS
            CleanAPKInterface.APP_SOURCE_FOSS
        )
        )
    }
    }

    override suspend fun getAppDetails(packageNameOrId: String): Response<Application> {
        return cleanApkAppDetailApi.getAppOrPWADetailsByID(packageNameOrId, null, null)
    }

    override suspend fun getAppsDetails(packageNamesOrIds: List<String>): Any {
        val applications = mutableListOf<Application>()

        packageNamesOrIds.forEach {
            val applicationResponse = getAppDetails(it)
            if (applicationResponse.isSuccessful && applicationResponse.body() != null) {
                applications.add(applicationResponse.body()!!)
            }
        }
        return applications
    }

    override suspend fun getDownloadInfo(idOrPackageName: String, versionCode: Any?, offerType: Int): Response<Download> {
        val version = versionCode?.let { it as String }
        return cleanAPKInterface.getDownloadInfo(idOrPackageName, version, null)
    }
}
}
+21 −1
Original line number Original line Diff line number Diff line
@@ -19,12 +19,16 @@
package foundation.e.apps.api.cleanapk
package foundation.e.apps.api.cleanapk


import foundation.e.apps.api.StoreRepository
import foundation.e.apps.api.StoreRepository
import foundation.e.apps.api.cleanapk.data.app.Application
import foundation.e.apps.api.cleanapk.data.categories.Categories
import foundation.e.apps.api.cleanapk.data.categories.Categories
import foundation.e.apps.api.cleanapk.data.search.Search
import foundation.e.apps.api.cleanapk.data.search.Search
import foundation.e.apps.api.fused.utils.CategoryType
import foundation.e.apps.api.fused.utils.CategoryType
import retrofit2.Response
import retrofit2.Response


class CleanApkPWARepository(private val cleanAPKInterface: CleanAPKInterface) : StoreRepository {
class CleanApkPWARepository(
    private val cleanAPKInterface: CleanAPKInterface,
    private val cleanApkAppDetailApi: CleanApkAppDetailApi
) : StoreRepository {


    override suspend fun getHomeScreenData(): Any {
    override suspend fun getHomeScreenData(): Any {
        return cleanAPKInterface.getHomeScreenData(
        return cleanAPKInterface.getHomeScreenData(
@@ -64,4 +68,20 @@ class CleanApkPWARepository(private val cleanAPKInterface: CleanAPKInterface) :
            CleanAPKInterface.APP_SOURCE_ANY
            CleanAPKInterface.APP_SOURCE_ANY
        )
        )
    }
    }

    override suspend fun getAppDetails(packageNameOrId: String): Response<Application> {
        return cleanApkAppDetailApi.getAppOrPWADetailsByID(packageNameOrId, null, null)
    }

    override suspend fun getAppsDetails(packageNamesOrIds: List<String>): Any {
        val applications = mutableListOf<Application>()

        packageNamesOrIds.forEach {
            val applicationResponse = getAppDetails(it)
            if (applicationResponse.isSuccessful && applicationResponse.body() != null) {
                applications.add(applicationResponse.body()!!)
            }
        }
        return applications
    }
}
}
Loading