Remove unnecessary field; add small fixes
This commit is contained in:
parent
2492b3aaa5
commit
918dc831fa
1 changed files with 15 additions and 21 deletions
|
@ -62,8 +62,6 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
|
|
||||||
private boolean lightTheme;
|
private boolean lightTheme;
|
||||||
|
|
||||||
private boolean optionsMenuVisible;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -79,10 +77,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
return new Dialog(getActivity(), getTheme()) {
|
return new Dialog(getActivity(), getTheme()) {
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (optionsMenuVisible) {
|
if (!dismissOptionsMenuFragment()) {
|
||||||
restoreSelectedNavItem();
|
|
||||||
dismissOptionsMenuFragment();
|
|
||||||
} else {
|
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +117,6 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
FragmentManager fragmentManager = getChildFragmentManager();
|
FragmentManager fragmentManager = getChildFragmentManager();
|
||||||
Fragment optionsFragment = fragmentManager.findFragmentByTag(OptionsBottomSheetDialogFragment.TAG);
|
Fragment optionsFragment = fragmentManager.findFragmentByTag(OptionsBottomSheetDialogFragment.TAG);
|
||||||
if (optionsFragment != null) {
|
if (optionsFragment != null) {
|
||||||
optionsMenuVisible = true;
|
|
||||||
((OptionsBottomSheetDialogFragment) optionsFragment).setListener(createOptionsFragmentListener());
|
((OptionsBottomSheetDialogFragment) optionsFragment).setListener(createOptionsFragmentListener());
|
||||||
}
|
}
|
||||||
Fragment directionIndicationFragment = fragmentManager.findFragmentByTag(DirectionIndicationDialogFragment.TAG);
|
Fragment directionIndicationFragment = fragmentManager.findFragmentByTag(DirectionIndicationDialogFragment.TAG);
|
||||||
|
@ -194,17 +188,20 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
setupActiveFragment(HISTORY_MARKERS_POSITION);
|
setupActiveFragment(HISTORY_MARKERS_POSITION);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_more:
|
case R.id.action_more:
|
||||||
if (optionsMenuVisible) {
|
showOptionsMenuFragment();
|
||||||
restoreSelectedNavItem();
|
|
||||||
dismissOptionsMenuFragment();
|
|
||||||
} else {
|
|
||||||
showOptionsMenuFragment();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
bottomNav.setOnNavigationItemReselectedListener(new BottomNavigationView.OnNavigationItemReselectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onNavigationItemReselected(@NonNull MenuItem menuItem) {
|
||||||
|
if (menuItem.getItemId() == R.id.action_more) {
|
||||||
|
dismissOptionsMenuFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
@ -223,9 +220,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupActiveFragment(int position) {
|
private void setupActiveFragment(int position) {
|
||||||
if (optionsMenuVisible) {
|
dismissOptionsMenuFragment();
|
||||||
dismissOptionsMenuFragment();
|
|
||||||
}
|
|
||||||
if (viewPager.getCurrentItem() != position) {
|
if (viewPager.getCurrentItem() != position) {
|
||||||
hideSnackbar();
|
hideSnackbar();
|
||||||
switch (position) {
|
switch (position) {
|
||||||
|
@ -278,15 +273,15 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
getChildFragmentManager().beginTransaction()
|
getChildFragmentManager().beginTransaction()
|
||||||
.add(R.id.menu_container, fragment, OptionsBottomSheetDialogFragment.TAG)
|
.add(R.id.menu_container, fragment, OptionsBottomSheetDialogFragment.TAG)
|
||||||
.commitAllowingStateLoss();
|
.commitAllowingStateLoss();
|
||||||
optionsMenuVisible = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dismissOptionsMenuFragment() {
|
private boolean dismissOptionsMenuFragment() {
|
||||||
Fragment optionsMenu = getChildFragmentManager().findFragmentByTag(OptionsBottomSheetDialogFragment.TAG);
|
Fragment optionsMenu = getChildFragmentManager().findFragmentByTag(OptionsBottomSheetDialogFragment.TAG);
|
||||||
if (optionsMenu != null) {
|
if (optionsMenu != null) {
|
||||||
((DialogFragment) optionsMenu).dismiss();
|
((DialogFragment) optionsMenu).dismiss();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
optionsMenuVisible = false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreSelectedNavItem() {
|
private void restoreSelectedNavItem() {
|
||||||
|
@ -304,7 +299,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (id != -1) {
|
if (id != -1) {
|
||||||
bottomNav.setSelectedItemId(id);
|
bottomNav.getMenu().findItem(id).setChecked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,7 +395,6 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
optionsMenuVisible = false;
|
|
||||||
restoreSelectedNavItem();
|
restoreSelectedNavItem();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue