[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:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user