From fe85ef685b6a8b6b5924f2de3b533d1aa30d892b Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 27 Dec 2016 00:51:28 +0100 Subject: [PATCH] use the stored background color as placeholder for image loading --- .../simplemobiletools/gallery/adapters/MediaAdapter.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 53e2ca6a7..b0530d865 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -39,6 +39,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, var displayFilenames = false val markedItems = HashSet() var foregroundColor = 0 + var backgroundColor = 0 fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) { getProperView(itemView).isSelected = select @@ -62,6 +63,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, init { foregroundColor = Config.newInstance(activity).primaryColor + backgroundColor = Config.newInstance(activity).backgroundColor } val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { @@ -201,7 +203,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder { 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) { @@ -220,7 +222,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, 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 { itemView.play_outline.visibility = if (medium.isVideo) View.VISIBLE else View.GONE itemView.file_name.beVisibleIf(displayFilenames) @@ -233,10 +235,10 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, Glide.with(activity).load(path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature).into(itemView.medium_thumbnail) } else if (medium.isPng()) { 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 { 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) }