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

Commit 113e120b authored by Hasib Prince's avatar Hasib Prince
Browse files

fix: network call on wrong thread

parent adef41dd
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -382,7 +382,7 @@ class MainActivity : AppCompatActivity() {
        Timber.d("Sending broadcast with login type - $user")
        val intent = Intent(Constants.ACTION_PARENTAL_CONTROL_APP_LOUNGE_LOGIN).apply {
            setPackage(BuildConfig.PACKAGE_NAME_PARENTAL_CONTROL)
            putExtra(COLUMN_LOGIN_TYPE, user)
            putExtra(COLUMN_LOGIN_TYPE, user.name)
        }
        sendBroadcast(intent)
    }
+3 −5
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import foundation.e.apps.data.ageRating.AgeGroupApi
import foundation.e.apps.data.ageRating.FDroidMonitorApi
import foundation.e.apps.data.handleNetworkResult
import foundation.e.apps.data.login.AuthenticatorRepository
import foundation.e.apps.data.playstore.PlayStoreRepository
import javax.inject.Inject
import javax.inject.Singleton

@@ -32,7 +33,7 @@ import javax.inject.Singleton
class ContentRatingsRepository @Inject constructor(
    private val ageGroupApi: AgeGroupApi,
    private val fDroidMonitorApi: FDroidMonitorApi,
    private val authenticatorRepository: AuthenticatorRepository,
    private val playStoreRepository: PlayStoreRepository,
) {

    private var _contentRatingGroups = listOf<ContentRatingGroup>()
@@ -54,11 +55,8 @@ class ContentRatingsRepository @Inject constructor(
    }

    suspend fun getEnglishContentRating(packageName: String): ContentRating? {
        val authData = authenticatorRepository.gplayAuth ?: return null
        val contentRatingHelper = ContentRatingHelper(authData)

        return handleNetworkResult {
            contentRatingHelper.getEnglishContentRating(packageName)
            playStoreRepository.getEnglishContentRating(packageName)
        }.data
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -49,4 +49,5 @@ interface PlayStoreRepository : StoreRepository {
        appPackage: String,
        contentRating: ContentRating
    ): ContentRating
    suspend fun getEnglishContentRating(packageName: String): ContentRating?
}
+10 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.aurora.gplayapi.helpers.TopChartsHelper
import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.R
import foundation.e.apps.data.application.utils.CategoryType
import foundation.e.apps.data.handleNetworkResult
import foundation.e.apps.data.login.AuthenticatorRepository
import foundation.e.apps.data.playstore.utils.GPlayHttpClient
import kotlinx.coroutines.Dispatchers
@@ -228,4 +229,13 @@ class PlayStoreRepositoryImpl @Inject constructor(
            )
        }
    }

    override suspend fun getEnglishContentRating(packageName: String): ContentRating? {
        val authData = authenticatorRepository.gplayAuth ?: return null
        val contentRatingHelper = ContentRatingHelper(authData)

        return withContext(Dispatchers.IO) {
            contentRatingHelper.getEnglishContentRating(packageName)
        }
    }
}