wg: Collapse fab when pressing back before exiting

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2018-04-27 23:50:11 +05:30
parent f1fa46829d
commit f9d68185e2
2 changed files with 19 additions and 2 deletions

View File

@ -63,8 +63,17 @@ public class MainActivity extends BaseActivity {
@Override
public void onBackPressed() {
if (!moveToState(State.ofLayer(state.layer - 1)))
super.onBackPressed();
TunnelListFragment fragment = null;
try {
fragment =
((TunnelListFragment)
getSupportFragmentManager().getFragments().get(0));
} catch (ClassCastException ignored) {
}
if (fragment == null || !(fragment.collapseActionMenu())) {
if (!moveToState(State.ofLayer(state.layer - 1)))
super.onBackPressed();
}
}
@Override

View File

@ -193,6 +193,14 @@ public class TunnelListFragment extends BaseFragment {
super.onDestroyView();
}
public boolean collapseActionMenu() {
if (binding.createMenu.isExpanded()) {
binding.createMenu.collapse();
return true;
}
return false;
}
public void onRequestCreateConfig(@SuppressWarnings("unused") final View view) {
startActivity(new Intent(getActivity(), TunnelCreatorActivity.class));
if (binding != null)