Initialize Loader via Navigation Drawer

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Regex - How to capture all iterations of a repeating pattern?