This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
class ImageRepositoryImpl @Inject constructor( | |
private val imageApi: ImageApi | |
) : ImageRepository { | |
override fun getImages(text: String): Flow<Resources<List<Image>>> { | |
return flow { | |
emit(Resources.Loading(true)) | |
val remoteList = try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ImageRepository { | |
fun getImages( | |
text: String | |
): Flow<Resources<List<Image>>> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun ImageDto.toImage(): Image { | |
return Image( | |
id = id, | |
width = width, | |
height = height, | |
srcSmall = srcSmall, | |
src = src | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Image( | |
var id: String, | |
var src: String, | |
var srcSmall: String, | |
var width: Int, | |
var height: Int, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.md.jetpackcomposemviarchitecture.data.remote.ImageApi | |
import dagger.Module | |
import dagger.Provides | |
import dagger.hilt.InstallIn | |
import dagger.hilt.components.SingletonComponent | |
import okhttp3.OkHttpClient | |
import okhttp3.logging.HttpLoggingInterceptor | |
import retrofit2.Retrofit | |
import retrofit2.converter.gson.GsonConverterFactory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.md.jetpackcomposemviarchitecture.data.remote.dto.ImageListDto | |
import retrofit2.http.GET | |
import retrofit2.http.Query | |
interface ImageApi { | |
@GET("search") | |
suspend fun getInfiniteApiImages( | |
@Query("q") q : String | |
): ImageListDto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<application | |
android:name=".App" | |
android:allowBackup="true" | |
android:dataExtractionRules="@xml/data_extraction_rules" | |
android:fullBackupContent="@xml/backup_rules" | |
android:icon="@mipmap/ic_launcher" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Application | |
import dagger.hilt.android.HiltAndroidApp | |
@HiltAndroidApp | |
class App : Application() { | |
override fun onCreate() { | |
super.onCreate() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.Manifest | |
import android.content.Intent | |
import android.net.Uri | |
import android.os.Build | |
import android.provider.Settings | |
import android.widget.Toast | |
import androidx.annotation.RequiresApi | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.Column |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.Manifest | |
import android.content.Intent | |
import android.net.Uri | |
import android.os.Build | |
import android.provider.Settings | |
import android.widget.Toast | |
import androidx.annotation.RequiresApi | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.Column |