From 697d01882ba8b1dbb85484ba3bf6e810e32448fc Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 24 Dec 2018 01:47:03 -0500 Subject: Enhancement/ktlint (#1259) * Add spotless * Reformat code * Apply license header * Add remaining license headers --- .../com/pitchedapps/frost/views/AccountItem.kt | 69 +++++++++++++++++----- 1 file changed, 53 insertions(+), 16 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt index 9f6d0c06..d7a7de0e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt @@ -1,12 +1,32 @@ +/* + * Copyright 2018 Allan Wang + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package com.pitchedapps.frost.views import android.graphics.drawable.Drawable -import androidx.appcompat.widget.AppCompatTextView -import androidx.recyclerview.widget.RecyclerView import android.view.View import android.widget.ImageView +import androidx.appcompat.widget.AppCompatTextView +import androidx.recyclerview.widget.RecyclerView import ca.allanwang.kau.iitems.KauIItem -import ca.allanwang.kau.utils.* +import ca.allanwang.kau.utils.bindView +import ca.allanwang.kau.utils.fadeIn +import ca.allanwang.kau.utils.invisible +import ca.allanwang.kau.utils.toDrawable +import ca.allanwang.kau.utils.visible import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.request.RequestListener @@ -23,7 +43,7 @@ import com.pitchedapps.frost.utils.Prefs * Created by Allan Wang on 2017-06-05. */ class AccountItem(val cookie: CookieModel?) : KauIItem -(R.layout.view_account, { ViewHolder(it) }, R.id.item_account) { + (R.layout.view_account, { ViewHolder(it) }, R.id.item_account) { override fun bindView(viewHolder: ViewHolder, payloads: MutableList) { super.bindView(viewHolder, payloads) @@ -33,20 +53,37 @@ class AccountItem(val cookie: CookieModel?) : KauIItem { - override fun onResourceReady(resource: Drawable?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { - text.fadeIn() - return false - } + .transform(FrostGlide.roundCorner).listener(object : RequestListener { + override fun onResourceReady( + resource: Drawable?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { + text.fadeIn() + return false + } - override fun onLoadFailed(e: GlideException?, model: Any?, target: Target?, isFirstResource: Boolean): Boolean { - text.fadeIn() - return false - } - }).into(image) + override fun onLoadFailed( + e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean + ): Boolean { + text.fadeIn() + return false + } + }).into(image) } else { text.visible() - image.setImageDrawable(GoogleMaterial.Icon.gmd_add_circle_outline.toDrawable(itemView.context, 100, Prefs.textColor)) + image.setImageDrawable( + GoogleMaterial.Icon.gmd_add_circle_outline.toDrawable( + itemView.context, + 100, + Prefs.textColor + ) + ) text.text = itemView.context.getString(R.string.kau_add_account) } } @@ -64,4 +101,4 @@ class AccountItem(val cookie: CookieModel?) : KauIItem