This file contains hidden or 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 ApiService { | |
@GET("photos") | |
suspend fun getPhotos(@Query("sol") sol: Int, @Query("api_key") apiKey: String, @Query("page") page: Int): Response<PhotosResponse>? | |
} | |
object RetrofitService { | |
var client: OkHttpClient = OkHttpClient.Builder().build() |
This file contains hidden or 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
@Parcelize | |
data class Photo(@SerializedName("camera") val camera: Camera, | |
@SerializedName("earth_date") val earthDate: String, | |
@SerializedName("id") val id: String, | |
@SerializedName("img_src") val imgSrc: String, | |
@SerializedName("rover") val rover: Rover, | |
@SerializedName("sol") val sol: String) : Parcelable |
This file contains hidden or 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
sealed class Result<out T : Any> { | |
data class Success<out T : Any>(val data: T) : Result<T>() | |
data class Error(val exception: Exception) : Result<Nothing>() | |
object InProgress : Result<Nothing>() | |
val extractData: T? | |
get() = when (this) { | |
is Success -> data | |
is Error -> null | |
is InProgress -> null |
This file contains hidden or 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
def glide_version = "4.9.0" | |
implementation "com.github.bumptech.glide:glide:$glide_version" | |
implementation "com.github.bumptech.glide:okhttp3-integration:$glide_version" | |
kapt "com.github.bumptech.glide:compiler:$glide_version" | |
def retrofit_version = "2.6.0" | |
implementation "com.squareup.retrofit2:retrofit:$retrofit_version" | |
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version" | |
def coroutines_version = "1.3.0" |
This file contains hidden or 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
class PhotosViewHolder(rowBinding: RowPhotoHomeBinding) : | |
RecyclerView.ViewHolder(rowBinding.root) { | |
private val binding = rowBinding | |
fun bind(str: String) { | |
binding.camera = str | |
val bundle = bundleOf("PHOTO_NAME" to str) | |
binding.root.setOnClickListener { view -> | |
Navigation.findNavController(view).navigate(R.id.action_home_to_details, bundle) | |
} |
This file contains hidden or 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"?> | |
<layout> | |
<data> | |
</data> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" |