File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
app/src/main/java/com/amaze/filemanager/adapters Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 21
21
package com.amaze.filemanager.adapters
22
22
23
23
import android.content.Context
24
+ import android.text.Spannable
25
+ import android.text.SpannableString
26
+ import android.text.style.ForegroundColorSpan
24
27
import android.view.LayoutInflater
25
28
import android.view.View
26
29
import android.view.ViewGroup
@@ -67,14 +70,22 @@ class SearchRecyclerViewAdapter :
67
70
override fun onBindViewHolder (holder : SearchRecyclerViewAdapter .ViewHolder , position : Int ) {
68
71
val (file, matchResult) = getItem(position)
69
72
70
- holder.fileNameTV.text = file.name
73
+ val colorPreference =
74
+ (AppConfig .getInstance().mainActivityContext as MainActivity ).currentColorPreference
75
+
76
+ val fileName = SpannableString (file.name)
77
+ fileName.setSpan(
78
+ ForegroundColorSpan (colorPreference.accent),
79
+ matchResult.first,
80
+ matchResult.last + 1 ,
81
+ Spannable .SPAN_EXCLUSIVE_EXCLUSIVE
82
+ )
83
+
84
+ holder.fileNameTV.text = fileName
71
85
holder.filePathTV.text = file.path.substring(0 , file.path.lastIndexOf(" /" ))
72
86
73
87
holder.colorView.setBackgroundColor(getRandomColor(holder.colorView.context))
74
88
75
- val colorPreference =
76
- (AppConfig .getInstance().mainActivityContext as MainActivity ).currentColorPreference
77
-
78
89
if (file.isDirectory) {
79
90
holder.colorView.setBackgroundColor(colorPreference.primaryFirstTab)
80
91
} else {
You can’t perform that action at this time.
0 commit comments