From 1cd68fe9a034eaafb2c5bfb243506e82e2171448 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 23:46:09 +0200 Subject: [PATCH] color icons and texts in list views appropriately --- .../gallery/adapters/DirectoryAdapter.kt | 11 +++++++++-- .../gallery/adapters/MediaAdapter.kt | 12 +++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index c70d13194..257b94375 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -38,6 +38,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList() val selectedPositions = HashSet() var primaryColor = config.primaryColor + var textColor = config.textColor var pinnedFolders = config.pinnedFolders var scrollVertically = !config.scrollHorizontally @@ -335,7 +336,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList (Unit)) : SwappingHolder(view, MultiSelector()) { - fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean): View { + fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean, isListView: Boolean, textColor: Int): View { itemView.apply { dir_name.text = directory.name dir_path?.text = "${directory.path.substringBeforeLast("/")}/" @@ -403,6 +404,12 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, var itemViews = SparseArray() val selectedPositions = HashSet() var primaryColor = config.primaryColor + var textColor = config.textColor var displayFilenames = config.displayFileNames var scrollVertically = !config.scrollHorizontally @@ -250,7 +251,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - itemViews.put(position, holder.bindView(media[position], displayFilenames || isListViewType, scrollVertically)) + itemViews.put(position, holder.bindView(media[position], displayFilenames, scrollVertically, isListViewType, textColor)) toggleItemSelection(selectedPositions.contains(position), position) holder.itemView.tag = holder } @@ -314,13 +315,18 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback, val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val isPickIntent: Boolean, val itemClick: (Medium) -> (Unit)) : SwappingHolder(view, MultiSelector()) { - fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean): View { + fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean, isListViewType: Boolean, textColor: Int): View { itemView.apply { play_outline.visibility = if (medium.video) View.VISIBLE else View.GONE - photo_name.beVisibleIf(displayFilenames) + photo_name.beVisibleIf(displayFilenames || isListViewType) photo_name.text = medium.name activity.loadImage(medium.path, medium_thumbnail, scrollVertically) + if (isListViewType) { + photo_name.setTextColor(textColor) + play_outline.setColorFilter(textColor, PorterDuff.Mode.SRC_IN) + } + setOnClickListener { viewClicked(medium) } setOnLongClickListener { if (isPickIntent) viewClicked(medium) else viewLongClicked(); true } }