use the stored background color as placeholder for image loading
This commit is contained in:
parent
c6dd89bc43
commit
fe85ef685b
|
@ -39,6 +39,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
var displayFilenames = false
|
var displayFilenames = false
|
||||||
val markedItems = HashSet<Int>()
|
val markedItems = HashSet<Int>()
|
||||||
var foregroundColor = 0
|
var foregroundColor = 0
|
||||||
|
var backgroundColor = 0
|
||||||
|
|
||||||
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
||||||
getProperView(itemView).isSelected = select
|
getProperView(itemView).isSelected = select
|
||||||
|
@ -62,6 +63,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
|
|
||||||
init {
|
init {
|
||||||
foregroundColor = Config.newInstance(activity).primaryColor
|
foregroundColor = Config.newInstance(activity).primaryColor
|
||||||
|
backgroundColor = Config.newInstance(activity).backgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||||
|
@ -201,7 +203,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
|
||||||
val view = LayoutInflater.from(parent?.context).inflate(R.layout.photo_video_item, parent, false)
|
val view = LayoutInflater.from(parent?.context).inflate(R.layout.photo_video_item, parent, false)
|
||||||
return ViewHolder(view, foregroundColor, itemClick)
|
return ViewHolder(view, backgroundColor, foregroundColor, itemClick)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
@ -220,7 +222,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewHolder(view: View, val foregroundColor: Int, val itemClick: (Medium) -> (Unit)) : SwappingHolder(view, MultiSelector()) {
|
class ViewHolder(view: View, val backgroundColor: Int, val foregroundColor: Int, val itemClick: (Medium) -> (Unit)) : SwappingHolder(view, MultiSelector()) {
|
||||||
fun bindView(activity: SimpleActivity, multiSelectorCallback: ModalMultiSelectorCallback, multiSelector: MultiSelector, medium: Medium, pos: Int): View {
|
fun bindView(activity: SimpleActivity, multiSelectorCallback: ModalMultiSelectorCallback, multiSelector: MultiSelector, medium: Medium, pos: Int): View {
|
||||||
itemView.play_outline.visibility = if (medium.isVideo) View.VISIBLE else View.GONE
|
itemView.play_outline.visibility = if (medium.isVideo) View.VISIBLE else View.GONE
|
||||||
itemView.file_name.beVisibleIf(displayFilenames)
|
itemView.file_name.beVisibleIf(displayFilenames)
|
||||||
|
@ -233,10 +235,10 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
Glide.with(activity).load(path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature).into(itemView.medium_thumbnail)
|
Glide.with(activity).load(path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature).into(itemView.medium_thumbnail)
|
||||||
} else if (medium.isPng()) {
|
} else if (medium.isPng()) {
|
||||||
Glide.with(activity).load(path).asBitmap().format(DecodeFormat.PREFER_ARGB_8888).diskCacheStrategy(DiskCacheStrategy.RESULT)
|
Glide.with(activity).load(path).asBitmap().format(DecodeFormat.PREFER_ARGB_8888).diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||||
.signature(timestampSignature).placeholder(R.color.tmb_background).centerCrop().into(itemView.medium_thumbnail)
|
.signature(timestampSignature).placeholder(backgroundColor).centerCrop().into(itemView.medium_thumbnail)
|
||||||
} else {
|
} else {
|
||||||
Glide.with(activity).load(path).diskCacheStrategy(DiskCacheStrategy.RESULT).signature(timestampSignature)
|
Glide.with(activity).load(path).diskCacheStrategy(DiskCacheStrategy.RESULT).signature(timestampSignature)
|
||||||
.placeholder(R.color.tmb_background).centerCrop().crossFade().into(itemView.medium_thumbnail)
|
.placeholder(backgroundColor).centerCrop().crossFade().into(itemView.medium_thumbnail)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemView.setOnClickListener { viewClicked(multiSelector, medium, pos) }
|
itemView.setOnClickListener { viewClicked(multiSelector, medium, pos) }
|
||||||
|
|
Loading…
Reference in New Issue