1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-22 04:12:08 +01:00

Fixed top/bottom menu entry population

This commit is contained in:
vanitasvitae 2016-09-29 19:44:42 +02:00
parent ae26ecd112
commit 850f759cde
2 changed files with 15 additions and 9 deletions

View file

@ -192,7 +192,6 @@ public class MainActivity extends AppCompatActivity
// Setup toolbar // Setup toolbar
setSupportActionBar(toolbarTop); setSupportActionBar(toolbarTop);
getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
toolbarBottom.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() { toolbarBottom.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
CustomFragment top = getTopFragment(); CustomFragment top = getTopFragment();
@ -274,14 +273,14 @@ public class MainActivity extends AppCompatActivity
* @param fragment Fragment to show * @param fragment Fragment to show
*/ */
protected void showFragment(CustomFragment fragment) { protected void showFragment(CustomFragment fragment) {
AppLog.d(this, "showFragment()"); AppLog.v(this, "showFragment()");
CustomFragment currentTop = (CustomFragment) fm.findFragmentById(R.id.fragment_container); CustomFragment currentTop = (CustomFragment) fm.findFragmentById(R.id.fragment_container);
if(currentTop == null || !currentTop.getFragmentTag().equals(fragment.getFragmentTag())) { if(currentTop == null || !currentTop.getFragmentTag().equals(fragment.getFragmentTag())) {
AppLog.d(this, "Fragment was not visible. Replace it."); AppLog.v(this, "Fragment was not visible. Replace it.");
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit(); fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
fragment.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater()); invalidateOptionsMenu();
} else { } else {
AppLog.d(this, "Fragment was already visible. Do nothing."); AppLog.v(this, "Fragment was already visible. Do nothing.");
} }
} }
@ -427,7 +426,7 @@ public class MainActivity extends AppCompatActivity
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
AppLog.d(this, "onActivityResult(): "+requestCode); AppLog.v(this, "onActivityResult(): "+requestCode);
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
} }
@ -463,7 +462,7 @@ public class MainActivity extends AppCompatActivity
AppLog.v(this, "Top Fragment is not null"); AppLog.v(this, "Top Fragment is not null");
if(!top.onBackPressed()) { if(!top.onBackPressed()) {
AppLog.v(this, "Top Fragment.onBackPressed was false"); AppLog.v(this, "Top Fragment.onBackPressed was false");
AppLog.d(this, "BackStackEntryCount: "+fm.getBackStackEntryCount()); AppLog.v(this, "BackStackEntryCount: "+fm.getBackStackEntryCount());
if(fm.getBackStackEntryCount()>0) { if(fm.getBackStackEntryCount()>0) {
fm.popBackStack(); fm.popBackStack();
} else { } else {
@ -514,7 +513,14 @@ public class MainActivity extends AppCompatActivity
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
AppLog.v(this, "onCreateOptionsMenu()"); AppLog.v(this, "onCreateOptionsMenu()");
menu.clear();
getMenuInflater().inflate(R.menu.main__menu_top, menu); getMenuInflater().inflate(R.menu.main__menu_top, menu);
toolbarBottom.getMenu().clear();
getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
CustomFragment top = getTopFragment();
if(top != null) {
top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater());
}
return true; return true;
} }

View file

@ -85,7 +85,7 @@ public class DiasporaStreamFragment extends BrowserFragment {
switch (requestCode) { switch (requestCode) {
case MainActivity.INPUT_FILE_REQUEST_CODE_NEW: case MainActivity.INPUT_FILE_REQUEST_CODE_NEW:
case MainActivity.INPUT_FILE_REQUEST_CODE_OLD: case MainActivity.INPUT_FILE_REQUEST_CODE_OLD:
AppLog.d(this, "INPUT_FILE_REQUEST_CODE: "+requestCode); AppLog.v(this, "INPUT_FILE_REQUEST_CODE: "+requestCode);
onImageUploadResult(requestCode, resultCode, data); onImageUploadResult(requestCode, resultCode, data);
return; return;
} }
@ -243,7 +243,7 @@ public class DiasporaStreamFragment extends BrowserFragment {
return false; return false;
} }
} }
AppLog.d(this, "onOpenFileChooser"); AppLog.v(this, "onOpenFileChooser");
if (imageUploadFilePathCallbackNew != null) imageUploadFilePathCallbackNew.onReceiveValue(null); if (imageUploadFilePathCallbackNew != null) imageUploadFilePathCallbackNew.onReceiveValue(null);
imageUploadFilePathCallbackNew = filePathCallback; imageUploadFilePathCallbackNew = filePathCallback;
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);