@@ -19,21 +19,35 @@ import androidx.core.database.getIntOrNull
1919import androidx.core.database.getStringOrNull
2020import androidx.cursoradapter.widget.CursorAdapter
2121import it.niedermann.owncloud.notes.R
22+ import it.niedermann.owncloud.notes.branding.BrandingUtil
23+ import it.niedermann.owncloud.notes.databinding.ItemSuggestionAdapterBinding
2224import it.niedermann.owncloud.notes.persistence.entity.Account
2325import it.niedermann.owncloud.notes.share.helper.AvatarLoader
2426
25- class SuggestionAdapter (context : Context , cursor : Cursor ? , private val account : Account ) : CursorAdapter(context, cursor, false ) {
27+ /* *
28+ * [CursorAdapter] used to display search suggestions for sharees for sharing notes.
29+ *
30+ * This adapter handles the layout and binding of suggestion data, including the
31+ * display of user avatars or system icons based on the provided search cursor.
32+ *
33+ * @param context The [Context] in which the adapter is running.
34+ * @param cursor The [Cursor] from which to get the data.
35+ * @param account The [Account] used for loading authenticated avatars.
36+ */
37+ class SuggestionAdapter (context : Context , cursor : Cursor ? , private val account : Account ) :
38+ CursorAdapter (context, cursor, false ) {
2639 override fun newView (context : Context , cursor : Cursor , parent : ViewGroup ): View {
27- val inflater = LayoutInflater .from(context)
28- return inflater.inflate(R .layout.item_suggestion_adapter, parent, false )
40+ val binding = ItemSuggestionAdapterBinding .inflate(LayoutInflater .from(context), parent, false )
41+ val brandingUtil = BrandingUtil .of(BrandingUtil .readBrandMainColor(parent.context), parent.context)
42+ binding.root.setBackgroundColor(brandingUtil.getScheme(parent.context).surfaceContainerHigh)
43+ return binding.root
2944 }
3045
3146 override fun bindView (view : View , context : Context , cursor : Cursor ) {
3247 val suggestion =
3348 cursor.getString(cursor.getColumnIndexOrThrow(SearchManager .SUGGEST_COLUMN_TEXT_1 ))
3449 view.findViewById<TextView >(R .id.suggestion_text).text = suggestion
3550
36-
3751 val icon = view.findViewById<ImageView >(R .id.suggestion_icon)
3852 val iconColumn = cursor.getColumnIndex(SearchManager .SUGGEST_COLUMN_ICON_1 )
3953
0 commit comments