[ShareLocation] Fixed minor UI issues

Highlighting was wrong, also if no location wiuth speed is provided,
take the first one available instead of skipping.
This commit is contained in:
Alexander Dörflinger
2025-03-25 16:51:02 +01:00
parent 9256fa69c7
commit 5e5c308d37
2 changed files with 18 additions and 9 deletions

View File

@@ -67,6 +67,7 @@ public class ActiveShareAdapter extends RecyclerView.Adapter<ActiveShareAdapter.
public ActiveShareViewHolder onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) { public ActiveShareViewHolder onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) {
final View view = LayoutInflater.from(parent.getContext()) final View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.active_share_view_holder, parent, false); .inflate(R.layout.active_share_view_holder, parent, false);
view.setSelected(false);
mAllItems.add(view); mAllItems.add(view);
return new ActiveShareViewHolder(view); return new ActiveShareViewHolder(view);
} }
@@ -90,7 +91,6 @@ public class ActiveShareAdapter extends RecyclerView.Adapter<ActiveShareAdapter.
public void applyNewData(final List<User> newUsers) { public void applyNewData(final List<User> newUsers) {
mSharingUserList.clear(); mSharingUserList.clear();
mSharingUserList.addAll(newUsers); mSharingUserList.addAll(newUsers);
mAllItems.clear();
notifyDataSetChanged(); notifyDataSetChanged();
} }
@@ -157,12 +157,12 @@ public class ActiveShareAdapter extends RecyclerView.Adapter<ActiveShareAdapter.
mItemView.setOnClickListener(v -> { mItemView.setOnClickListener(v -> {
Log.d(TAG, "setUserData: Clicked on [" + user + "]"); Log.d(TAG, "setUserData: Clicked on [" + user + "]");
if (mItemView.isSelected()) { if (mItemView.isSelected()) {
mCurrentlySelectedSubject.onNext("");
clearFocusedView(); clearFocusedView();
mCurrentlySelectedSubject.onNext("");
mItemView.setSelected(false); mItemView.setSelected(false);
} else { } else {
mCurrentlySelectedSubject.onNext(user.getuId());
clearFocusedView(); clearFocusedView();
mCurrentlySelectedSubject.onNext(user.getuId());
mItemView.setSelected(true); mItemView.setSelected(true);
} }
}); });

View File

@@ -80,17 +80,19 @@ public final class LocationHelper {
Log.d(TAG, "onLocationResult: No Location available, skip update"); Log.d(TAG, "onLocationResult: No Location available, skip update");
return; return;
} }
for (final Location location : locationResult.getLocations()) { final List<Location> allReceivedLocations = locationResult.getLocations();
for (final Location location : allReceivedLocations) {
if (location.hasSpeed()) { if (location.hasSpeed()) {
Log.d(TAG, "onLocationResult: Location with speed received, continue..."); Log.d(TAG, "onLocationResult: Location with speed received, continue...");
final LocationObject locationObject = LocationObject.fromLocation(location); handleReceivedLocation(location);
Log.d(TAG, "onLocationChanged: Received update with " + locationObject);
mLocationSubject.onNext(locationObject);
mDbHelper.insertOrUpdateLocation(locationObject);
return; 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; 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. * Build a notification to be shown while location sharing is in progress.
* *