Initialize Loader via Navigation Drawer

Multi tool use


Initialize Loader via Navigation Drawer
I want to change the news section using a Navigation Drawer
. I want to reinitialize the loader whenever I click on an item in the Navigation Drawer
. But I can’t find the right way. I tried to make use of the Activity Lifecycle, but I can't find the right way.
Navigation Drawer
Navigation Drawer
and Here's a portion of the code:
this method is invoked when I click on an item in the Navigation Drawer
Navigation Drawer
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.headlines: {
section = null;
}
break;
case R.id.world: {
section = "world";
}
break;
case R.id.business: {
section = "business";
}
break;
case R.id.community: {
section = "community";
}
break;
case R.id.sport: {
section = "sport";
}
break;
case R.id.art: {
section = "artanddesign";
}
break;
case R.id.culture: {
section = "culture";
}
break;
default:
section = "culture";
break;
}
item.setChecked(true);
mDrawerLayout.closeDrawers();
return true;
}
@Override
protected void onResume() {
if (isConnected(this)) {
getLoaderManager().initLoader(0, null, this).forceLoad();
} else {
emptyStateView.setText(R.string.no_internet);
loadingIndicator.setVisibility(View.GONE);
}
super.onResume();
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.