49 lines
1.8 KiB
Kotlin
49 lines
1.8 KiB
Kotlin
/*
|
|
* Pupil, Hitomi.la viewer for Android
|
|
* Copyright (C) 2019 tom5079
|
|
*
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package xyz.quaver.pupil.adapters
|
|
|
|
import android.view.ViewGroup
|
|
import android.widget.ImageView
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import com.bumptech.glide.RequestManager
|
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
|
import xyz.quaver.pupil.BuildConfig
|
|
|
|
class ThumbnailAdapter(private val glide: RequestManager, var thumbnails: List<String>) : RecyclerView.Adapter<ThumbnailAdapter.ViewHolder>() {
|
|
|
|
class ViewHolder(val view: ImageView) : RecyclerView.ViewHolder(view)
|
|
|
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
|
return ViewHolder(ImageView(parent.context))
|
|
}
|
|
|
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
|
glide
|
|
.load(thumbnails[position])
|
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
|
.apply {
|
|
if (BuildConfig.CENSOR)
|
|
override(5, 8)
|
|
}
|
|
.into(holder.view)
|
|
}
|
|
|
|
override fun getItemCount() = thumbnails.size
|
|
|
|
} |