Ola, tenho um aplicativo que utiliza o sistema de fragmentos e um FloatActionButton, em um dos fragmentos eu tenho um banner de anúncio bem embaixo do FloatActionButton, eu fiz da forma abaixo, porém não funciona com os fragmentos na pilha, então, existe algum tipo de listener para identificar qual é o atual fragmento na activity?
//Is Landscape or Portrait
if(isLandscape){
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.frameContainer, gallery);
ft.commit();
}else{
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.containerFrag, main);
ft.commit();
if(findViewById(R.id.fabOpenDownloaderPage).getVisibility() != View.GONE){
findViewById(R.id.fabOpenDownloaderPage).setVisibility(View.GONE);
}
}
PrimaryDrawerItem itemHome = new PrimaryDrawerItem().withName(R.string.navD_item_home).withIcon(R.drawable.ic_home).withIdentifier(ID_HOME_ITEM).withSelectable(false);
PrimaryDrawerItem itemGallery = new PrimaryDrawerItem().withName(R.string.navD_item_gallery).withIcon(R.drawable.ic_movies).withIdentifier(ID_GALLERY_ITEM).withSelectable(false);
PrimaryDrawerItem itemSettings = new PrimaryDrawerItem().withName(R.string.navD_item_settings).withIcon(R.drawable.ic_settings).withIdentifier(ID_SETTINGS_ITEM).withSelectable(false);
SecondaryDrawerItem itemAbout = new SecondaryDrawerItem().withName(R.string.navD_item_about).withIcon(R.drawable.ic_info_outline).withIdentifier(ID_ABOUT_ITEM).withSelectable(false);
Drawer navDrawer = new DrawerBuilder()
.withActivity(this)
.withToolbar(tbMain)
.withTranslucentStatusBar(true)
.withActionBarDrawerToggle(true)
.withActionBarDrawerToggleAnimated(true)
.withSelectedItem(-1)
.addDrawerItems(itemHome, itemGallery, itemSettings, new DividerDrawerItem(), itemAbout)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
switch((int)drawerItem.getIdentifier()){
case (int)ID_HOME_ITEM:
if(!isLandscape){
ft.replace(R.id.containerFrag, main);
ft.addToBackStack(null);
ft.commit();
if(findViewById(R.id.fabOpenDownloaderPage).getVisibility() != View.GONE){
findViewById(R.id.fabOpenDownloaderPage).setVisibility(View.GONE);
}
}
break;
case (int)ID_GALLERY_ITEM:
if(isLandscape){
ft.replace(R.id.frameContainer, gallery);
ft.commit();
}else{
ft.replace(R.id.containerFrag, gallery);
ft.addToBackStack(main.TAG);
ft.commit();
if(findViewById(R.id.fabOpenDownloaderPage).getVisibility() == View.GONE){
findViewById(R.id.fabOpenDownloaderPage).setVisibility(View.VISIBLE);
}
}
break;
case (int)ID_SETTINGS_ITEM:
if(isLandscape){
ft.replace(R.id.frameContainer, settings);
ft.addToBackStack(gallery.TAG);
ft.commit();
}else{
ft.replace(R.id.containerFrag, settings);
ft.addToBackStack(main.TAG);
ft.commit();
if(findViewById(R.id.fabOpenDownloaderPage).getVisibility() != View.GONE){
findViewById(R.id.fabOpenDownloaderPage).setVisibility(View.GONE);
}
}
break;
case (int)ID_ABOUT_ITEM:
if(isLandscape){
ft.replace(R.id.frameContainer, about);
ft.commit();
}else{
ft.replace(R.id.containerFrag, about);
ft.addToBackStack(main.TAG);
ft.commit();
if(findViewById(R.id.fabOpenDownloaderPage).getVisibility() != View.GONE){
findViewById(R.id.fabOpenDownloaderPage).setVisibility(View.GONE);
}
}
break;
}
return false;
}
})
.build();