mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
replace the selected directory foreground marker with a temporary check icon
This commit is contained in:
parent
5c448081f0
commit
fa775e35e3
4 changed files with 18 additions and 56 deletions
|
@ -1,11 +1,9 @@
|
|||
package com.simplemobiletools.gallery.adapters
|
||||
|
||||
import android.os.Build
|
||||
import android.support.v7.view.ActionMode
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.util.SparseArray
|
||||
import android.view.*
|
||||
import android.widget.FrameLayout
|
||||
import com.bignerdranch.android.multiselector.ModalMultiSelectorCallback
|
||||
import com.bignerdranch.android.multiselector.MultiSelector
|
||||
import com.bignerdranch.android.multiselector.SwappingHolder
|
||||
|
@ -23,7 +21,6 @@ import com.simplemobiletools.gallery.extensions.*
|
|||
import com.simplemobiletools.gallery.models.AlbumCover
|
||||
import com.simplemobiletools.gallery.models.Directory
|
||||
import kotlinx.android.synthetic.main.directory_item.view.*
|
||||
import kotlinx.android.synthetic.main.directory_tmb.view.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
|
@ -42,7 +39,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
|
||||
fun toggleItemSelection(select: Boolean, pos: Int) {
|
||||
if (itemViews[pos] != null)
|
||||
getProperView(itemViews[pos]!!).isSelected = select
|
||||
itemViews[pos].dir_check.beVisibleIf(select)
|
||||
|
||||
if (select)
|
||||
selectedPositions.add(pos)
|
||||
|
@ -57,13 +54,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
updateTitle(selectedPositions.size)
|
||||
}
|
||||
|
||||
fun getProperView(itemView: View): View {
|
||||
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
itemView.dir_frame
|
||||
else
|
||||
itemView.dir_thumbnail
|
||||
}
|
||||
|
||||
fun updateTitle(cnt: Int) {
|
||||
actMode?.title = "$cnt / ${dirs.size}"
|
||||
actMode?.invalidate()
|
||||
|
@ -72,14 +62,9 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
fun updatePrimaryColor(color: Int) {
|
||||
foregroundColor = color
|
||||
(0..itemViews.size() - 1).mapNotNull { itemViews[it] }
|
||||
.forEach { setupItemViewForeground(it) }
|
||||
}
|
||||
.forEach {
|
||||
|
||||
private fun setupItemViewForeground(itemView: View) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
(getProperView(itemView) as FrameLayout).foreground = foregroundColor.createSelector()
|
||||
else
|
||||
getProperView(itemView).foreground = foregroundColor.createSelector()
|
||||
}
|
||||
}
|
||||
|
||||
val adapterListener = object : MyAdapterListener {
|
||||
|
@ -87,10 +72,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
toggleItemSelection(select, position)
|
||||
}
|
||||
|
||||
override fun setupItemForeground(itemView: View) {
|
||||
setupItemViewForeground(itemView)
|
||||
}
|
||||
|
||||
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
||||
}
|
||||
|
||||
|
@ -136,7 +117,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
super.onDestroyActionMode(actionMode)
|
||||
selectedPositions.forEach {
|
||||
if (itemViews[it] != null)
|
||||
getProperView(itemViews[it]!!).isSelected = false
|
||||
itemViews[it].dir_check.beGone()
|
||||
}
|
||||
selectedPositions.clear()
|
||||
actMode = null
|
||||
|
@ -430,8 +411,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
|
||||
setOnClickListener { viewClicked(directory) }
|
||||
setOnLongClickListener { if (isPickIntent) viewClicked(directory) else viewLongClicked(); true }
|
||||
|
||||
adapterListener.setupItemForeground(this)
|
||||
}
|
||||
return itemView
|
||||
}
|
||||
|
@ -465,8 +444,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
interface MyAdapterListener {
|
||||
fun toggleItemSelectionAdapter(select: Boolean, position: Int)
|
||||
|
||||
fun setupItemForeground(itemView: View)
|
||||
|
||||
fun getSelectedPositions(): HashSet<Int>
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.simplemobiletools.gallery.views.MySquareImageView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/dir_thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
|
@ -6,14 +6,20 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:padding="1px">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/tmb_wrapper"
|
||||
<com.simplemobiletools.gallery.views.MySquareImageView
|
||||
android:id="@+id/dir_thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<include layout="@layout/directory_tmb"/>
|
||||
|
||||
</FrameLayout>
|
||||
<ImageView
|
||||
android:id="@+id/dir_check"
|
||||
android:layout_width="@dimen/pin_size"
|
||||
android:layout_height="@dimen/pin_size"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_margin="@dimen/small_margin"
|
||||
android:src="@drawable/ic_check"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dir_pin"
|
||||
|
@ -36,9 +42,9 @@
|
|||
android:id="@+id/dir_bottom_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/tmb_wrapper"
|
||||
android:layout_alignLeft="@+id/dir_thumbnail"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignRight="@+id/tmb_wrapper"
|
||||
android:layout_alignRight="@+id/dir_thumbnail"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/small_margin"
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge>
|
||||
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/dir_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.simplemobiletools.gallery.views.MySquareImageView
|
||||
android:id="@+id/dir_thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</FrameLayout>
|
||||
</merge>
|
Loading…
Reference in a new issue