Skip to content

Commit

Permalink
complete clean architecture and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nandrasaputra committed Oct 12, 2020
1 parent 7d4a5ed commit f2aa457
Show file tree
Hide file tree
Showing 97 changed files with 1,694 additions and 1,440 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/.idea/assetWizardSettings.xml
.DS_Store
/build
/app/google-services.json
/captures
.externalNativeBuild
.cxx
71 changes: 36 additions & 35 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 29
compileSdkVersion 30
buildToolsVersion "29.0.3"

defaultConfig {
applicationId "com.nandra.covid19id"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"

Expand All @@ -37,45 +37,46 @@ android {
}

dependencies {
def nav_version = "2.2.1"
def lifecycle_version = "2.2.0"
def glide_version = "4.9.0"
def gsonVersion = "2.8.5"
def retrofitVersion = "2.6.1"

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

//Constraint Layout
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
//Material Component
implementation 'com.google.android.material:material:1.1.0'
//Rounded ImageView
// Constraint Layout
implementation "androidx.constraintlayout:constraintlayout:$constraint_layout_version"
// Material Component
implementation "com.google.android.material:material:$material_version"
// Rounded ImageView
implementation "com.makeramen:roundedimageview:2.3.0"
//Navigation Jetpack
// Navigation Jetpack
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
//Lifecycle Component
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
//Glide
// Glide
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
//Firebase
implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation 'com.google.firebase:firebase-database-ktx:19.2.1'
implementation 'com.google.firebase:firebase-storage-ktx:19.1.1'
implementation 'com.firebaseui:firebase-ui-storage:6.2.0'
//Facebook Shimmer
// Facebook Shimmer
implementation 'com.facebook.shimmer:shimmer:0.5.0'
//Retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
//Gson
implementation "com.google.code.gson:gson:$gsonVersion"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// Retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
// RxJava
implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"
// Firebase
implementation "com.google.firebase:firebase-analytics:$firebase_analytic_version"
implementation "com.google.firebase:firebase-database-ktx:$firebase_database_version"
implementation "com.google.firebase:firebase-storage-ktx:$firebase_storage_version"
implementation 'com.firebaseui:firebase-ui-storage:6.2.0'
// Lifecycle Component
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"
// Dagger
implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".CovidApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_covid_launcher_logo"
android:label="@string/app_name"
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/nandra/covid19id/CovidApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.nandra.covid19id

import android.app.Application
import com.nandra.covid19id.core.di.CoreComponent
import com.nandra.covid19id.core.di.DaggerCoreComponent
import com.nandra.covid19id.di.AppComponent

class CovidApplication: Application() {

private val coreComponent: CoreComponent by lazy {
DaggerCoreComponent.factory().create(applicationContext)
}

val appComponent: AppComponent by lazy {
coreComponent.getAppComponentFactory().create()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.google.firebase.storage.FirebaseStorage
import com.nandra.covid19id.R
import com.nandra.covid19id.model.Content
import com.nandra.covid19id.core.domain.model.InformationContent
import com.nandra.covid19id.ui.WebViewActivity
import com.nandra.covid19id.utils.Constant
import kotlinx.android.synthetic.main.fragment_information_item.view.*

class ContentListAdapter : ListAdapter<Content, ContentListAdapter.ContentViewHolder>(contentDiffUtil) {
class ContentListAdapter : ListAdapter<InformationContent, ContentListAdapter.ContentViewHolder>(contentDiffUtil) {

private val firebaseStorage = FirebaseStorage.getInstance()

Expand All @@ -29,35 +29,35 @@ class ContentListAdapter : ListAdapter<Content, ContentListAdapter.ContentViewHo
}

inner class ContentViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bind(content: Content) {
fun bind(informationContent: InformationContent) {

itemView.apply {
fragment_information_item_title.text = content.title
fragment_information_item_description.text = content.description
fragment_information_item_title.text = informationContent.title
fragment_information_item_description.text = informationContent.description
}

Glide.with(itemView.context)
.load(firebaseStorage.getReferenceFromUrl(content.image_path))
.load(firebaseStorage.getReferenceFromUrl(informationContent.image_path))
.placeholder(R.color.shimmerColorTwo)
.into(itemView.fragment_information_item_image)

itemView.setOnClickListener {
val intent = Intent(itemView.context, WebViewActivity::class.java).apply {
putExtra(Constant.EXTRA_WEB_SITE, content.website_path)
putExtra(Constant.EXTRA_WEB_TITLE, content.title)
putExtra(Constant.EXTRA_WEB_SITE, informationContent.website_path)
putExtra(Constant.EXTRA_WEB_TITLE, informationContent.title)
}
itemView.context.startActivity(intent)
}
}
}

companion object {
val contentDiffUtil = object : DiffUtil.ItemCallback<Content>() {
override fun areItemsTheSame(oldItem: Content, newItem: Content): Boolean {
val contentDiffUtil = object : DiffUtil.ItemCallback<InformationContent>() {
override fun areItemsTheSame(oldItem: InformationContent, newItem: InformationContent): Boolean {
return oldItem == newItem
}

override fun areContentsTheSame(oldItem: Content, newItem: Content): Boolean {
override fun areContentsTheSame(oldItem: InformationContent, newItem: InformationContent): Boolean {
return oldItem.id == newItem.id
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.nandra.covid19id.R
import com.nandra.covid19id.adapter.IndonesiaProvinceDetailListAdapter.IndonesiaProvinceDetailViewHolder
import com.nandra.covid19id.network.response.model.Attributes
import com.nandra.covid19id.core.domain.model.IndonesiaProvinceCase
import kotlinx.android.synthetic.main.fragment_indonesia_province_detail_item.view.*

class IndonesiaProvinceDetailListAdapter
: ListAdapter<Attributes, IndonesiaProvinceDetailViewHolder>(
: ListAdapter<IndonesiaProvinceCase, IndonesiaProvinceDetailViewHolder>(
attributesDiffUtil) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IndonesiaProvinceDetailViewHolder {
Expand All @@ -25,25 +25,25 @@ class IndonesiaProvinceDetailListAdapter
}

inner class IndonesiaProvinceDetailViewHolder(view: View): RecyclerView.ViewHolder(view) {
fun bind(attributes: Attributes) {
val provinceName = "Provinsi ${attributes.namaProvinsi}"
fun bind(case: IndonesiaProvinceCase) {
val provinceName = "Provinsi ${case.title}"
itemView.apply {
province_detail_item_title.text = provinceName
province_detail_item_total_infected_count_number.text = attributes.kasusPositif.toString()
province_detail_item_total_recovered_count_number.text = attributes.kasusSembuh.toString()
province_detail_item_total_death_count_number.text = attributes.kasusMeninggal.toString()
province_detail_item_total_infected_count_number.text = case.positiveCase.toString()
province_detail_item_total_recovered_count_number.text = case.curedCase.toString()
province_detail_item_total_death_count_number.text = case.deathCase.toString()
}
}
}

companion object {
val attributesDiffUtil = object : DiffUtil.ItemCallback<Attributes>() {
override fun areItemsTheSame(oldItem: Attributes, newItem: Attributes): Boolean {
val attributesDiffUtil = object : DiffUtil.ItemCallback<IndonesiaProvinceCase>() {
override fun areItemsTheSame(oldItem: IndonesiaProvinceCase, newItem: IndonesiaProvinceCase): Boolean {
return oldItem == newItem
}

override fun areContentsTheSame(oldItem: Attributes, newItem: Attributes): Boolean {
return oldItem.fID == newItem.fID
override fun areContentsTheSame(oldItem: IndonesiaProvinceCase, newItem: IndonesiaProvinceCase): Boolean {
return oldItem.id == newItem.id
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.nandra.covid19id.R
import com.nandra.covid19id.network.response.CountryResponse
import com.nandra.covid19id.core.domain.model.CountryCase
import kotlinx.android.synthetic.main.fragment_other_countries_detail_item.view.*

class OtherCountriesDetailListAdapter
: ListAdapter<CountryResponse, OtherCountriesDetailListAdapter.OtherCountriesDetailViewHolder>(otherCountriesDiffUtil) {
: ListAdapter<CountryCase, OtherCountriesDetailListAdapter.OtherCountriesDetailViewHolder>(otherCountriesDiffUtil) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OtherCountriesDetailViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.fragment_other_countries_detail_item, parent, false)
Expand All @@ -24,28 +24,28 @@ class OtherCountriesDetailListAdapter
}

inner class OtherCountriesDetailViewHolder(view: View): RecyclerView.ViewHolder(view) {
fun bind(country: CountryResponse) {
fun bind(country: CountryCase) {
itemView.apply {
other_countries_detail_item_title.text = country.countryName
other_countries_detail_item_total_infected_count_number.text = country.totalCase.toString()
other_countries_detail_item_total_recovered_count_number.text = country.totalRecovered.toString()
other_countries_detail_item_total_death_count_number.text = country.totalDeath.toString()
other_countries_detail_item_title.text = country.title
other_countries_detail_item_total_infected_count_number.text = country.positiveCase.toString()
other_countries_detail_item_total_recovered_count_number.text = country.curedCase.toString()
other_countries_detail_item_total_death_count_number.text = country.deathCase.toString()
}

Glide.with(itemView.context)
.load(country.countryInfo.flagImagePath)
.load(country.countryFlagImageUrl)
.placeholder(R.color.shimmerColorOne)
.into(itemView.other_countries_detail_item_flag)
}
}

companion object {
val otherCountriesDiffUtil = object : DiffUtil.ItemCallback<CountryResponse>() {
override fun areItemsTheSame(oldItem: CountryResponse, newItem: CountryResponse): Boolean {
val otherCountriesDiffUtil = object : DiffUtil.ItemCallback<CountryCase>() {
override fun areItemsTheSame(oldItem: CountryCase, newItem: CountryCase): Boolean {
return oldItem == newItem
}

override fun areContentsTheSame(oldItem: CountryResponse, newItem: CountryResponse): Boolean {
override fun areContentsTheSame(oldItem: CountryCase, newItem: CountryCase): Boolean {
return oldItem.id == newItem.id
}
}
Expand Down
Loading

0 comments on commit f2aa457

Please sign in to comment.