[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) {
final View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.active_share_view_holder, parent, false);
view.setSelected(false);
mAllItems.add(view);
return new ActiveShareViewHolder(view);
}
@@ -90,7 +91,6 @@ public class ActiveShareAdapter extends RecyclerView.Adapter<ActiveShareAdapter.
public void applyNewData(final List<User> newUsers) {
mSharingUserList.clear();
mSharingUserList.addAll(newUsers);
mAllItems.clear();
notifyDataSetChanged();
}
@@ -157,12 +157,12 @@ public class ActiveShareAdapter extends RecyclerView.Adapter<ActiveShareAdapter.
mItemView.setOnClickListener(v -> {
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);
}
});

View File

@@ -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<Location> 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.
*