Initial web-helper migration

This commit is contained in:
Rahul Patel
2024-06-21 22:44:05 +05:30
committed by Aayush Gupta
parent 21dacd8167
commit ad64bb1055
12 changed files with 36 additions and 32 deletions

View File

@@ -121,12 +121,7 @@ object OkHttpClient : IProxyHttpClient {
@Throws(IOException::class)
override fun post(url: String, headers: Map<String, String>, body: ByteArray): PlayResponse {
val requestBody = body.toRequestBody(
"application/x-protobuf".toMediaType(),
0,
body.size
)
return post(url, headers, requestBody)
return post(url, headers, body.toRequestBody())
}
@Throws(IOException::class)

View File

@@ -25,6 +25,7 @@ import androidx.fragment.app.viewModels
import com.aurora.Constants
import com.aurora.gplayapi.data.models.editor.EditorChoiceCluster
import com.aurora.gplayapi.helpers.StreamHelper
import com.aurora.gplayapi.helpers.contracts.StreamContract
import com.aurora.store.R
import com.aurora.store.databinding.FragmentForYouBinding
import com.aurora.store.view.epoxy.controller.EditorChoiceController
@@ -65,8 +66,8 @@ class EditorChoiceFragment : BaseFragment(R.layout.fragment_for_you),
binding.recycler.setController(editorChoiceController)
when (pageType) {
0 -> viewModel.getEditorChoiceStream(StreamHelper.Category.APPLICATION)
1 -> viewModel.getEditorChoiceStream(StreamHelper.Category.GAME)
0 -> viewModel.getEditorChoiceStream(StreamContract.Category.APPLICATION)
1 -> viewModel.getEditorChoiceStream(StreamContract.Category.GAME)
}
viewModel.liveData.observe(viewLifecycleOwner) {

View File

@@ -26,8 +26,8 @@ import com.aurora.Constants
import com.aurora.gplayapi.data.models.App
import com.aurora.gplayapi.data.models.StreamBundle
import com.aurora.gplayapi.data.models.StreamCluster
import com.aurora.gplayapi.helpers.StreamHelper.Category
import com.aurora.gplayapi.helpers.StreamHelper.Type
import com.aurora.gplayapi.helpers.contracts.StreamContract.Category
import com.aurora.gplayapi.helpers.contracts.StreamContract.Type
import com.aurora.store.R
import com.aurora.store.data.model.ViewState
import com.aurora.store.databinding.FragmentForYouBinding

View File

@@ -24,8 +24,8 @@ import android.view.View
import androidx.fragment.app.viewModels
import com.aurora.Constants
import com.aurora.gplayapi.data.models.StreamCluster
import com.aurora.gplayapi.helpers.TopChartsHelper.Chart
import com.aurora.gplayapi.helpers.TopChartsHelper.Type
import com.aurora.gplayapi.helpers.contracts.TopChartsContract.Chart
import com.aurora.gplayapi.helpers.contracts.TopChartsContract.Type
import com.aurora.store.R
import com.aurora.store.databinding.FragmentTopContainerBinding
import com.aurora.store.view.custom.recycler.EndlessRecyclerOnScrollListener

View File

@@ -29,6 +29,7 @@ import com.aurora.gplayapi.data.models.StreamCluster
import com.aurora.gplayapi.helpers.AppDetailsHelper
import com.aurora.gplayapi.helpers.StreamHelper
import com.aurora.store.data.model.ViewState
import com.aurora.gplayapi.helpers.contracts.StreamContract
import com.aurora.store.data.network.HttpClient
import com.aurora.store.data.providers.AuthProvider
import com.aurora.store.util.Log
@@ -53,8 +54,8 @@ class DetailsClusterViewModel @Inject constructor(
val liveData: MutableLiveData<ViewState> = MutableLiveData()
var streamBundle: StreamBundle = StreamBundle()
lateinit var type: StreamHelper.Type
lateinit var category: StreamHelper.Category
lateinit var type: StreamContract.Type
lateinit var category: StreamContract.Category
fun getStreamBundle(streamUrl: String) {
viewModelScope.launch(Dispatchers.IO) {

View File

@@ -30,6 +30,7 @@ import com.aurora.gplayapi.data.models.details.DevStream
import com.aurora.gplayapi.helpers.AppDetailsHelper
import com.aurora.gplayapi.helpers.StreamHelper
import com.aurora.store.data.model.ViewState
import com.aurora.gplayapi.helpers.contracts.StreamContract
import com.aurora.store.data.network.HttpClient
import com.aurora.store.data.providers.AuthProvider
import com.aurora.store.util.Log
@@ -55,8 +56,8 @@ class DevProfileViewModel @Inject constructor(
var devStream:DevStream = DevStream()
var streamBundle: StreamBundle = StreamBundle()
lateinit var type: StreamHelper.Type
lateinit var category: StreamHelper.Category
lateinit var type: StreamContract.Type
lateinit var category: StreamContract.Category
fun getStreamBundle(devId: String) {
viewModelScope.launch(Dispatchers.IO) {

View File

@@ -27,6 +27,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.aurora.gplayapi.data.models.editor.EditorChoiceBundle
import com.aurora.gplayapi.helpers.StreamHelper
import com.aurora.gplayapi.helpers.contracts.StreamContract
import com.aurora.store.data.network.HttpClient
import com.aurora.store.data.providers.AuthProvider
import dagger.hilt.android.lifecycle.HiltViewModel
@@ -50,7 +51,7 @@ class EditorChoiceViewModel @Inject constructor(
val liveData: MutableLiveData<List<EditorChoiceBundle>> = MutableLiveData()
fun getEditorChoiceStream(category: StreamHelper.Category) {
fun getEditorChoiceStream(category: StreamContract.Category) {
viewModelScope.launch(Dispatchers.IO) {
supervisorScope {
try {

View File

@@ -28,15 +28,16 @@ import com.aurora.gplayapi.data.models.StreamBundle
import com.aurora.gplayapi.data.models.StreamCluster
import com.aurora.gplayapi.helpers.StreamHelper
import com.aurora.store.data.model.ViewState
import com.aurora.gplayapi.helpers.contracts.StreamContract
import com.aurora.store.data.network.HttpClient
import com.aurora.store.data.providers.AuthProvider
import com.aurora.store.util.Log
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.supervisorScope
import javax.inject.Inject
@HiltViewModel
@SuppressLint("StaticFieldLeak") // false positive, see https://github.com/google/dagger/issues/3253
@@ -51,10 +52,10 @@ class BaseClusterViewModel @Inject constructor(
val liveData: MutableLiveData<ViewState> = MutableLiveData()
var streamBundle: StreamBundle = StreamBundle()
lateinit var type: StreamHelper.Type
lateinit var category: StreamHelper.Category
lateinit var type: StreamContract.Type
lateinit var category: StreamContract.Category
fun getStreamBundle(category: StreamHelper.Category, type: StreamHelper.Type) {
fun getStreamBundle(category: StreamContract.Category, type: StreamContract.Type) {
this.type = type
this.category = category
liveData.postValue(ViewState.Loading)

View File

@@ -28,7 +28,8 @@ import androidx.lifecycle.viewModelScope
import com.aurora.extensions.flushAndAdd
import com.aurora.gplayapi.data.models.SearchBundle
import com.aurora.gplayapi.helpers.SearchHelper
import com.aurora.gplayapi.helpers.WebSearchHelper
import com.aurora.gplayapi.helpers.contracts.SearchContract
import com.aurora.gplayapi.helpers.web.WebSearchHelper
import com.aurora.store.data.network.HttpClient
import com.aurora.store.data.providers.AuthProvider
import com.aurora.store.data.providers.FilterProvider
@@ -49,7 +50,7 @@ class SearchResultViewModel @Inject constructor(
private val TAG = SearchResultViewModel::class.java.simpleName
private val webSearchHelper: WebSearchHelper = WebSearchHelper(authProvider.authData)
private val webSearchHelper: WebSearchHelper = WebSearchHelper()
private val searchHelper: SearchHelper = SearchHelper(authProvider.authData)
.using(HttpClient.getPreferredClient(context))
@@ -57,7 +58,7 @@ class SearchResultViewModel @Inject constructor(
private var searchBundle: SearchBundle = SearchBundle()
fun helper(): SearchHelper {
fun helper(): SearchContract {
return if (authProvider.isAnonymous) {
webSearchHelper
} else {

View File

@@ -26,14 +26,15 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.aurora.gplayapi.SearchSuggestEntry
import com.aurora.gplayapi.helpers.SearchHelper
import com.aurora.gplayapi.helpers.WebSearchHelper
import com.aurora.gplayapi.helpers.contracts.SearchContract
import com.aurora.gplayapi.helpers.web.WebSearchHelper
import com.aurora.store.data.network.HttpClient
import com.aurora.store.data.providers.AuthProvider
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject
@HiltViewModel
@SuppressLint("StaticFieldLeak") // false positive, see https://github.com/google/dagger/issues/3253
@@ -42,13 +43,13 @@ class SearchSuggestionViewModel @Inject constructor(
private val authProvider: AuthProvider
) : ViewModel() {
private val webSearchHelper: WebSearchHelper = WebSearchHelper(authProvider.authData)
private val webSearchHelper: WebSearchHelper = WebSearchHelper()
private val searchHelper: SearchHelper = SearchHelper(authProvider.authData)
.using(HttpClient.getPreferredClient(context))
val liveSearchSuggestions: MutableLiveData<List<SearchSuggestEntry>> = MutableLiveData()
fun helper(): SearchHelper {
fun helper(): SearchContract {
return if (authProvider.isAnonymous) {
webSearchHelper
} else {

View File

@@ -26,14 +26,15 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.aurora.gplayapi.data.models.StreamCluster
import com.aurora.gplayapi.helpers.TopChartsHelper
import com.aurora.gplayapi.helpers.contracts.TopChartsContract
import com.aurora.store.data.network.HttpClient
import com.aurora.store.data.providers.AuthProvider
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.supervisorScope
import javax.inject.Inject
@HiltViewModel
@SuppressLint("StaticFieldLeak") // false positive, see https://github.com/google/dagger/issues/3253
@@ -48,10 +49,10 @@ class TopChartViewModel @Inject constructor(
val liveData: MutableLiveData<StreamCluster> = MutableLiveData()
var streamCluster: StreamCluster = StreamCluster()
fun getStreamCluster(type: TopChartsHelper.Type, chart: TopChartsHelper.Chart) {
fun getStreamCluster(type: TopChartsContract.Type, chart: TopChartsContract.Chart) {
viewModelScope.launch(Dispatchers.IO) {
try {
streamCluster = topChartsHelper.getCluster(type, chart)
streamCluster = topChartsHelper.getCluster(type.value, chart.value)
liveData.postValue(streamCluster)
} catch (_: Exception) {
}