Add custom item view for DeviceListAdapter.java.

This commit is contained in:
Denis-Cosmin Nutiu 2020-12-20 16:46:18 +02:00
parent d0b38e9b59
commit 1ef3ebc945
6 changed files with 58 additions and 4 deletions

View file

@ -6,6 +6,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import dev.nuculabs.nucuhub.R;
import dev.nuculabs.nucuhub.domain.Device;
import java.util.ArrayList;
@ -44,14 +45,15 @@ public class DeviceListAdapter extends BaseAdapter {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
final TextView text;
if (view == null) {
view = inflater.inflate(android.R.layout.simple_list_item_1, null);
view = inflater.inflate(R.layout.settings_device_list_item, null);
}
text = (TextView) view;
final TextView text = view.findViewById(R.id.settingsDeviceListDeviceListItemText);
text.setText(items.get(position).toString());
// TODO: Add click listeners for Delete And Select Buttons.
// TODO: Mark selected item row?
return view;
}

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/black" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
</vector>

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
</vector>

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4l-3.76,2.27 1,-4.28 -3.32,-2.88 4.38,-0.38L12,6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z"/>
</vector>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingStart="10dp" android:paddingEnd="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/settingsDeviceListDeviceListItemText"
tools:text="Device Name" android:textSize="18sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp" android:layout_weight="1">
<ImageButton
android:layout_width="100dp"
android:layout_height="wrap_content" android:id="@+id/settingsDeviceListDeviceItemSelectButton"
android:src="@drawable/ic_baseline_star_border_24"
android:contentDescription="@string/select_icon"/>
<ImageButton
android:layout_width="100dp"
android:layout_height="wrap_content" android:id="@+id/settingsDeviceListDeviceItemDeleteButton"
android:src="@drawable/ic_baseline_delete_24" android:contentDescription="@string/delete_icon"/>
</LinearLayout>
</LinearLayout>

View file

@ -49,4 +49,6 @@
<string name="attachment_title">Download incoming attachments</string>
<string name="attachment_summary_on">Automatically download attachments for incoming emails</string>
<string name="attachment_summary_off">Only download attachments when manually requested</string>
<string name="delete_icon">Delete Icon</string>
<string name="select_icon">Select Icon</string>
</resources>