Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/ActivityPrincipal.java
Show First 20 Lines • Show All 259 Lines • ▼ Show 20 Lines | private void setupDrawerContent(NavigationView navigationView) { | ||||
case PERMISSION_NEG_CANNOT_ASK: | case PERMISSION_NEG_CANNOT_ASK: | ||||
String storage_perm = getString(R.string.storage_permission); | String storage_perm = getString(R.string.storage_permission); | ||||
String text = getString(R.string.too_many_permission_asks, storage_perm); | String text = getString(R.string.too_many_permission_asks, storage_perm); | ||||
Toast.makeText(getApplicationContext(),text, Toast.LENGTH_LONG).show(); | Toast.makeText(getApplicationContext(),text, Toast.LENGTH_LONG).show(); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
//selectDrawerItem(menuItem); | //selectDrawerItem(menuItem); | ||||
Log.d(DEBUG_TAG, "pressed item "+menuItem.toString()); | Log.d(DEBUG_TAG, "pressed item "+menuItem); | ||||
return true; | return true; | ||||
}); | }); | ||||
} | } | ||||
private void closeDrawerIfOpen(){ | private void closeDrawerIfOpen(){ | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | public class ActivityPrincipal extends GeneralActivity implements FragmentListenerMain { | ||||
@Override | @Override | ||||
public void onBackPressed() { | public void onBackPressed() { | ||||
boolean foundFragment = false; | boolean foundFragment = false; | ||||
Fragment shownFrag = getSupportFragmentManager().findFragmentById(R.id.mainActContentFrame); | Fragment shownFrag = getSupportFragmentManager().findFragmentById(R.id.mainActContentFrame); | ||||
if (mDrawer.isDrawerOpen(GravityCompat.START)) | if (mDrawer.isDrawerOpen(GravityCompat.START)) | ||||
mDrawer.closeDrawer(GravityCompat.START); | mDrawer.closeDrawer(GravityCompat.START); | ||||
else if(shownFrag != null && shownFrag.isVisible() && shownFrag.getChildFragmentManager().getBackStackEntryCount() > 0){ | else if(shownFrag != null && shownFrag.isVisible() && shownFrag.getChildFragmentManager().getBackStackEntryCount() > 0){ | ||||
//if we have been asked to show a stop from another fragment, we should go back even in the main | //if we have been asked to show a stop from another fragment, we should go back even in the main | ||||
if(shownFrag instanceof MainScreenFragment){ | |||||
//we have to stop the arrivals reload | |||||
((MainScreenFragment) shownFrag).cancelReloadArrivalsIfNeeded(); | |||||
} | |||||
shownFrag.getChildFragmentManager().popBackStackImmediate(); | shownFrag.getChildFragmentManager().popBackStackImmediate(); | ||||
if(showingMainFragmentFromOther && getSupportFragmentManager().getBackStackEntryCount() > 0){ | if(showingMainFragmentFromOther && getSupportFragmentManager().getBackStackEntryCount() > 0){ | ||||
getSupportFragmentManager().popBackStack(); | getSupportFragmentManager().popBackStack(); | ||||
} | } | ||||
} | } | ||||
else if (getSupportFragmentManager().getBackStackEntryCount() > 0) { | else if (getSupportFragmentManager().getBackStackEntryCount() > 0) { | ||||
getSupportFragmentManager().popBackStack(); | getSupportFragmentManager().popBackStack(); | ||||
} | } | ||||
Show All 36 Lines | private static void showMainFragment(FragmentManager fraMan, MainScreenFragment fragment){ | ||||
)*/ | )*/ | ||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) | .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) | ||||
.commit(); | .commit(); | ||||
} | } | ||||
private MainScreenFragment showMainFragment(){ | private MainScreenFragment showMainFragment(){ | ||||
FragmentManager fraMan = getSupportFragmentManager(); | FragmentManager fraMan = getSupportFragmentManager(); | ||||
Fragment fragment = fraMan.findFragmentByTag(MainScreenFragment.FRAGMENT_TAG); | Fragment fragment = fraMan.findFragmentByTag(MainScreenFragment.FRAGMENT_TAG); | ||||
MainScreenFragment mainScreenFragment = null; | final MainScreenFragment mainScreenFragment; | ||||
if (fragment==null | !(fragment instanceof MainScreenFragment)){ | if (fragment==null | !(fragment instanceof MainScreenFragment)){ | ||||
mainScreenFragment = createAndShowMainFragment(); | mainScreenFragment = createAndShowMainFragment(); | ||||
} | } | ||||
else if(!fragment.isVisible()){ | else if(!fragment.isVisible()){ | ||||
mainScreenFragment = (MainScreenFragment) fragment; | mainScreenFragment = (MainScreenFragment) fragment; | ||||
showMainFragment(fraMan, mainScreenFragment); | showMainFragment(fraMan, mainScreenFragment); | ||||
▲ Show 20 Lines • Show All 156 Lines • Show Last 20 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register