Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/fragments/MainScreenFragment.java
Show All 36 Lines | |||||
import android.widget.Toast; | import android.widget.Toast; | ||||
import com.google.android.material.floatingactionbutton.FloatingActionButton; | import com.google.android.material.floatingactionbutton.FloatingActionButton; | ||||
import com.google.zxing.integration.android.IntentIntegrator; | import com.google.zxing.integration.android.IntentIntegrator; | ||||
import java.util.Map; | import java.util.Map; | ||||
import it.reyboz.bustorino.R; | import it.reyboz.bustorino.R; | ||||
import it.reyboz.bustorino.backend.ArrivalsFetcher; | import it.reyboz.bustorino.backend.*; | ||||
import it.reyboz.bustorino.backend.FiveTAPIFetcher; | |||||
import it.reyboz.bustorino.backend.FiveTScraperFetcher; | |||||
import it.reyboz.bustorino.backend.FiveTStopsFetcher; | |||||
import it.reyboz.bustorino.backend.GTTJSONFetcher; | |||||
import it.reyboz.bustorino.backend.GTTStopsFetcher; | |||||
import it.reyboz.bustorino.backend.Palina; | |||||
import it.reyboz.bustorino.backend.StopsFinderByName; | |||||
import it.reyboz.bustorino.middleware.AppLocationManager; | import it.reyboz.bustorino.middleware.AppLocationManager; | ||||
import it.reyboz.bustorino.middleware.AsyncDataDownload; | import it.reyboz.bustorino.middleware.AsyncDataDownload; | ||||
import it.reyboz.bustorino.util.LocationCriteria; | import it.reyboz.bustorino.util.LocationCriteria; | ||||
import it.reyboz.bustorino.util.Permissions; | import it.reyboz.bustorino.util.Permissions; | ||||
import static it.reyboz.bustorino.util.Permissions.LOCATION_PERMISSIONS; | import static it.reyboz.bustorino.util.Permissions.LOCATION_PERMISSIONS; | ||||
import static it.reyboz.bustorino.util.Permissions.LOCATION_PERMISSION_GIVEN; | import static it.reyboz.bustorino.util.Permissions.LOCATION_PERMISSION_GIVEN; | ||||
▲ Show 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | public class MainScreenFragment extends BaseFragment implements FragmentListenerMain{ | ||||
} | } | ||||
@Override | @Override | ||||
public void onSaveInstanceState(@NonNull Bundle outState) { | public void onSaveInstanceState(@NonNull Bundle outState) { | ||||
super.onSaveInstanceState(outState); | super.onSaveInstanceState(outState); | ||||
Fragment fragment = getChildFragmentManager().findFragmentById(R.id.resultFrame); | Fragment fragment = getChildFragmentManager().findFragmentById(R.id.resultFrame); | ||||
if (fragment!=null) | if (fragment!=null) | ||||
getChildFragmentManager().putFragment(outState, SAVED_FRAGMENT, fragment); | getChildFragmentManager().putFragment(outState, SAVED_FRAGMENT, fragment); | ||||
fragmentHelper.setBlockAllActivities(true); | |||||
} | } | ||||
public void setSuppressArrivalsReload(boolean value){ | public void setSuppressArrivalsReload(boolean value){ | ||||
suppressArrivalsReload = value; | suppressArrivalsReload = value; | ||||
// we have to suppress the reloading of the (possible) ArrivalsFragment | // we have to suppress the reloading of the (possible) ArrivalsFragment | ||||
/*if(value) { | /*if(value) { | ||||
Fragment fragment = getChildFragmentManager().findFragmentById(R.id.resultFrame); | Fragment fragment = getChildFragmentManager().findFragmentById(R.id.resultFrame); | ||||
if (fragment instanceof ArrivalsFragment) { | if (fragment instanceof ArrivalsFragment) { | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | public void onResume() { | ||||
} | } | ||||
suppressArrivalsReload = false; | suppressArrivalsReload = false; | ||||
} | } | ||||
if(pendingStopID!=null){ | if(pendingStopID!=null){ | ||||
requestArrivalsForStopID(pendingStopID); | requestArrivalsForStopID(pendingStopID); | ||||
pendingStopID = null; | pendingStopID = null; | ||||
} | } | ||||
mListener.readyGUIfor(FragmentKind.MAIN_SCREEN_FRAGMENT); | mListener.readyGUIfor(FragmentKind.MAIN_SCREEN_FRAGMENT); | ||||
fragmentHelper.setBlockAllActivities(false); | |||||
} | } | ||||
@Override | @Override | ||||
public void onPause() { | public void onPause() { | ||||
//mainHandler = null; | //mainHandler = null; | ||||
locationManager.removeLocationRequestFor(requester); | locationManager.removeLocationRequestFor(requester); | ||||
super.onPause(); | super.onPause(); | ||||
fragmentHelper.setBlockAllActivities(true); | |||||
fragmentHelper.stopLastRequestIfNeeded(); | |||||
} | } | ||||
/* | /* | ||||
GUI METHODS | GUI METHODS | ||||
*/ | */ | ||||
/** | /** | ||||
* QR scan button clicked | * QR scan button clicked | ||||
* | * | ||||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | public void readyGUIfor(FragmentKind fragmentType) { | ||||
Log.d(DEBUG_TAG, "Fragment type is unknown"); | Log.d(DEBUG_TAG, "Fragment type is unknown"); | ||||
return; | return; | ||||
} | } | ||||
// Shows hints | // Shows hints | ||||
} | } | ||||
@Override | |||||
public void showMapCenteredOnStop(Stop stop) { | |||||
if(mListener!=null) mListener.showMapCenteredOnStop(stop); | |||||
} | |||||
/** | /** | ||||
* Main method for stops requests | * Main method for stops requests | ||||
* @param ID the Stop ID | * @param ID the Stop ID | ||||
*/ | */ | ||||
@Override | @Override | ||||
public void requestArrivalsForStopID(String ID) { | public void requestArrivalsForStopID(String ID) { | ||||
if (!isResumed()){ | if (!isResumed()){ | ||||
//defer request | //defer request | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | class NearbyStopsRequester implements Runnable { | ||||
} else if(!haveProviders){ | } else if(!haveProviders){ | ||||
Log.e(DEBUG_TAG, "NO PROVIDERS FOR POSITION"); | Log.e(DEBUG_TAG, "NO PROVIDERS FOR POSITION"); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
No newline at end of file | No newline at end of file |
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