音频增加搜索
This commit is contained in:
parent
4fa3f505d0
commit
56f3f48dd9
@ -1,6 +1,8 @@
|
||||
package com.ux.video.file.filerecovery.photo
|
||||
|
||||
import android.content.Intent
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
@ -57,10 +59,6 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
|
||||
val FILTER_DATE_24 = 24
|
||||
val FILTER_DATE_CUSTOMER = 0
|
||||
|
||||
val FILTER_SIZE_ALL = -1
|
||||
val FILTER_SIZE_1 = 1
|
||||
val FILTER_SIZE_5 = 2
|
||||
val FILTER_SIZE_OVER_5 = 3
|
||||
|
||||
val SORT_ASC_SIZE = 0
|
||||
val SORT_DESC_SIZE = 1
|
||||
@ -108,6 +106,7 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
|
||||
private var currentDateList: List<Pair<String, List<ResultPhotosFiles>>>? = null
|
||||
private var currentSizeList: List<ResultPhotosFiles>? = null
|
||||
|
||||
|
||||
//选中的所有数据集合(实际选中)
|
||||
private lateinit var allSelectedSetList: Set<ResultPhotosFiles>
|
||||
|
||||
@ -372,6 +371,7 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
|
||||
titleSize.text = getString(R.string.size)
|
||||
filterLayoutLinearlayout.isVisible = true
|
||||
relativeThumbnails.isVisible = true
|
||||
layoutSearch.isVisible = false
|
||||
sizeFilterItemArray = resources.getStringArray(R.array.filter_size_photo)
|
||||
}
|
||||
|
||||
@ -379,6 +379,7 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
|
||||
titleSize.text = getString(R.string.duration)
|
||||
filterLayoutLinearlayout.isVisible = true
|
||||
relativeThumbnails.isVisible = false
|
||||
layoutSearch.isVisible = false
|
||||
sizeFilterItemArray =
|
||||
resources.getStringArray(R.array.filter_duration_video_audio)
|
||||
}
|
||||
@ -387,15 +388,19 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
|
||||
titleSize.text = getString(R.string.duration)
|
||||
filterLayoutLinearlayout.isVisible = false
|
||||
relativeThumbnails.isVisible = false
|
||||
layoutSearch.isVisible = true
|
||||
sizeFilterItemArray =
|
||||
resources.getStringArray(R.array.filter_duration_video_audio)
|
||||
initSearch()
|
||||
}
|
||||
|
||||
VALUE_SCAN_TYPE_documents, VALUE_SCAN_TYPE_deleted_documents -> {
|
||||
titleSize.text = getString(R.string.size)
|
||||
filterLayoutLinearlayout.isVisible = false
|
||||
relativeThumbnails.isVisible = false
|
||||
layoutSearch.isVisible = true
|
||||
sizeFilterItemArray = resources.getStringArray(R.array.filter_documents_size)
|
||||
initSearch()
|
||||
}
|
||||
}
|
||||
|
||||
@ -576,12 +581,6 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
|
||||
{ clickValue ->
|
||||
titleSize.text = clickValue
|
||||
filterSize = clickValue
|
||||
// when (clickValue) {
|
||||
// data[0] -> filterSize = clickValue
|
||||
// data[1] -> filterSize = FILTER_SIZE_1
|
||||
// data[2] -> filterSize = FILTER_SIZE_5
|
||||
// data[3] -> filterSize = FILTER_SIZE_OVER_5
|
||||
// }
|
||||
startFilter()
|
||||
}) {
|
||||
setItemSelect(it, false)
|
||||
@ -950,5 +949,83 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun initSearch() {
|
||||
binding.run {
|
||||
iconClearSearch.setOnClickListener {
|
||||
etSearch.text.clear()
|
||||
checkTypeAfter {
|
||||
if (it) {
|
||||
currentDateList?.let { data ->
|
||||
dateAdapter?.setData(data)
|
||||
checkRefreshDisPlaySelected(list1 = data)
|
||||
}
|
||||
|
||||
} else {
|
||||
currentSizeList?.let { data ->
|
||||
sizeSortAdapter?.setData(data)
|
||||
checkRefreshDisPlaySelected(list2 = data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
etSearch.addTextChangedListener(object : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
val toString = s?.trim().toString()
|
||||
toString.let { keyword ->
|
||||
checkTypeAfter {
|
||||
if (it) {
|
||||
currentDateList?.let {
|
||||
val searchByName = Common.searchByName(it, keyword)
|
||||
dateAdapter?.setData(searchByName)
|
||||
Common.showLog("----------搜索更新数据0000000000")
|
||||
checkRefreshDisPlaySelected(list1 = searchByName)
|
||||
}
|
||||
} else {
|
||||
currentSizeList?.let {
|
||||
val searchByName = Common.searchByNameList(it, keyword)
|
||||
sizeSortAdapter?.setData(searchByName)
|
||||
Common.showLog("----------搜索更新数据111111")
|
||||
checkRefreshDisPlaySelected(list2 = searchByName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(
|
||||
s: CharSequence?,
|
||||
start: Int,
|
||||
count: Int,
|
||||
after: Int
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(
|
||||
s: CharSequence?,
|
||||
start: Int,
|
||||
before: Int,
|
||||
count: Int
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun checkTypeAfter(onAction: (isDateSort: Boolean) -> Unit) {
|
||||
when (binding.recyclerView.adapter) {
|
||||
is PhotoDisplayDateAdapter -> {
|
||||
onAction(true)
|
||||
}
|
||||
|
||||
is PhotoDisplayDateChildAdapter -> {
|
||||
onAction(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -86,6 +86,27 @@ object Common {
|
||||
}
|
||||
|
||||
|
||||
fun searchByName(
|
||||
data: List<Pair<String, List<ResultPhotosFiles>>>,
|
||||
keyword: String
|
||||
): List<Pair<String, List<ResultPhotosFiles>>> {
|
||||
if (keyword.isBlank()) return data
|
||||
|
||||
return data.mapNotNull { (key, files) ->
|
||||
val filtered = files.filter { it.name.contains(keyword, ignoreCase = true) }
|
||||
if (filtered.isNotEmpty()) key to filtered else null
|
||||
}
|
||||
}
|
||||
fun searchByNameList(
|
||||
list: List<ResultPhotosFiles>,
|
||||
keyword: String
|
||||
): List<ResultPhotosFiles> {
|
||||
if (keyword.isBlank()) return list
|
||||
return list.filter { it.name.contains(keyword, ignoreCase = true) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 格式化文件大小显示
|
||||
*/
|
||||
|
||||
7
app/src/main/res/drawable/bg_search_input.xml
Normal file
7
app/src/main/res/drawable/bg_search_input.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="20dp"/>
|
||||
<solid android:color="@color/date_dialog_bg_unselected"/>
|
||||
|
||||
</shape>
|
||||
BIN
app/src/main/res/drawable/icon_clear_search.png
Normal file
BIN
app/src/main/res/drawable/icon_clear_search.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@ -42,11 +42,53 @@
|
||||
app:selected_text="@string/deselect_all"
|
||||
tools:ignore="RelativeOverlap" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layout_search"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="36dp"
|
||||
android:layout_below="@id/tv_select_all"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="10dp"
|
||||
android:background="@drawable/bg_search_input"
|
||||
android:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_margin="10dp"
|
||||
android:src="@drawable/icon_search" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_search"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toEndOf="@id/icon"
|
||||
android:background="@null"
|
||||
android:hint="@string/search"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="36dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/main_title"
|
||||
android:textColorHint="@color/main_sub_title"
|
||||
android:textSize="17sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon_clear_search"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:src="@drawable/icon_clear_search" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/filter_date_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="42dp"
|
||||
android:layout_below="@id/tv_select_all"
|
||||
android:layout_below="@id/layout_search"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
@ -123,30 +165,23 @@
|
||||
android:layout_marginStart="8dp"
|
||||
android:src="@drawable/selector_arrow_up_down" />
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/im_search"
|
||||
android:layout_width="47dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_alignTop="@id/filter_date_layout"
|
||||
android:layout_alignBottom="@id/filter_date_layout"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:src="@drawable/icon_search" />
|
||||
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_sort"
|
||||
android:layout_width="47dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignTop="@id/filter_date_layout"
|
||||
android:layout_alignBottom="@id/filter_date_layout"
|
||||
android:layout_toStartOf="@id/im_search"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:src="@drawable/icon_sort" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/relative_thumbnails"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/relative_thumbnails"
|
||||
android:layout_below="@id/filter_date_layout">
|
||||
|
||||
<com.ux.video.file.filerecovery.utils.CustomTextView
|
||||
|
||||
@ -85,6 +85,7 @@ wait..</string>
|
||||
<string name="confirm_delete">Confirm delete?</string>
|
||||
<string name="view">View</string>
|
||||
<string name="not_found">Sorry!No %s found!</string>
|
||||
<string name="search">Search</string>
|
||||
|
||||
|
||||
<string-array name="filter_date">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user