File indexing completed on 2025-02-02 04:47:53
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Albert Vaca Cintora <albertvaka@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 package org.kde.kdeconnect.UserInterface.List; 0008 0009 import android.util.TypedValue; 0010 import android.view.LayoutInflater; 0011 import android.view.View; 0012 import android.widget.TextView; 0013 0014 import androidx.annotation.NonNull; 0015 0016 public class SmallEntryItem implements ListAdapter.Item { 0017 private final String title; 0018 private final View.OnClickListener clickListener; 0019 0020 SmallEntryItem(String title, View.OnClickListener clickListener) { 0021 this.title = title; 0022 this.clickListener = clickListener; 0023 } 0024 0025 @NonNull 0026 @Override 0027 public View inflateView(@NonNull LayoutInflater layoutInflater) { 0028 View v = layoutInflater.inflate(android.R.layout.simple_list_item_1, null); 0029 final int padding = (int) (28 * layoutInflater.getContext().getResources().getDisplayMetrics().density); 0030 v.setPadding(padding, 0, padding, 0); 0031 0032 TextView titleView = v.findViewById(android.R.id.text1); 0033 if (titleView != null) { 0034 titleView.setText(title); 0035 if (clickListener != null) { 0036 titleView.setOnClickListener(clickListener); 0037 TypedValue outValue = new TypedValue(); 0038 layoutInflater.getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); 0039 v.setBackgroundResource(outValue.resourceId); 0040 } 0041 } 0042 0043 return v; 0044 } 0045 }