Fix update of text in menu after removal of static methods

This commit is contained in:
David A. Velasco 2015-12-23 12:22:52 +01:00
parent 337191ff1a
commit 4ec4b66921

View file

@ -88,6 +88,11 @@ public class OCFileListFragment extends ExtendedListFragment
private OCFile mTargetFile;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
/**
* {@inheritDoc}
@ -213,6 +218,11 @@ public class OCFileListFragment extends ExtendedListFragment
outState.putParcelable(KEY_FILE, mFile);
}
@Override
public void onPrepareOptionsMenu (Menu menu) {
changeGridIcon(menu); // this is enough if the option stays out of the action bar
}
/**
* Call this, when the user presses the up button.
*
@ -340,7 +350,6 @@ public class OCFileListFragment extends ExtendedListFragment
// String.format(mContext.getString(R.string.subject_token),
// getClient().getCredentials().getUsername(), file.getFileName()));
changeGridIcon(menu, targetFile);
}
}
@ -640,9 +649,9 @@ public class OCFileListFragment extends ExtendedListFragment
}
}
private void changeGridIcon(ContextMenu menu, OCFile targetFile){
private void changeGridIcon(Menu menu){
MenuItem menuItem = menu.findItem(R.id.action_switch_view);
if (isGridViewPreferred(targetFile)){
if (isGridViewPreferred(mFile)){
menuItem.setTitle(getString(R.string.action_switch_list_view));
menuItem.setIcon(R.drawable.ic_view_list);
} else {