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

Commit a472a8f6 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Use Gson converter consistently for cleanapk

parent ced100e0
Loading
Loading
Loading
Loading
+0 −36
Original line number Diff line number Diff line
/*
 *
 *  * Copyright ECORP SAS 2022
 *  * Apps  Quickly and easily install Android apps onto your device!
 *  *
 *  * This program is free software: you can redistribute it and/or modify
 *  * it under the terms of the GNU General Public License as published by
 *  * the Free Software Foundation, either version 3 of the License, or
 *  * (at your option) any later version.
 *  *
 *  * This program is distributed in the hope that it will be useful,
 *  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  * GNU General Public License for more details.
 *  *
 *  * You should have received a copy of the GNU General Public License
 *  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */

package foundation.e.apps.data.cleanapk

import foundation.e.apps.data.cleanapk.data.app.Application
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Query

interface CleanApkAppDetailsRetrofit {

    @GET("apps?action=app_detail")
    suspend fun getAppOrPWADetailsByID(
        @Query("id") id: String,
        @Query("architectures") architectures: List<String>? = null,
        @Query("type") type: String? = null
    ): Response<Application>
}
+2 −4
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@

package foundation.e.apps.data.cleanapk.repositories

import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit
import foundation.e.apps.data.cleanapk.CleanApkDownloadInfoFetcher
import foundation.e.apps.data.cleanapk.CleanApkRetrofit
import foundation.e.apps.data.cleanapk.data.app.Application
@@ -29,8 +28,7 @@ import foundation.e.apps.data.cleanapk.data.search.Search
import retrofit2.Response

class CleanApkAppsRepository(
    private val cleanApkRetrofit: CleanApkRetrofit,
    private val cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit
    private val cleanApkRetrofit: CleanApkRetrofit
) : CleanApkRepository, CleanApkDownloadInfoFetcher {

    override suspend fun getHomeScreenData(): Response<HomeScreen> {
@@ -76,7 +74,7 @@ class CleanApkAppsRepository(
    }

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

    override suspend fun getDownloadInfo(idOrPackageName: String, versionCode: Any?): Response<Download> {
+2 −4
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@

package foundation.e.apps.data.cleanapk.repositories

import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit
import foundation.e.apps.data.cleanapk.CleanApkRetrofit
import foundation.e.apps.data.cleanapk.data.app.Application
import foundation.e.apps.data.cleanapk.data.categories.Categories
@@ -26,8 +25,7 @@ import foundation.e.apps.data.cleanapk.data.search.Search
import retrofit2.Response

class CleanApkPWARepository(
    private val cleanAPKRetrofit: CleanApkRetrofit,
    private val cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit
    private val cleanAPKRetrofit: CleanApkRetrofit
) : CleanApkRepository {

    override suspend fun getHomeScreenData(): Any {
@@ -70,6 +68,6 @@ class CleanApkPWARepository(
    }

    override suspend fun getAppDetails(packageNameOrId: String): Response<Application> {
        return cleanApkAppDetailsRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null)
        return cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null)
    }
}
+4 −7
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit
import foundation.e.apps.data.cleanapk.CleanApkRetrofit
import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository
import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository
@@ -54,19 +53,17 @@ object NamedRepositoryModule {
    @Provides
    @Named("cleanApkAppsRepository")
    fun getCleanApkAppsRepository(
        cleanAPKRetrofit: CleanApkRetrofit,
        cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit
        cleanAPKRetrofit: CleanApkRetrofit
    ): CleanApkRepository {
        return CleanApkAppsRepository(cleanAPKRetrofit, cleanApkAppDetailsRetrofit)
        return CleanApkAppsRepository(cleanAPKRetrofit)
    }

    @Singleton
    @Provides
    @Named("cleanApkPWARepository")
    fun getCleanApkPWARepository(
        cleanAPKRetrofit: CleanApkRetrofit,
        cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit
        cleanAPKRetrofit: CleanApkRetrofit
    ): CleanApkRepository {
        return CleanApkPWARepository(cleanAPKRetrofit, cleanApkAppDetailsRetrofit)
        return CleanApkPWARepository(cleanAPKRetrofit)
    }
}
+4 −15
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit
import foundation.e.apps.data.cleanapk.CleanApkRetrofit
import foundation.e.apps.data.ecloud.EcloudApiInterface
import foundation.e.apps.data.exodus.ExodusTrackerApi
@@ -47,27 +46,17 @@ import javax.inject.Singleton
class RetrofitApiModule {
    @Singleton
    @Provides
    fun provideCleanApkApi(okHttpClient: OkHttpClient, moshi: Moshi): CleanApkRetrofit {
        return Retrofit.Builder()
            .baseUrl(CleanApkRetrofit.BASE_URL)
            .client(okHttpClient)
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .build()
            .create(CleanApkRetrofit::class.java)
    }

    @Singleton
    @Provides
    fun provideCleanApkAppDetailsApi(
    fun provideCleanApkApi(
        okHttpClient: OkHttpClient,
        @Named("gsonCustomAdapter") gson: Gson
    ): CleanApkAppDetailsRetrofit {
    ): CleanApkRetrofit
    {
        return Retrofit.Builder()
            .baseUrl(CleanApkRetrofit.BASE_URL)
            .client(okHttpClient)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build()
            .create(CleanApkAppDetailsRetrofit::class.java)
            .create(CleanApkRetrofit::class.java)
    }

    @Singleton