diff options
author | Eugene Susla <eugenesusla@google.com> | 2018-04-16 11:32:52 -0700 |
---|---|---|
committer | Eugene Susla <eugenesusla@google.com> | 2018-04-18 22:19:13 +0000 |
commit | 9a130ef9379a27ba380b390c707fa5688d898c0c (patch) | |
tree | f40b25f005abffcfa9a763235afb7d0a9a6331ba | |
parent | b2182c412c534be18a3b0c869d186fcf91a86a6d (diff) |
[DO NOT MERGE] [Companion] Call notifyDataSetChanged on main thread
Fixes: 78090775
Test: ensure attached bug not reproduces
Change-Id: I386087742883e4847d811f7b8e6e7c8c8aea227a
-rw-r--r-- | packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java index a5f0f24363a5..1ca3c1dbe5be 100644 --- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java +++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java @@ -65,9 +65,7 @@ import android.widget.TextView; import com.android.internal.util.ArrayUtils; import com.android.internal.util.CollectionUtils; import com.android.internal.util.Preconditions; -import com.android.internal.util.function.pooled.PooledLambda; -import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -219,7 +217,7 @@ public class DeviceDiscoveryService extends Service { stopScan(); mDevicesFound.clear(); mSelectedDevice = null; - mDevicesAdapter.notifyDataSetChanged(); + notifyDataSetChanged(); } @Override @@ -265,7 +263,12 @@ public class DeviceDiscoveryService extends Service { onReadyToShowUI(); } mDevicesFound.add(device); - mDevicesAdapter.notifyDataSetChanged(); + notifyDataSetChanged(); + } + + private void notifyDataSetChanged() { + Handler.getMain().sendMessage(obtainMessage( + DevicesAdapter::notifyDataSetChanged, mDevicesAdapter)); } //TODO also, on timeout -> call onFailure @@ -283,7 +286,7 @@ public class DeviceDiscoveryService extends Service { private void onDeviceLost(@Nullable DeviceFilterPair device) { mDevicesFound.remove(device); - mDevicesAdapter.notifyDataSetChanged(); + notifyDataSetChanged(); if (DEBUG) Log.i(LOG_TAG, "Lost device " + device.getDisplayName()); } |