コード例 #1
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_refresh_directory:
       getLoaderManager().restartLoader(Data.DIRECTORY, Bundle.EMPTY, this);
       return true;
     case R.id.menu_parent:
       openParentDirectory();
       return true;
     case R.id.menu_home:
       mDirectory = mPreferences.getHomeDirectory();
       getLoaderManager().restartLoader(Data.DIRECTORY, Bundle.EMPTY, this);
       return true;
     case R.id.menu_set_home:
       mPreferences.setHomeDirectory(mDirectory);
       showSetHomeToast();
       return true;
     case R.id.menu_size_large:
       mPreferences.setTextSize(Preferences.TEXT_LARGE);
       mAdapter.notifyDataSetChanged();
       return true;
     case R.id.menu_size_medium:
       mPreferences.setTextSize(Preferences.TEXT_MEDIUM);
       mAdapter.notifyDataSetChanged();
       return true;
     case R.id.menu_size_small:
       mPreferences.setTextSize(Preferences.TEXT_SMALL);
       mAdapter.notifyDataSetChanged();
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
コード例 #2
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setHasOptionsMenu(true);
   mPreferences = Preferences.get(getActivity());
   if (savedInstanceState == null) {
     mDirectory = mPreferences.getBrowseDirectory();
   } else {
     mDirectory = savedInstanceState.getString(State.DIRECTORY);
   }
 }
コード例 #3
0
 /** {@inheritDoc} */
 public Loader<Remote<Directory>> onCreateLoader(int id, Bundle args) {
   mPreferences.setBrowseDirectory(mDirectory);
   setEmptyText(getText(R.string.loading));
   return new DirectoryLoader(getActivity(), getMediaServer(), mDirectory);
 }