color icons and texts in list views appropriately

This commit is contained in:
tibbi 2017-09-29 23:46:09 +02:00
parent d89ebec57a
commit 1cd68fe9a0
2 changed files with 18 additions and 5 deletions

View file

@ -38,6 +38,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
var itemViews = SparseArray<View>()
val selectedPositions = HashSet<Int>()
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<Direc
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val dir = dirs[position]
itemViews.put(position, holder.bindView(dir, pinnedFolders.contains(dir.path), scrollVertically))
itemViews.put(position, holder.bindView(dir, pinnedFolders.contains(dir.path), scrollVertically, isListViewType, textColor))
toggleItemSelection(selectedPositions.contains(position), position)
holder.itemView.tag = holder
}
@ -394,7 +395,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
val multiSelector: MultiSelector, val listener: DirOperationsListener?, val isPickIntent: Boolean, val itemClick: (Directory) -> (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<Direc
dir_pin.beVisibleIf(isPinned)
dir_sd_card.beVisibleIf(activity.isPathOnSD(directory.path))
if (isListView) {
dir_name.setTextColor(textColor)
dir_pin.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
dir_sd_card.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
}
setOnClickListener { viewClicked(directory) }
setOnLongClickListener { if (isPickIntent) viewClicked(directory) else viewLongClicked(); true }
}

View file

@ -35,6 +35,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
var itemViews = SparseArray<View>()
val selectedPositions = HashSet<Int>()
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<Medium>,
}
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<Medium>,
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 }
}