Simplify and optimize Kotlin code snippets
This commit is contained in:
@@ -14,10 +14,10 @@ import com.github.gotify.log.Log
|
||||
import com.github.gotify.messages.provider.MessageImageCombiner
|
||||
import com.squareup.picasso.OkHttp3Downloader
|
||||
import com.squareup.picasso.Picasso
|
||||
import okhttp3.Cache
|
||||
import okhttp3.OkHttpClient
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import okhttp3.Cache
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
internal class PicassoHandler(private val context: Context, private val settings: Settings) {
|
||||
companion object {
|
||||
@@ -31,7 +31,7 @@ internal class PicassoHandler(private val context: Context, private val settings
|
||||
)
|
||||
|
||||
private val picasso: Picasso = makePicasso()
|
||||
private val appIdToAppImage: MutableMap<Long, String> = mutableMapOf()
|
||||
private val appIdToAppImage = mutableMapOf<Long, String>()
|
||||
|
||||
private fun makePicasso(): Picasso {
|
||||
val builder = OkHttpClient.Builder()
|
||||
@@ -45,9 +45,7 @@ internal class PicassoHandler(private val context: Context, private val settings
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun getImageFromUrl(url: String?): Bitmap {
|
||||
return picasso.load(url).get()
|
||||
}
|
||||
fun getImageFromUrl(url: String?): Bitmap = picasso.load(url).get()
|
||||
|
||||
fun getIcon(appId: Long): Bitmap {
|
||||
if (appId == -1L) {
|
||||
|
||||
Reference in New Issue
Block a user