Fix route menu lags
This commit is contained in:
parent
9ada86198c
commit
640b369f66
3 changed files with 11 additions and 27 deletions
|
@ -252,6 +252,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
||||||
ContextThemeWrapper context =
|
ContextThemeWrapper context =
|
||||||
new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
||||||
view = LayoutInflater.from(context).inflate(getMainLayoutId(), container, false);
|
view = LayoutInflater.from(context).inflate(getMainLayoutId(), container, false);
|
||||||
|
initLayout = true;
|
||||||
currentMenuState = getInitialMenuState();
|
currentMenuState = getInitialMenuState();
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
final RoutesPagerAdapter pagerAdapter = new RoutesPagerAdapter(getChildFragmentManager(), routesCount);
|
final RoutesPagerAdapter pagerAdapter = new RoutesPagerAdapter(getChildFragmentManager(), routesCount);
|
||||||
viewPager.setAdapter(pagerAdapter);
|
viewPager.setAdapter(pagerAdapter);
|
||||||
viewPager.setCurrentItem(routeIndex);
|
viewPager.setCurrentItem(routeIndex);
|
||||||
viewPager.setOffscreenPageLimit(routesCount);
|
viewPager.setOffscreenPageLimit(1);
|
||||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
public void onPageScrollStateChanged(int state) {
|
public void onPageScrollStateChanged(int state) {
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
buildPagesControl(view);
|
buildPagesControl(view);
|
||||||
List<WeakReference<RouteDetailsFragment>> routeDetailsFragments = ChooseRouteFragment.this.routeDetailsFragments;
|
List<WeakReference<RouteDetailsFragment>> routeDetailsFragments = ChooseRouteFragment.this.routeDetailsFragments;
|
||||||
|
RouteDetailsFragment current = getCurrentFragment();
|
||||||
for (WeakReference<RouteDetailsFragment> ref : routeDetailsFragments) {
|
for (WeakReference<RouteDetailsFragment> ref : routeDetailsFragments) {
|
||||||
RouteDetailsFragment f = ref.get();
|
RouteDetailsFragment f = ref.get();
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
|
@ -179,10 +180,14 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
card.updateButtons();
|
card.updateButtons();
|
||||||
}
|
}
|
||||||
if (f == getCurrentFragment()) {
|
if (f == current) {
|
||||||
updateZoomButtonsPos(f, f.getViewY(), true);
|
updateZoomButtonsPos(f, f.getViewY(), true);
|
||||||
updatePagesViewPos(f, f.getViewY(), true);
|
updatePagesViewPos(f, f.getViewY(), true);
|
||||||
}
|
}
|
||||||
|
Bundle args = f.getArguments();
|
||||||
|
if (args != null) {
|
||||||
|
args.putInt(ContextMenuFragment.MENU_STATE_KEY, currentMenuState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,10 +328,8 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
pagesView.addView(itemView);
|
pagesView.addView(itemView);
|
||||||
}
|
}
|
||||||
pagesView.requestLayout();
|
pagesView.requestLayout();
|
||||||
pagesView.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
pagesView.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
updatePagesViewVisibility(currentMenuState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,6 +701,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private RouteDetailsFragment getCurrentFragment() {
|
private RouteDetailsFragment getCurrentFragment() {
|
||||||
LockableViewPager viewPager = this.viewPager;
|
LockableViewPager viewPager = this.viewPager;
|
||||||
if (viewPager != null) {
|
if (viewPager != null) {
|
||||||
|
@ -810,7 +814,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
|
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
|
||||||
LockableViewPager viewPager = this.viewPager;
|
LockableViewPager viewPager = this.viewPager;
|
||||||
RouteDetailsFragment current = getCurrentFragment();
|
RouteDetailsFragment current = getCurrentFragment();
|
||||||
if (viewPager != null && current != null && fragment == current) {
|
if (viewPager != null && fragment == current) {
|
||||||
currentMenuState = menuState;
|
currentMenuState = menuState;
|
||||||
List<WeakReference<RouteDetailsFragment>> routeDetailsFragments = this.routeDetailsFragments;
|
List<WeakReference<RouteDetailsFragment>> routeDetailsFragments = this.routeDetailsFragments;
|
||||||
for (WeakReference<RouteDetailsFragment> ref : routeDetailsFragments) {
|
for (WeakReference<RouteDetailsFragment> ref : routeDetailsFragments) {
|
||||||
|
|
|
@ -268,27 +268,6 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setViewY(int y, boolean animated, boolean adjustMapPos) {
|
|
||||||
super.setViewY(y, animated, adjustMapPos);
|
|
||||||
View mainView = getMainView();
|
|
||||||
if (mainView != null && isPortrait()) {
|
|
||||||
LinearLayout cardsContainer = getCardsContainer();
|
|
||||||
View topShadow = getTopShadow();
|
|
||||||
FrameLayout bottomContainer = getBottomContainer();
|
|
||||||
int top = Math.max(getMenuStatePosY(MenuState.HALF_SCREEN), getViewHeight() - getMenuFullHeightMax());
|
|
||||||
if (y > top) {
|
|
||||||
topShadow.setVisibility(View.INVISIBLE);
|
|
||||||
bottomContainer.setBackgroundDrawable(null);
|
|
||||||
AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.drawable.travel_card_bg_light, R.drawable.travel_card_bg_dark);
|
|
||||||
} else {
|
|
||||||
topShadow.setVisibility(View.VISIBLE);
|
|
||||||
AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(), R.color.card_and_list_background_light, R.color.card_and_list_background_dark);
|
|
||||||
AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.color.card_and_list_background_light, R.color.card_and_list_background_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateCards() {
|
private void updateCards() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
|
Loading…
Reference in a new issue