parent
793aeb1c6d
commit
b9287cf053
@ -1,2 +0,0 @@ |
|||||||
OGN5dS5jb20= |
|
||||||
c2cwMC54eXo= |
|
@ -1,24 +0,0 @@ |
|||||||
package io.legado.app.ui.rss.article |
|
||||||
|
|
||||||
import android.content.Context |
|
||||||
import io.legado.app.base.adapter.ItemViewHolder |
|
||||||
import io.legado.app.base.adapter.SimpleRecyclerAdapter |
|
||||||
import io.legado.app.data.entities.RssArticle |
|
||||||
import org.jetbrains.anko.sdk27.listeners.onClick |
|
||||||
|
|
||||||
|
|
||||||
abstract class RssArticlesBaseAdapter(context: Context, private val layoutId: Int, val callBack: CallBack) : |
|
||||||
SimpleRecyclerAdapter<RssArticle>(context, layoutId) { |
|
||||||
|
|
||||||
override fun registerListener(holder: ItemViewHolder) { |
|
||||||
holder.itemView.onClick { |
|
||||||
getItem(holder.layoutPosition)?.let { |
|
||||||
callBack.readRss(it) |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
interface CallBack { |
|
||||||
fun readRss(rssArticle: RssArticle) |
|
||||||
} |
|
||||||
} |
|
@ -1,63 +0,0 @@ |
|||||||
package io.legado.app.ui.rss.article |
|
||||||
|
|
||||||
import android.content.Context |
|
||||||
import android.graphics.drawable.Drawable |
|
||||||
import com.bumptech.glide.load.DataSource |
|
||||||
import com.bumptech.glide.load.engine.GlideException |
|
||||||
import com.bumptech.glide.request.RequestListener |
|
||||||
import com.bumptech.glide.request.target.Target |
|
||||||
import io.legado.app.R |
|
||||||
import io.legado.app.base.adapter.ItemViewHolder |
|
||||||
import io.legado.app.data.entities.RssArticle |
|
||||||
import io.legado.app.help.ImageLoader |
|
||||||
import io.legado.app.utils.gone |
|
||||||
import io.legado.app.utils.visible |
|
||||||
import kotlinx.android.synthetic.main.item_rss_article.view.* |
|
||||||
import org.jetbrains.anko.textColorResource |
|
||||||
|
|
||||||
|
|
||||||
class RssArticlesGridAdapter(context: Context, private val layoutId: Int, callBack: CallBack) : |
|
||||||
RssArticlesBaseAdapter(context, layoutId, callBack) { |
|
||||||
|
|
||||||
override fun convert(holder: ItemViewHolder, item: RssArticle, payloads: MutableList<Any>) { |
|
||||||
with(holder.itemView) { |
|
||||||
tv_title.text = item.title |
|
||||||
tv_pub_date.text = item.pubDate |
|
||||||
if (item.image.isNullOrBlank()) { |
|
||||||
image_view.gone() |
|
||||||
} else { |
|
||||||
ImageLoader.load(context, item.image) |
|
||||||
.addListener(object : RequestListener<Drawable> { |
|
||||||
override fun onLoadFailed( |
|
||||||
e: GlideException?, |
|
||||||
model: Any?, |
|
||||||
target: Target<Drawable>?, |
|
||||||
isFirstResource: Boolean |
|
||||||
): Boolean { |
|
||||||
image_view.gone() |
|
||||||
return false |
|
||||||
} |
|
||||||
|
|
||||||
override fun onResourceReady( |
|
||||||
resource: Drawable?, |
|
||||||
model: Any?, |
|
||||||
target: Target<Drawable>?, |
|
||||||
dataSource: DataSource?, |
|
||||||
isFirstResource: Boolean |
|
||||||
): Boolean { |
|
||||||
image_view.visible() |
|
||||||
return false |
|
||||||
} |
|
||||||
|
|
||||||
}) |
|
||||||
.into(image_view) |
|
||||||
} |
|
||||||
if (item.read) { |
|
||||||
tv_title.textColorResource = R.color.tv_text_summary |
|
||||||
} else { |
|
||||||
tv_title.textColorResource = R.color.tv_text_default |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
After Width: | Height: | Size: 168 KiB |
Loading…
Reference in new issue