Small fixes

This commit is contained in:
Vitaliy 2021-01-24 22:12:10 +02:00
parent cf943edc98
commit f3f2345371
2 changed files with 60 additions and 67 deletions

View file

@ -12,7 +12,6 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.ViewTreeObserver.OnScrollChangedListener; import android.view.ViewTreeObserver.OnScrollChangedListener;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@ -44,9 +43,9 @@ import net.osmand.plus.onlinerouting.OnlineRoutingFactory;
import net.osmand.plus.onlinerouting.OnlineRoutingHelper; import net.osmand.plus.onlinerouting.OnlineRoutingHelper;
import net.osmand.plus.onlinerouting.OnlineRoutingUtils; import net.osmand.plus.onlinerouting.OnlineRoutingUtils;
import net.osmand.plus.onlinerouting.VehicleType; import net.osmand.plus.onlinerouting.VehicleType;
import net.osmand.plus.onlinerouting.ui.OnlineRoutingCard.OnTextChangedListener;
import net.osmand.plus.onlinerouting.engine.EngineType; import net.osmand.plus.onlinerouting.engine.EngineType;
import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine; import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine;
import net.osmand.plus.onlinerouting.ui.OnlineRoutingCard.OnTextChangedListener;
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.util.Algorithms; import net.osmand.util.Algorithms;
@ -703,26 +702,17 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment {
} }
private void showShadowBelowButtons() { private void showShadowBelowButtons() {
if (onScroll != null) { scrollView.getViewTreeObserver().addOnScrollChangedListener(getShowShadowOnScrollListener());
scrollView.getViewTreeObserver().addOnScrollChangedListener(onScroll);
} else {
initShowShadowOnScrollListener();
showShadowBelowButtons();
}
} }
private void showButtonsAboveKeyboard() { private void showButtonsAboveKeyboard() {
if (onGlobalLayout != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayout); view.getViewTreeObserver().addOnGlobalLayoutListener(getShowButtonsOnGlobalListener());
}
} else {
initShowButtonsOnGlobalListener();
showButtonsAboveKeyboard();
} }
} }
private void initShowShadowOnScrollListener() { private OnScrollChangedListener getShowShadowOnScrollListener() {
if (onScroll == null) {
onScroll = new OnScrollChangedListener() { onScroll = new OnScrollChangedListener() {
@Override @Override
public void onScrollChanged() { public void onScrollChanged() {
@ -735,9 +725,12 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment {
} }
}; };
} }
return onScroll;
}
private void initShowButtonsOnGlobalListener() { private OnGlobalLayoutListener getShowButtonsOnGlobalListener() {
onGlobalLayout = new ViewTreeObserver.OnGlobalLayoutListener() { if (onGlobalLayout == null) {
onGlobalLayout = new OnGlobalLayoutListener() {
private int layoutHeightPrevious; private int layoutHeightPrevious;
private int layoutHeightMin; private int layoutHeightMin;
@ -770,23 +763,24 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment {
view.post(new Runnable() { view.post(new Runnable() {
@Override @Override
public void run() { public void run() {
view.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayout); view.getViewTreeObserver().addOnGlobalLayoutListener(getShowButtonsOnGlobalListener());
} }
}); });
} }
}; };
} }
return onGlobalLayout;
}
private void removeOnScrollListener() { private void removeOnScrollListener() {
scrollView.getViewTreeObserver().removeOnScrollChangedListener(onScroll); scrollView.getViewTreeObserver().removeOnScrollChangedListener(getShowShadowOnScrollListener());
} }
private void removeOnGlobalLayoutListener() { private void removeOnGlobalLayoutListener() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayout); view.getViewTreeObserver().removeOnGlobalLayoutListener(getShowButtonsOnGlobalListener());
} else { } else {
view.getViewTreeObserver().removeGlobalOnLayoutListener(onGlobalLayout); view.getViewTreeObserver().removeGlobalOnLayoutListener(getShowButtonsOnGlobalListener());
} }
} }

View file

@ -29,5 +29,4 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
int paddingH = getResources().getDimensionPixelSize(R.dimen.route_info_card_details_margin); int paddingH = getResources().getDimensionPixelSize(R.dimen.route_info_card_details_margin);
inputLayout.setPadding(0, paddingH, 0, paddingH); inputLayout.setPadding(0, paddingH, 0, paddingH);
} }
} }