From e1ce4a9bec307e136f39d03ecf1f0272836e545f Mon Sep 17 00:00:00 2001 From: Florianisme Date: Sun, 12 Mar 2023 13:58:01 +0100 Subject: [PATCH 1/2] Fix synchronization when updating scanned Network Devices --- .../wakeonlan/ui/scan/NetworkScanAdapter.java | 12 +++++++++--- .../wakeonlan/ui/scan/NetworkScanFragment.java | 9 +-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/de/florianisme/wakeonlan/ui/scan/NetworkScanAdapter.java b/app/src/main/java/de/florianisme/wakeonlan/ui/scan/NetworkScanAdapter.java index c751dfa..734c9a0 100644 --- a/app/src/main/java/de/florianisme/wakeonlan/ui/scan/NetworkScanAdapter.java +++ b/app/src/main/java/de/florianisme/wakeonlan/ui/scan/NetworkScanAdapter.java @@ -25,11 +25,17 @@ public class NetworkScanAdapter extends RecyclerView.Adapter deviceList = new ArrayList<>(0); public void clearDataset() { - updateList(new ArrayList<>()); + deviceList = new ArrayList<>(); + updateDeviceList(); } - public void updateList(List updatedList) { - List sortedList = updatedList.stream() + public synchronized void addDevice(NetworkScanDevice networkScanDevice) { + deviceList.add(networkScanDevice); + updateDeviceList(); + } + + private void updateDeviceList() { + List sortedList = deviceList.stream() .distinct() .sorted(getScanDeviceComparator()) .collect(Collectors.toList()); diff --git a/app/src/main/java/de/florianisme/wakeonlan/ui/scan/NetworkScanFragment.java b/app/src/main/java/de/florianisme/wakeonlan/ui/scan/NetworkScanFragment.java index 5abd20b..f6fc7ce 100644 --- a/app/src/main/java/de/florianisme/wakeonlan/ui/scan/NetworkScanFragment.java +++ b/app/src/main/java/de/florianisme/wakeonlan/ui/scan/NetworkScanFragment.java @@ -11,9 +11,6 @@ import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; -import java.util.ArrayList; -import java.util.List; - import de.florianisme.wakeonlan.databinding.FragmentNetworkScanBinding; import de.florianisme.wakeonlan.ui.list.layoutmanager.LinearLayoutManagerWrapper; import de.florianisme.wakeonlan.ui.scan.callbacks.ScanCallback; @@ -54,7 +51,6 @@ private void setupSwipeToRefresh() { } private ScanCallback getScanCallback() { - final List resultList = new ArrayList<>(20); return new ScanCallback() { @Override @@ -71,10 +67,7 @@ public void onDeviceFound(String ip, String hostName) { networkScanDevice.setName(hostName); } - synchronized (resultList) { - resultList.add(networkScanDevice); - runOnUiThread(() -> networkScanAdapter.updateList(resultList)); - } + runOnUiThread(() -> networkScanAdapter.addDevice(networkScanDevice)); } private void runOnUiThread(Runnable runnable) { From c10ec4e23c137a6a60d29a2454c973886826f243 Mon Sep 17 00:00:00 2001 From: Florianisme Date: Mon, 13 Mar 2023 19:26:45 +0100 Subject: [PATCH 2/2] Increase Version code/name --- app/build.gradle | 2 +- shared-build.gradle | 2 +- wear/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ad67335..3352efc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply from: "$rootProject.projectDir/shared-build.gradle" android { defaultConfig { - versionCode 63 + versionCode 69 wearAppUnbundled true } buildFeatures { diff --git a/shared-build.gradle b/shared-build.gradle index a28c560..707ec35 100644 --- a/shared-build.gradle +++ b/shared-build.gradle @@ -18,7 +18,7 @@ android { applicationId "de.florianisme.wakeonlan" minSdk 24 targetSdk 33 - versionName "1.7.0" + versionName "1.7.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/wear/build.gradle b/wear/build.gradle index 87eab6e..a1b32a7 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -3,7 +3,7 @@ apply from: "$rootProject.projectDir/shared-build.gradle" android { defaultConfig { - versionCode 62 + versionCode 68 } }