-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from naufalprakoso/master
Pokemon Info Evolution & Gradle Kotlin DSL
- Loading branch information
Showing
21 changed files
with
259 additions
and
144 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
plugins { | ||
id("com.android.application") | ||
id("kotlin-android") | ||
id("kotlin-android-extensions") | ||
id("kotlin-kapt") | ||
id("androidx.navigation.safeargs.kotlin") | ||
} | ||
apply(from = "../ktlint.gradle.kts") | ||
|
||
android { | ||
compileSdkVersion(29) | ||
buildToolsVersion("29.0.3") | ||
defaultConfig { | ||
applicationId = "dev.marcosfarias.pokedex" | ||
minSdkVersion(23) | ||
targetSdkVersion(29) | ||
versionCode = 1 | ||
versionName = "1.0" | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
getByName("release") { | ||
isMinifyEnabled = false | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72") | ||
|
||
// Architecture | ||
implementation("androidx.core:core-ktx:1.2.0") | ||
implementation("androidx.appcompat:appcompat:1.1.0") | ||
implementation("androidx.navigation:navigation-ui:2.2.2") | ||
implementation("androidx.navigation:navigation-ui-ktx:2.2.2") | ||
implementation("androidx.navigation:navigation-fragment:2.2.2") | ||
implementation("androidx.navigation:navigation-fragment-ktx:2.2.2") | ||
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0") | ||
implementation("androidx.constraintlayout:constraintlayout:1.1.3") | ||
implementation("androidx.coordinatorlayout:coordinatorlayout:1.1.0") | ||
|
||
// Material | ||
implementation("com.google.android.material:material:1.1.0") | ||
|
||
// Third Party | ||
implementation("com.leinardi.android:speed-dial:3.1.1") | ||
|
||
// Retrofit | ||
implementation("com.squareup.retrofit2:retrofit:2.6.0") | ||
implementation("com.squareup.retrofit2:converter-gson:2.6.0") | ||
|
||
// Persistence | ||
implementation("android.arch.persistence.room:runtime:1.1.1") | ||
kapt("android.arch.persistence.room:compiler:1.1.1") | ||
|
||
// Glide | ||
kapt("android.arch.lifecycle:compiler:1.1.1") | ||
kapt("com.github.bumptech.glide:compiler:4.10.0") | ||
implementation("com.github.bumptech.glide:glide:4.10.0") | ||
|
||
// Koin | ||
implementation("org.koin:koin-android:2.0.1") | ||
implementation("org.koin:koin-androidx-scope:2.0.1") | ||
implementation("org.koin:koin-androidx-viewmodel:2.0.1") | ||
|
||
// Test | ||
testImplementation("junit:junit:4.12") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.1") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0") | ||
} |
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
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
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
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
72 changes: 72 additions & 0 deletions
72
app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/evolution/EvolutionAdapter.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package dev.marcosfarias.pokedex.ui.dashboard.evolution | ||
|
||
import android.content.Context | ||
import android.graphics.PorterDuff | ||
import android.graphics.PorterDuffColorFilter | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.core.view.isVisible | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.bumptech.glide.Glide | ||
import dev.marcosfarias.pokedex.R | ||
import dev.marcosfarias.pokedex.model.Pokemon | ||
import dev.marcosfarias.pokedex.utils.PokemonColorUtil | ||
import kotlinx.android.synthetic.main.item_pokemon.view.* | ||
|
||
class EvolutionAdapter( | ||
private val context: Context | ||
) : RecyclerView.Adapter<EvolutionAdapter.ViewHolder>() { | ||
|
||
private val list = arrayListOf<Pokemon>() | ||
|
||
fun setList(list: List<Pokemon>) { | ||
this.list.clear() | ||
this.list.addAll(list) | ||
} | ||
|
||
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
fun bindView(item: Pokemon) { | ||
itemView.textViewName.text = item.name | ||
itemView.textViewID.text = item.id | ||
|
||
val color = PokemonColorUtil(itemView.context).getPokemonColor(item.typeofpokemon) | ||
itemView.relativeLayoutBackground.background.colorFilter = | ||
PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP) | ||
|
||
item.typeofpokemon?.getOrNull(0).let { firstType -> | ||
itemView.textViewType3.text = firstType | ||
itemView.textViewType3.isVisible = firstType != null | ||
} | ||
|
||
item.typeofpokemon?.getOrNull(1).let { secondType -> | ||
itemView.textViewType2.text = secondType | ||
itemView.textViewType2.isVisible = secondType != null | ||
} | ||
|
||
item.typeofpokemon?.getOrNull(2).let { thirdType -> | ||
itemView.textViewType1.text = thirdType | ||
itemView.textViewType1.isVisible = thirdType != null | ||
} | ||
|
||
Glide.with(itemView.context) | ||
.load(item.imageurl) | ||
.placeholder(android.R.color.transparent) | ||
.into(itemView.imageView) | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
val view = LayoutInflater.from(context).inflate(R.layout.item_pokemon, parent, false) | ||
return ViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
val item = list[position] | ||
holder.bindView(item) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return list.size | ||
} | ||
} |
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
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
Oops, something went wrong.