From 1e89a449f88f7012ee5cf26e84cd0b678d9f70c3 Mon Sep 17 00:00:00 2001 From: Boy Wonder Date: Thu, 16 Sep 2021 14:18:55 +0500 Subject: [PATCH] Removed unused API methods. Code clean up. --- app/build.gradle | 6 +++--- .../playstoredemo/adapter/ParentRecyclerViewAdapter.kt | 1 - .../uz/boywonder/playstoredemo/data/RemoteDataSource.kt | 5 ----- .../uz/boywonder/playstoredemo/data/network/ImageAPI.kt | 7 ------- .../playstoredemo/ui/dialogs/LanguageBottomSheet.kt | 1 - .../uz/boywonder/playstoredemo/util/NetworkListener.kt | 2 -- 6 files changed, 3 insertions(+), 19 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ed02c78..f2fdf9e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -80,9 +80,9 @@ dependencies { implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2-native-mt' // Lifecycle - implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0-alpha03" - implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0-alpha03" + implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-beta01" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0-beta01" + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0-beta01" // Image Loading library Coil implementation 'io.coil-kt:coil:1.3.2' diff --git a/app/src/main/java/uz/boywonder/playstoredemo/adapter/ParentRecyclerViewAdapter.kt b/app/src/main/java/uz/boywonder/playstoredemo/adapter/ParentRecyclerViewAdapter.kt index 18b0fcb..bd87ec2 100644 --- a/app/src/main/java/uz/boywonder/playstoredemo/adapter/ParentRecyclerViewAdapter.kt +++ b/app/src/main/java/uz/boywonder/playstoredemo/adapter/ParentRecyclerViewAdapter.kt @@ -7,7 +7,6 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import uz.boywonder.playstoredemo.databinding.ParentRecyclerviewItemsBinding import uz.boywonder.playstoredemo.model.CategoryItem -import uz.boywonder.playstoredemo.model.ImageItem import uz.boywonder.playstoredemo.util.MyDiffUtil class ParentRecyclerViewAdapter : diff --git a/app/src/main/java/uz/boywonder/playstoredemo/data/RemoteDataSource.kt b/app/src/main/java/uz/boywonder/playstoredemo/data/RemoteDataSource.kt index 3057c8b..553a451 100644 --- a/app/src/main/java/uz/boywonder/playstoredemo/data/RemoteDataSource.kt +++ b/app/src/main/java/uz/boywonder/playstoredemo/data/RemoteDataSource.kt @@ -2,7 +2,6 @@ package uz.boywonder.playstoredemo.data import retrofit2.Response import uz.boywonder.playstoredemo.data.network.ImageAPI -import uz.boywonder.playstoredemo.model.CategoryItem import uz.boywonder.playstoredemo.model.ImageItem import javax.inject.Inject @@ -10,10 +9,6 @@ class RemoteDataSource @Inject constructor( private val imageAPI: ImageAPI ) { - suspend fun getRandomImage(width: Int, height: Int) : Response { - return imageAPI.getRandomImage(width, height) - } - suspend fun getImageList(): Response> { return imageAPI.getImageList() } diff --git a/app/src/main/java/uz/boywonder/playstoredemo/data/network/ImageAPI.kt b/app/src/main/java/uz/boywonder/playstoredemo/data/network/ImageAPI.kt index 2d27cba..56cc6c7 100644 --- a/app/src/main/java/uz/boywonder/playstoredemo/data/network/ImageAPI.kt +++ b/app/src/main/java/uz/boywonder/playstoredemo/data/network/ImageAPI.kt @@ -4,19 +4,12 @@ import retrofit2.Response import retrofit2.http.GET import retrofit2.http.Path import retrofit2.http.Query -import uz.boywonder.playstoredemo.model.CategoryItem import uz.boywonder.playstoredemo.model.ImageItem import uz.boywonder.playstoredemo.util.Constants.Companion.QUERY_PAGE_NUMBER import uz.boywonder.playstoredemo.util.Constants.Companion.QUERY_PAGE_SIZE interface ImageAPI { - @GET("{width}/{height}") - suspend fun getRandomImage( - @Path("width") width: Int, - @Path("height") height: Int - ): Response - @GET("v2/list") suspend fun getImageList( @Query("page") page: Int = QUERY_PAGE_NUMBER, diff --git a/app/src/main/java/uz/boywonder/playstoredemo/ui/dialogs/LanguageBottomSheet.kt b/app/src/main/java/uz/boywonder/playstoredemo/ui/dialogs/LanguageBottomSheet.kt index 7aeb117..527f425 100644 --- a/app/src/main/java/uz/boywonder/playstoredemo/ui/dialogs/LanguageBottomSheet.kt +++ b/app/src/main/java/uz/boywonder/playstoredemo/ui/dialogs/LanguageBottomSheet.kt @@ -8,7 +8,6 @@ import android.widget.Toast import androidx.lifecycle.ViewModelProvider import androidx.navigation.fragment.findNavController import com.google.android.material.bottomsheet.BottomSheetDialogFragment -import com.google.android.material.snackbar.Snackbar import uz.boywonder.playstoredemo.R import uz.boywonder.playstoredemo.databinding.FragmentBottomSheetLanguageBinding import uz.boywonder.playstoredemo.ui.settings.SettingsViewModel diff --git a/app/src/main/java/uz/boywonder/playstoredemo/util/NetworkListener.kt b/app/src/main/java/uz/boywonder/playstoredemo/util/NetworkListener.kt index ee988cc..e7169af 100644 --- a/app/src/main/java/uz/boywonder/playstoredemo/util/NetworkListener.kt +++ b/app/src/main/java/uz/boywonder/playstoredemo/util/NetworkListener.kt @@ -10,10 +10,8 @@ import kotlinx.coroutines.flow.MutableStateFlow class NetworkListener : ConnectivityManager.NetworkCallback() { - // State of Network exposed to Recipes Fragment private val isNetworkAvailable = MutableStateFlow(false) - // Network Check Function @RequiresApi(Build.VERSION_CODES.N) fun checkNetworkAvailability(context: Context): MutableStateFlow {