Merge pull request #10613 from osmandapp/fix_online_routing_ui_p2
Fix online routing UI p2
This commit is contained in:
commit
59f0d08ba5
2 changed files with 19 additions and 4 deletions
|
@ -25,6 +25,8 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
||||||
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener;
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener;
|
||||||
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem;
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem;
|
||||||
|
import net.osmand.plus.onlinerouting.VehicleType;
|
||||||
|
import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
||||||
|
@ -135,14 +137,23 @@ public class OnlineRoutingCard extends BaseCard {
|
||||||
if (callback.processResult(item)) {
|
if (callback.processResult(item)) {
|
||||||
adapter.setSelectedItem(item);
|
adapter.setSelectedItem(item);
|
||||||
}
|
}
|
||||||
|
Object obj = item.getObject();
|
||||||
|
updateBottomMarginSelectionMenu(obj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Object item = adapter.getItemByTitle(selectedItemTitle).getObject();
|
||||||
|
updateBottomMarginSelectionMenu(item);
|
||||||
rvSelectionMenu.setAdapter(adapter);
|
rvSelectionMenu.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateBottomMarginSelectionMenu(int bottomMargin) {
|
private void updateBottomMarginSelectionMenu(Object item) {
|
||||||
|
if (item instanceof VehicleType) {
|
||||||
|
VehicleType vt = (VehicleType) item;
|
||||||
|
boolean hasPadding = vt.equals(OnlineRoutingEngine.CUSTOM_VEHICLE);
|
||||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) rvSelectionMenu.getLayoutParams();
|
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) rvSelectionMenu.getLayoutParams();
|
||||||
params.bottomMargin = bottomMargin;
|
int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||||
|
params.bottomMargin = hasPadding ? contentPadding : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(@NonNull String description) {
|
public void setDescription(@NonNull String description) {
|
||||||
|
|
|
@ -342,7 +342,11 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment {
|
||||||
apiKeyCard.setOnTextChangedListener(new OnTextChangedListener() {
|
apiKeyCard.setOnTextChangedListener(new OnTextChangedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(boolean editedByUser, @NonNull String text) {
|
public void onTextChanged(boolean editedByUser, @NonNull String text) {
|
||||||
|
if (Algorithms.isBlank(text)) {
|
||||||
|
engine.remove(EngineParameter.API_KEY);
|
||||||
|
} else {
|
||||||
engine.put(EngineParameter.API_KEY, text);
|
engine.put(EngineParameter.API_KEY, text);
|
||||||
|
}
|
||||||
updateCardViews(exampleCard);
|
updateCardViews(exampleCard);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue