Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/ActivityPrincipal.java
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
import com.google.android.material.snackbar.Snackbar; | import com.google.android.material.snackbar.Snackbar; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||
import it.reyboz.bustorino.backend.Stop; | import it.reyboz.bustorino.backend.Stop; | ||||
import it.reyboz.bustorino.data.DBUpdateWorker; | import it.reyboz.bustorino.data.DBUpdateWorker; | ||||
import it.reyboz.bustorino.data.DatabaseUpdate; | import it.reyboz.bustorino.data.DatabaseUpdate; | ||||
import it.reyboz.bustorino.fragments.FavoritesFragment; | import it.reyboz.bustorino.fragments.*; | ||||
import it.reyboz.bustorino.fragments.FragmentKind; | |||||
import it.reyboz.bustorino.fragments.FragmentListenerMain; | |||||
import it.reyboz.bustorino.fragments.MainScreenFragment; | |||||
import it.reyboz.bustorino.fragments.MapFragment; | |||||
import it.reyboz.bustorino.middleware.GeneralActivity; | import it.reyboz.bustorino.middleware.GeneralActivity; | ||||
import static it.reyboz.bustorino.backend.utils.getBusStopIDFromUri; | import static it.reyboz.bustorino.backend.utils.getBusStopIDFromUri; | ||||
import static it.reyboz.bustorino.backend.utils.openIceweasel; | import static it.reyboz.bustorino.backend.utils.openIceweasel; | ||||
public class ActivityPrincipal extends GeneralActivity implements FragmentListenerMain { | public class ActivityPrincipal extends GeneralActivity implements FragmentListenerMain { | ||||
private DrawerLayout mDrawer; | private DrawerLayout mDrawer; | ||||
private NavigationView mNavView; | private NavigationView mNavView; | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | protected void onCreate(@Nullable Bundle savedInstanceState) { | ||||
} | } | ||||
// Intercept calls from other activities | // Intercept calls from other activities | ||||
if (!tryedFromIntent) { | if (!tryedFromIntent) { | ||||
Bundle b = getIntent().getExtras(); | Bundle b = getIntent().getExtras(); | ||||
if (b != null) { | if (b != null) { | ||||
busStopID = b.getString("bus-stop-ID"); | busStopID = b.getString("bus-stop-ID"); | ||||
/** | /* | ||||
* I'm not very sure if you are coming from an Intent. | * I'm not very sure if you are coming from an Intent. | ||||
* Some launchers work in strange ways. | * Some launchers work in strange ways. | ||||
*/ | */ | ||||
tryedFromIntent = busStopID != null; | tryedFromIntent = busStopID != null; | ||||
} | } | ||||
} | } | ||||
//---------------------------- END INTENT CHECK QUEUE -------------------------------------- | //---------------------------- END INTENT CHECK QUEUE -------------------------------------- | ||||
▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | public void onBackPressed() { | ||||
} | } | ||||
else if (getSupportFragmentManager().getBackStackEntryCount() > 0) { | else if (getSupportFragmentManager().getBackStackEntryCount() > 0) { | ||||
getSupportFragmentManager().popBackStack(); | getSupportFragmentManager().popBackStack(); | ||||
} | } | ||||
else | else | ||||
super.onBackPressed(); | super.onBackPressed(); | ||||
} | } | ||||
/** | |||||
* Create and show the SnackBar with the message | |||||
*/ | |||||
private void createDefaultSnackbar() { | private void createDefaultSnackbar() { | ||||
if (snackbar == null) { | |||||
snackbar = Snackbar.make(findViewById(R.id.searchButton), R.string.database_update_message, Snackbar.LENGTH_INDEFINITE); | View baseView = null; | ||||
} | final Fragment frag = getSupportFragmentManager().findFragmentById(R.id.mainActContentFrame); | ||||
if (frag instanceof ScreenBaseFragment){ | |||||
baseView = ((ScreenBaseFragment) frag).getBaseViewForSnackBar(); | |||||
} | |||||
if (baseView == null) baseView = findViewById(R.id.mainActContentFrame); | |||||
if (baseView == null) Log.e(DEBUG_TAG, "baseView null for default snackbar, probably exploding now"); | |||||
snackbar = Snackbar.make(baseView, R.string.database_update_message, Snackbar.LENGTH_INDEFINITE); | |||||
snackbar.show(); | snackbar.show(); | ||||
} | } | ||||
private MainScreenFragment createAndShowMainFragment(){ | private MainScreenFragment createAndShowMainFragment(){ | ||||
FragmentManager fraMan = getSupportFragmentManager(); | FragmentManager fraMan = getSupportFragmentManager(); | ||||
MainScreenFragment fragment = MainScreenFragment.newInstance(); | MainScreenFragment fragment = MainScreenFragment.newInstance(); | ||||
▲ Show 20 Lines • Show All 195 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