Skip to content

Commit

Permalink
Removed Glide support in favor of Coil
Browse files Browse the repository at this point in the history
  • Loading branch information
Javinator9889 committed Jul 1, 2020
1 parent 1ecd615 commit 1c7e697
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 218 deletions.
10 changes: 9 additions & 1 deletion ads/build.gradle
Expand Up @@ -22,14 +22,22 @@ android {
proguardFiles 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':app')

// https://firebase.google.com/docs/admob/android/quick-start#import_the_mobile_ads_sdk
implementation 'com.google.firebase:firebase-ads:19.1.0'
implementation 'com.google.firebase:firebase-ads:19.2.0'
}
repositories {
mavenCentral()
Expand Down
15 changes: 9 additions & 6 deletions app/build.gradle
Expand Up @@ -99,7 +99,12 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
Expand Down Expand Up @@ -176,10 +181,6 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0'
// https://developer.android.com/reference/kotlin/androidx/preference/package-summary
api 'androidx.preference:preference-ktx:1.1.1'
// https://github.com/bumptech/glide
api 'com.github.bumptech.glide:glide:4.11.0'
api 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
// https://github.com/afollestad/material-dialogs/
implementation 'com.afollestad.material-dialogs:core:3.3.0'
// https://developer.android.com/google/play/billing/billing_library_overview
Expand All @@ -190,15 +191,17 @@ dependencies {
// https://github.com/SufficientlySecure/html-textview
implementation 'org.sufficientlysecure:html-textview:3.9'
// https://github.com/square/okhttp/tree/okhttp_3.12.x
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
implementation 'com.squareup.okhttp3:okhttp:3.12.11'
// https://square.github.io/okio/#releases
implementation 'com.squareup.okio:okio:2.5.0'
implementation 'com.squareup.okio:okio:2.6.0'
// https://github.com/deano2390/MaterialShowcaseView
implementation 'com.github.deano2390:MaterialShowcaseView:1.3.4'
// https://github.com/PhilJay/MPAndroidChart
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
// https://developer.android.com/training/data-storage/room
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
// https://coil-kt.github.io/coil/
api "io.coil-kt:coil:0.11.0"
}
apply plugin: 'com.google.gms.google-services'
Expand Up @@ -23,13 +23,16 @@ import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.lifecycle.LifecycleCoroutineScope
import coil.Coil
import coil.api.load
import coil.request.GetRequest
import com.airbnb.lottie.LottieAnimationView
import com.google.android.material.card.MaterialCardView
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.graphics.GlideApp
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.items.AbstractItem
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import timber.log.Timber
import java.text.DateFormat
import java.util.*
Expand Down Expand Up @@ -60,10 +63,6 @@ data class News(
val cardContainer: MaterialCardView = view.findViewById(R.id.root)
val shareImage: ImageView = view.findViewById(R.id.share)

/*init {
setIsRecyclable(!isHighPerformingDevice())
}*/

@SuppressLint("SetTextI18n")
override fun bindView(item: News, payloads: List<Any>) {
val formatter = DateFormat.getDateTimeInstance()
Expand All @@ -72,33 +71,32 @@ data class News(
item.lifecycleScope.launch(context = Dispatchers.Main) {
title.text = item.title
description.text = item.short
val deferreds = mutableSetOf<Deferred<Any?>>()
if (item.imageUrl != null)
deferreds.add(
async {
GlideApp.with(context)
.load(item.imageUrl)
.optionalCenterCrop()
.into(imageHeader)
}
)
else imageHeader.visibility = View.GONE
if (item.websiteImageUrl != null)
deferreds.add(
async {
GlideApp.with(context)
.load(item.websiteImageUrl)
.optionalCenterCrop()
.into(websiteLogo)
}
)
else websiteLogo.visibility = View.GONE
val imageLoader = Coil.imageLoader(view.context)
if (item.imageUrl != null) {
val request = GetRequest.Builder(view.context)
.data(item.imageUrl)
.size(imageHeader.width, imageHeader.height)
.allowHardware(true)
.build()
launch(Dispatchers.IO) {
imageHeader.load(imageLoader.execute(request).drawable)
}
} else imageHeader.visibility = View.GONE
if (item.websiteImageUrl != null) {
val request = GetRequest.Builder(view.context)
.data(item.websiteImageUrl)
.size(websiteLogo.width, websiteLogo.height)
.allowHardware(true)
.build()
launch(Dispatchers.IO) {
websiteLogo.load(imageLoader.execute(request).drawable)
}
} else websiteLogo.visibility = View.GONE
websiteName.text = item.website
?: context.getString(R.string.no_website)
publishDate.text =
item.discoverDate?.let { formatter.format(it) }
?: context.getString(R.string.no_date)
deferreds.awaitAll()
}
}

Expand Down
Expand Up @@ -27,10 +27,10 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.whenStarted
import coil.api.load
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.activities.base.BaseFragmentView
import com.javinator9889.handwashingreminder.activities.views.viewmodels.*
import com.javinator9889.handwashingreminder.graphics.GlideApp
import kotlinx.android.synthetic.main.wash_your_hands_demo.*
import kotlinx.coroutines.launch
import timber.log.Timber
Expand Down Expand Up @@ -69,9 +69,7 @@ class SliderView : BaseFragmentView() {
})
washingHandsModel.image.observe(viewLifecycleOwner, Observer {
try {
GlideApp.with(this@SliderView)
.load(it)
.into(image)
image.load(it)
} catch (e: Exception) {
Timber.e(e, "Error while loading Glide view")
image.setImageResource(it)
Expand Down Expand Up @@ -124,10 +122,7 @@ class SliderView : BaseFragmentView() {
video.requestFocus()
video.start()
try {
GlideApp.with(this)
.load(drawableId)
.centerInside()
.into(image)
image.load(drawableId)
} catch (e: Exception) {
Timber.e(e, "Error while loading Glide view")
image.setImageResource(drawableId)
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 1c7e697

Please sign in to comment.