Fix location picker layout issue

pull/795/head
Alex Baker 5 years ago
parent c7401762b2
commit fbcd321f8e

@ -224,7 +224,9 @@ public class LocationPickerActivity extends InjectingAppCompatActivity
public void onLayoutChange( public void onLayoutChange(
View v, int l, int t, int r, int b, int ol, int ot, int or, int ob) { View v, int l, int t, int r, int b, int ol, int ot, int or, int ob) {
coordinatorLayout.removeOnLayoutChangeListener(this); coordinatorLayout.removeOnLayoutChangeListener(this);
updateAppbarLayout(); locationDao
.getPlaceUsage()
.observe(LocationPickerActivity.this, LocationPickerActivity.this::updatePlaces);
} }
}); });
@ -406,8 +408,6 @@ public class LocationPickerActivity extends InjectingAppCompatActivity
.debounce(SEARCH_DEBOUNCE_TIMEOUT, TimeUnit.MILLISECONDS) .debounce(SEARCH_DEBOUNCE_TIMEOUT, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(query -> viewModel.query(query, mapPosition))); .subscribe(query -> viewModel.query(query, mapPosition)));
locationDao.getPlaceUsage().observe(this, this::updatePlaces);
} }
private void handleError(Event<String> error) { private void handleError(Event<String> error) {
@ -421,31 +421,27 @@ public class LocationPickerActivity extends InjectingAppCompatActivity
this.places = places; this.places = places;
updateMarkers(); updateMarkers();
recentsAdapter.submitList(places); recentsAdapter.submitList(places);
updateAppbarLayout();
if (places.isEmpty()) {
collapseToolbar();
}
}
private void updateMarkers() {
if (map != null) {
map.setMarkers(newArrayList(transform(places, PlaceUsage::getPlace)));
}
}
private void updateAppbarLayout() {
CoordinatorLayout.LayoutParams params = CoordinatorLayout.LayoutParams params =
(CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams(); (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
if (places.isEmpty()) { int height = coordinatorLayout.getHeight();
params.height = coordinatorLayout.getHeight(); if (this.places.isEmpty()) {
params.height = height;
chooseRecentLocation.setVisibility(View.GONE); chooseRecentLocation.setVisibility(View.GONE);
collapseToolbar();
} else { } else {
params.height = (coordinatorLayout.getHeight() * 75) / 100; params.height = (height * 75) / 100;
chooseRecentLocation.setVisibility(View.VISIBLE); chooseRecentLocation.setVisibility(View.VISIBLE);
} }
} }
private void updateMarkers() {
if (map != null) {
map.setMarkers(newArrayList(transform(places, PlaceUsage::getPlace)));
}
}
private void collapseToolbar() { private void collapseToolbar() {
appBarLayout.setExpanded(true, true); appBarLayout.setExpanded(true, true);
} }

Loading…
Cancel
Save