@@ -41,14 +41,17 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
41
41
private var player: MediaPlayer ? = null
42
42
private var progressTimer = Timer ()
43
43
private var playedRecordingIDs = Stack <Int >()
44
+ private var itemsIgnoringSearch = ArrayList <Recording >()
45
+ private var lastSearchQuery = " "
44
46
private var bus: EventBus ? = null
45
47
private var prevSavePath = " "
46
48
private var playOnPreparation = true
47
49
48
50
override fun onResume () {
49
51
setupColors()
50
52
if (prevSavePath.isNotEmpty() && context!! .config.saveRecordingsFolder != prevSavePath) {
51
- setupAdapter()
53
+ itemsIgnoringSearch = getRecordings()
54
+ setupAdapter(itemsIgnoringSearch)
52
55
} else {
53
56
getRecordingsAdapter()?.updateTextColor(context.getProperTextColor())
54
57
}
@@ -71,7 +74,8 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
71
74
bus = EventBus .getDefault()
72
75
bus!! .register(this )
73
76
setupColors()
74
- setupAdapter()
77
+ itemsIgnoringSearch = getRecordings()
78
+ setupAdapter(itemsIgnoringSearch)
75
79
initMediaPlayer()
76
80
setupViews()
77
81
storePrevPath()
@@ -132,18 +136,26 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
132
136
}
133
137
134
138
override fun refreshRecordings () {
135
- setupAdapter()
139
+ itemsIgnoringSearch = getRecordings()
140
+ setupAdapter(itemsIgnoringSearch)
136
141
}
137
142
138
- private fun setupAdapter () {
143
+ private fun setupAdapter (recordings : ArrayList < Recording > ) {
139
144
ensureBackgroundThread {
140
- val recordings = getRecordings()
141
-
142
145
Handler (Looper .getMainLooper()).post {
143
146
recordings_fastscroller.beVisibleIf(recordings.isNotEmpty())
144
147
recordings_placeholder.beVisibleIf(recordings.isEmpty())
145
148
if (recordings.isEmpty()) {
146
- val stringId = if (isQPlus()) R .string.no_recordings_found else R .string.no_recordings_in_folder_found
149
+ val stringId = if (lastSearchQuery.isEmpty()) {
150
+ if (isQPlus()) {
151
+ R .string.no_recordings_found
152
+ } else {
153
+ R .string.no_recordings_in_folder_found
154
+ }
155
+ } else {
156
+ R .string.no_items_found
157
+ }
158
+
147
159
recordings_placeholder.text = context.getString(stringId)
148
160
resetProgress(null )
149
161
player?.stop()
@@ -391,7 +403,9 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
391
403
}
392
404
393
405
fun onSearchTextChanged (text : String ) {
394
-
406
+ lastSearchQuery = text
407
+ val filtered = itemsIgnoringSearch.filter { it.title.contains(text, true ) }.toMutableList() as ArrayList <Recording >
408
+ setupAdapter(filtered)
395
409
}
396
410
397
411
private fun togglePlayPause () {
0 commit comments