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,9 +63,18 @@ public class MainActivity extends BaseActivity {
@Override @Override
public void onBackPressed() { public void 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))) if (!moveToState(State.ofLayer(state.layer - 1)))
super.onBackPressed(); super.onBackPressed();
} }
}
@Override @Override
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {

View File

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