From 5e5c308d375d5ade8f5aed4171b6d69ad6874a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20D=C3=B6rflinger?= Date: Tue, 25 Mar 2025 16:51:02 +0100 Subject: [PATCH] [ShareLocation] Fixed minor UI issues Highlighting was wrong, also if no location wiuth speed is provided, take the first one available instead of skipping. --- .../familyhelpers/ui/ActiveShareAdapter.java | 6 +++--- .../familyhelpers/workers/LocationHelper.java | 21 +++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/aldo/apps/familyhelpers/ui/ActiveShareAdapter.java b/app/src/main/java/com/aldo/apps/familyhelpers/ui/ActiveShareAdapter.java index 414d2c1..1f9a38e 100644 --- a/app/src/main/java/com/aldo/apps/familyhelpers/ui/ActiveShareAdapter.java +++ b/app/src/main/java/com/aldo/apps/familyhelpers/ui/ActiveShareAdapter.java @@ -67,6 +67,7 @@ public class ActiveShareAdapter extends RecyclerView.Adapter newUsers) { mSharingUserList.clear(); mSharingUserList.addAll(newUsers); - mAllItems.clear(); notifyDataSetChanged(); } @@ -157,12 +157,12 @@ public class ActiveShareAdapter extends RecyclerView.Adapter { Log.d(TAG, "setUserData: Clicked on [" + user + "]"); if (mItemView.isSelected()) { - mCurrentlySelectedSubject.onNext(""); clearFocusedView(); + mCurrentlySelectedSubject.onNext(""); mItemView.setSelected(false); } else { - mCurrentlySelectedSubject.onNext(user.getuId()); clearFocusedView(); + mCurrentlySelectedSubject.onNext(user.getuId()); mItemView.setSelected(true); } }); diff --git a/app/src/main/java/com/aldo/apps/familyhelpers/workers/LocationHelper.java b/app/src/main/java/com/aldo/apps/familyhelpers/workers/LocationHelper.java index 5ea056f..243cb6a 100644 --- a/app/src/main/java/com/aldo/apps/familyhelpers/workers/LocationHelper.java +++ b/app/src/main/java/com/aldo/apps/familyhelpers/workers/LocationHelper.java @@ -80,17 +80,19 @@ public final class LocationHelper { Log.d(TAG, "onLocationResult: No Location available, skip update"); return; } - for (final Location location : locationResult.getLocations()) { + final List allReceivedLocations = locationResult.getLocations(); + for (final Location location : allReceivedLocations) { if (location.hasSpeed()) { Log.d(TAG, "onLocationResult: Location with speed received, continue..."); - final LocationObject locationObject = LocationObject.fromLocation(location); - Log.d(TAG, "onLocationChanged: Received update with " + locationObject); - mLocationSubject.onNext(locationObject); - mDbHelper.insertOrUpdateLocation(locationObject); + handleReceivedLocation(location); return; } } - Log.d(TAG, "onLocationResult: Haven't receive a location with speed, skip this update..."); + if (!allReceivedLocations.isEmpty()) { + Log.d(TAG, "onLocationResult: Haven't receive a location with speed, take first value..."); + final Location backupLocation = allReceivedLocations.get(0); + handleReceivedLocation(backupLocation); + } } }; @@ -268,6 +270,13 @@ public final class LocationHelper { return mSharingStateSubject; } + private void handleReceivedLocation(final Location location) { + final LocationObject locationObject = LocationObject.fromLocation(location); + Log.d(TAG, "onLocationChanged: Received update with " + locationObject); + mLocationSubject.onNext(locationObject); + mDbHelper.insertOrUpdateLocation(locationObject); + } + /** * Build a notification to be shown while location sharing is in progress. *