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:
parent
7efd111d9c
commit
8e451b2a83
|
@ -52,8 +52,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
|
||||||
inflater.inflate(R.menu.main_menu, menu);
|
inflater.inflate(R.menu.main_menu, menu);
|
||||||
|
|
||||||
mainFragment.onCreateOptionsMenu(menu, inflater);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +77,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return mainFragment.onOptionsItemSelected(item) ||
|
return super.onOptionsItemSelected(item);
|
||||||
super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,19 +162,10 @@ public class VideoItemDetailActivity extends AppCompatActivity {
|
||||||
NavUtils.navigateUpTo(this, intent);
|
NavUtils.navigateUpTo(this, intent);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return fragment.onOptionsItemSelected(item) ||
|
return super.onOptionsItemSelected(item);
|
||||||
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.
|
* Retrieves all Strings which look remotely like URLs from a text.
|
||||||
* Used if NewPipe was called through share menu.
|
* Used if NewPipe was called through share menu.
|
||||||
|
|
|
@ -629,6 +629,7 @@ public class VideoItemDetailFragment extends Fragment {
|
||||||
onNotSpecifiedContentError();
|
onNotSpecifiedContentError();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -273,8 +273,7 @@ public class DownloadActivity extends AppCompatActivity implements AdapterView.O
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return mFragment.onOptionsItemSelected(item) ||
|
return super.onOptionsItemSelected(item);
|
||||||
super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,8 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
SearchWorker sw = SearchWorker.getInstance();
|
SearchWorker sw = SearchWorker.getInstance();
|
||||||
sw.setSearchWorkerResultListener(new SearchWorker.SearchWorkerResultListener() {
|
sw.setSearchWorkerResultListener(new SearchWorker.SearchWorkerResultListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue