Use fragments setHasOptionsMenu

Remove complications by allowing android to handle fragment's
options menu.

See https://developer.android.com/guide/components/fragments.html#ActionBar
This commit is contained in:
Coffeemakr 2017-01-19 19:38:33 +01:00
parent 7efd111d9c
commit 8e451b2a83
5 changed files with 6 additions and 16 deletions

View File

@ -52,8 +52,6 @@ public class MainActivity extends AppCompatActivity {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
mainFragment.onCreateOptionsMenu(menu, inflater);
return true;
}
@ -79,8 +77,7 @@ public class MainActivity extends AppCompatActivity {
return true;
}
default:
return mainFragment.onOptionsItemSelected(item) ||
super.onOptionsItemSelected(item);
return super.onOptionsItemSelected(item);
}
}
}

View File

@ -162,19 +162,10 @@ public class VideoItemDetailActivity extends AppCompatActivity {
NavUtils.navigateUpTo(this, intent);
return true;
} else {
return fragment.onOptionsItemSelected(item) ||
super.onOptionsItemSelected(item);
return super.onOptionsItemSelected(item);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
fragment.onCreateOptionsMenu(menu, getMenuInflater());
return true;
}
/**
* Retrieves all Strings which look remotely like URLs from a text.
* Used if NewPipe was called through share menu.

View File

@ -629,6 +629,7 @@ public class VideoItemDetailFragment extends Fragment {
onNotSpecifiedContentError();
}
});
setHasOptionsMenu(true);
}
@Override

View File

@ -273,8 +273,7 @@ public class DownloadActivity extends AppCompatActivity implements AdapterView.O
return true;
}
default:
return mFragment.onOptionsItemSelected(item) ||
super.onOptionsItemSelected(item);
return super.onOptionsItemSelected(item);
}
}
}

View File

@ -160,6 +160,8 @@ public class SearchInfoItemFragment extends Fragment {
}
}
setHasOptionsMenu(true);
SearchWorker sw = SearchWorker.getInstance();
sw.setSearchWorkerResultListener(new SearchWorker.SearchWorkerResultListener() {
@Override