mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-29 05:07:40 +00:00
Use view binding in RunCommandWidgetDeviceSelector.
This commit is contained in:
parent
0c38405965
commit
cfa00c05ca
@ -6,7 +6,7 @@
|
|||||||
android:padding="20dp">
|
android:padding="20dp">
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/runcommandsdevicelist"
|
android:id="@+id/run_commands_device_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
@ -3,7 +3,6 @@ package org.kde.kdeconnect.Plugins.RunCommandPlugin;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.ListView;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
@ -11,7 +10,7 @@ import org.kde.kdeconnect.BackgroundService;
|
|||||||
import org.kde.kdeconnect.Device;
|
import org.kde.kdeconnect.Device;
|
||||||
import org.kde.kdeconnect.UserInterface.List.ListAdapter;
|
import org.kde.kdeconnect.UserInterface.List.ListAdapter;
|
||||||
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.databinding.WidgetRemoteCommandPluginDialogBinding;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -24,11 +23,12 @@ public class RunCommandWidgetDeviceSelector extends AppCompatActivity {
|
|||||||
|
|
||||||
ThemeUtil.setUserPreferredTheme(this);
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
setContentView(R.layout.widget_remotecommandplugin_dialog);
|
|
||||||
|
final WidgetRemoteCommandPluginDialogBinding binding =
|
||||||
|
WidgetRemoteCommandPluginDialogBinding.inflate(getLayoutInflater());
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
BackgroundService.RunCommand(this, service -> runOnUiThread(() -> {
|
BackgroundService.RunCommand(this, service -> runOnUiThread(() -> {
|
||||||
ListView view = findViewById(R.id.runcommandsdevicelist);
|
|
||||||
|
|
||||||
final List<CommandEntry> deviceItems = service.getDevices().values().stream()
|
final List<CommandEntry> deviceItems = service.getDevices().values().stream()
|
||||||
.filter(Device::isPaired).filter(Device::isReachable)
|
.filter(Device::isPaired).filter(Device::isReachable)
|
||||||
.map(device -> new CommandEntry(device.getName(), null, device.getDeviceId()))
|
.map(device -> new CommandEntry(device.getName(), null, device.getDeviceId()))
|
||||||
@ -37,8 +37,8 @@ public class RunCommandWidgetDeviceSelector extends AppCompatActivity {
|
|||||||
|
|
||||||
ListAdapter adapter = new ListAdapter(RunCommandWidgetDeviceSelector.this, deviceItems);
|
ListAdapter adapter = new ListAdapter(RunCommandWidgetDeviceSelector.this, deviceItems);
|
||||||
|
|
||||||
view.setAdapter(adapter);
|
binding.runCommandsDeviceList.setAdapter(adapter);
|
||||||
view.setOnItemClickListener((adapterView, viewContent, i, l) -> {
|
binding.runCommandsDeviceList.setOnItemClickListener((adapterView, viewContent, i, l) -> {
|
||||||
CommandEntry entry = deviceItems.get(i);
|
CommandEntry entry = deviceItems.get(i);
|
||||||
RunCommandWidget.setCurrentDevice(entry.getKey());
|
RunCommandWidget.setCurrentDevice(entry.getKey());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user