forked from organicmaps/organicmaps
[android] fix: Correct menu height on navigation state changed.
This commit is contained in:
parent
cacab2d7c6
commit
274b5dad55
3 changed files with 62 additions and 40 deletions
|
@ -147,10 +147,8 @@ public class RoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
listView.setAdapter(buildAdapter());
|
||||
listView.setChildDivider(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
|
||||
|
||||
ViewTreeObserver observer = listView.getViewTreeObserver();
|
||||
observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
|
||||
UiUtils.waitLayout(listView, new ViewTreeObserver.OnGlobalLayoutListener()
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onGlobalLayout()
|
||||
{
|
||||
|
@ -161,12 +159,6 @@ public class RoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
listView.setIndicatorBounds(width - indicatorWidth, width);
|
||||
else
|
||||
listView.setIndicatorBoundsRelative(width - indicatorWidth, width);
|
||||
|
||||
final ViewTreeObserver treeObserver = listView.getViewTreeObserver();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
|
||||
treeObserver.removeGlobalOnLayoutListener(this);
|
||||
else
|
||||
treeObserver.removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -281,7 +281,8 @@ public class MainMenu
|
|||
if (mLayoutCorrected)
|
||||
return;
|
||||
|
||||
mContentFrame.post(new Runnable() {
|
||||
mContentFrame.post(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
@ -390,6 +391,12 @@ public class MainMenu
|
|||
UiUtils.showIf(navigation, mNavigationFrame,
|
||||
mItemViews.get(Item.SEARCH),
|
||||
mItemViews.get(Item.BOOKMARKS));
|
||||
if (mLayoutCorrected)
|
||||
{
|
||||
mContentFrame.measure(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
mContentHeight = mContentFrame.getMeasuredHeight();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
|
|
|
@ -16,12 +16,14 @@ import android.os.Build;
|
|||
import android.provider.Settings;
|
||||
import android.support.annotation.DimenRes;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.AnimationUtils;
|
||||
|
@ -37,6 +39,57 @@ public final class UiUtils
|
|||
private static float sScreenDensity;
|
||||
|
||||
|
||||
public static class SimpleAnimationListener implements AnimationListener
|
||||
{
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation)
|
||||
{}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation)
|
||||
{}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation)
|
||||
{}
|
||||
}
|
||||
|
||||
|
||||
public static class SimpleNineoldAnimationListener implements Animator.AnimatorListener
|
||||
{
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {}
|
||||
}
|
||||
|
||||
|
||||
public static void waitLayout(View view, @NonNull final ViewTreeObserver.OnGlobalLayoutListener callback)
|
||||
{
|
||||
final ViewTreeObserver observer = view.getViewTreeObserver();
|
||||
observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onGlobalLayout()
|
||||
{
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
|
||||
observer.removeGlobalOnLayoutListener(this);
|
||||
else
|
||||
observer.removeOnGlobalLayoutListener(this);
|
||||
|
||||
callback.onGlobalLayout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void hide(View view)
|
||||
{
|
||||
view.setVisibility(View.GONE);
|
||||
|
@ -142,36 +195,6 @@ public final class UiUtils
|
|||
return new BitmapDrawable(res, bmp);
|
||||
}
|
||||
|
||||
public static class SimpleAnimationListener implements AnimationListener
|
||||
{
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation)
|
||||
{}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation)
|
||||
{}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation)
|
||||
{}
|
||||
}
|
||||
|
||||
public static class SimpleNineoldAnimationListener implements Animator.AnimatorListener
|
||||
{
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {}
|
||||
}
|
||||
|
||||
public static TextView setTextAndShow(TextView tv, CharSequence text)
|
||||
{
|
||||
checkNotNull(tv);
|
||||
|
|
Loading…
Add table
Reference in a new issue