1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-25 05:42:10 +01:00

forward clicks on bottom toolbar to fragments onOptionsItemSelected

This commit is contained in:
vanitasvitae 2016-09-22 00:54:32 +02:00
parent 179fb3e741
commit a1ca8596b8
2 changed files with 14 additions and 1 deletions

View file

@ -188,7 +188,8 @@ public class MainActivity extends AppCompatActivity
getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
toolbarBottom.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
return MainActivity.this.onOptionsItemSelected(item);
CustomFragment topFrag = (CustomFragment) getTopFragment();
return MainActivity.this.onOptionsItemSelected(item) || (topFrag != null && topFrag.onOptionsItemSelected(item));
}
});
setTitle(R.string.app_name);

View file

@ -1,5 +1,6 @@
package com.github.dfa.diaspora_android.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Menu;
import android.view.MenuInflater;
@ -10,6 +11,17 @@ import android.view.MenuInflater;
*/
public abstract class CustomFragment extends Fragment {
/**
* We have an optionsMenu
* @param savedInstanceState state
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
/**
* Return the tag used to identify the Fragment.
* @return tag