Changeset View
Changeset View
Standalone View
Standalone View
app/src/main/java/it/reyboz/bustorino/fragments/NearbyStopsFragment.java
| Show All 11 Lines | BusTO - Fragments components | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| GNU General Public License for more details. | GNU General Public License for more details. | ||||
| You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | ||||
| along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
| */ | */ | ||||
| package it.reyboz.bustorino.fragments; | package it.reyboz.bustorino.fragments; | ||||
| import android.annotation.SuppressLint; | |||||
| import android.content.Context; | import android.content.Context; | ||||
| import android.content.SharedPreferences; | import android.content.SharedPreferences; | ||||
| import android.location.Location; | import android.location.Location; | ||||
| import android.location.LocationManager; | |||||
| import android.os.Bundle; | import android.os.Bundle; | ||||
| import androidx.activity.result.ActivityResultLauncher; | |||||
| import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
| import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
| import androidx.core.location.LocationListenerCompat; | |||||
| import androidx.core.location.LocationManagerCompat; | |||||
| import androidx.fragment.app.Fragment; | import androidx.fragment.app.Fragment; | ||||
| import androidx.lifecycle.Observer; | import androidx.lifecycle.Observer; | ||||
| import androidx.lifecycle.ViewModelProvider; | import androidx.lifecycle.ViewModelProvider; | ||||
| import androidx.core.util.Pair; | import androidx.core.util.Pair; | ||||
| import androidx.preference.PreferenceManager; | import androidx.preference.PreferenceManager; | ||||
| import androidx.appcompat.widget.AppCompatButton; | import androidx.appcompat.widget.AppCompatButton; | ||||
| import androidx.recyclerview.widget.RecyclerView; | import androidx.recyclerview.widget.RecyclerView; | ||||
| import androidx.work.WorkInfo; | import androidx.work.WorkInfo; | ||||
| Show All 9 Lines | |||||
| import it.reyboz.bustorino.R; | import it.reyboz.bustorino.R; | ||||
| import it.reyboz.bustorino.adapters.ArrivalsStopAdapter; | import it.reyboz.bustorino.adapters.ArrivalsStopAdapter; | ||||
| import it.reyboz.bustorino.backend.*; | import it.reyboz.bustorino.backend.*; | ||||
| import it.reyboz.bustorino.data.DatabaseUpdate; | import it.reyboz.bustorino.data.DatabaseUpdate; | ||||
| import it.reyboz.bustorino.middleware.AppLocationManager; | import it.reyboz.bustorino.middleware.AppLocationManager; | ||||
| import it.reyboz.bustorino.adapters.SquareStopAdapter; | import it.reyboz.bustorino.adapters.SquareStopAdapter; | ||||
| import it.reyboz.bustorino.middleware.AutoFitGridLayoutManager; | import it.reyboz.bustorino.middleware.AutoFitGridLayoutManager; | ||||
| import it.reyboz.bustorino.util.LocationCriteria; | import it.reyboz.bustorino.util.LocationCriteria; | ||||
| import it.reyboz.bustorino.util.Permissions; | |||||
| import it.reyboz.bustorino.util.StopSorterByDistance; | import it.reyboz.bustorino.util.StopSorterByDistance; | ||||
| import it.reyboz.bustorino.viewmodels.NearbyStopsViewModel; | import it.reyboz.bustorino.viewmodels.NearbyStopsViewModel; | ||||
| import org.jetbrains.annotations.NotNull; | import org.jetbrains.annotations.NotNull; | ||||
| import java.util.*; | import java.util.*; | ||||
| public class NearbyStopsFragment extends Fragment { | public class NearbyStopsFragment extends Fragment { | ||||
| public enum FragType{ | public enum FragType{ | ||||
| STOPS(1), ARRIVALS(2); | STOPS(1), ARRIVALS(2); | ||||
| private final int num; | private final int num; | ||||
| FragType(int num){ | FragType(int num){ | ||||
| this.num = num; | this.num = num; | ||||
| } | } | ||||
| public static FragType fromNum(int i){ | public static FragType fromNum(int i){ | ||||
| switch (i){ | switch (i){ | ||||
| case 1: return STOPS; | case 1: return STOPS; | ||||
| case 2: return ARRIVALS; | case 2: return ARRIVALS; | ||||
| default: | default: | ||||
| throw new IllegalArgumentException("type not recognized"); | throw new IllegalArgumentException("type not recognized"); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| private enum LocationShowingStatus {SEARCHING, FIRST_FIX, DISABLED, NO_PERMISSION} | |||||
| private FragmentListenerMain mListener; | private FragmentListenerMain mListener; | ||||
| private FragmentLocationListener fragmentLocationListener; | private FragmentLocationListener fragmentLocationListener; | ||||
| private final static String DEBUG_TAG = "NearbyStopsFragment"; | private final static String DEBUG_TAG = "NearbyStopsFragment"; | ||||
| private final static String FRAGMENT_TYPE_KEY = "FragmentType"; | private final static String FRAGMENT_TYPE_KEY = "FragmentType"; | ||||
| //public final static int TYPE_STOPS = 19, TYPE_ARRIVALS = 20; | //public final static int TYPE_STOPS = 19, TYPE_ARRIVALS = 20; | ||||
| private FragType fragment_type = FragType.STOPS; | private FragType fragment_type = FragType.STOPS; | ||||
| public final static String FRAGMENT_TAG="NearbyStopsFrag"; | public final static String FRAGMENT_TAG="NearbyStopsFrag"; | ||||
| //data Bundle | |||||
| private final String BUNDLE_LOCATION = "location"; | |||||
| private final int LOADER_ID = 0; | |||||
| private RecyclerView gridRecyclerView; | private RecyclerView gridRecyclerView; | ||||
| private SquareStopAdapter dataAdapter; | private SquareStopAdapter dataAdapter; | ||||
| private AutoFitGridLayoutManager gridLayoutManager; | private AutoFitGridLayoutManager gridLayoutManager; | ||||
| private GPSPoint lastPosition = null; | private GPSPoint lastPosition = null; | ||||
| private ProgressBar circlingProgressBar,flatProgressBar; | private ProgressBar circlingProgressBar,flatProgressBar; | ||||
| private int distance = 10; | private int distance = 10; | ||||
| protected SharedPreferences globalSharedPref; | protected SharedPreferences globalSharedPref; | ||||
| private SharedPreferences.OnSharedPreferenceChangeListener preferenceChangeListener; | private SharedPreferences.OnSharedPreferenceChangeListener preferenceChangeListener; | ||||
| private TextView messageTextView,titleTextView, loadingTextView; | private TextView messageTextView,titleTextView, loadingTextView; | ||||
| private CommonScrollListener scrollListener; | private CommonScrollListener scrollListener; | ||||
| private AppCompatButton switchButton; | private AppCompatButton switchButton; | ||||
| private boolean firstLocForStops = true,firstLocForArrivals = true; | private boolean firstLocForStops = true,firstLocForArrivals = true; | ||||
| public static final int COLUMN_WIDTH_DP = 250; | public static final int COLUMN_WIDTH_DP = 250; | ||||
| private Integer MAX_DISTANCE = -3; | private Integer MAX_DISTANCE = -3; | ||||
| private int MIN_NUM_STOPS = -1; | private int MIN_NUM_STOPS = -1; | ||||
| private int TIME_INTERVAL_REQUESTS = -1; | private int TIME_INTERVAL_REQUESTS = -1; | ||||
| private AppLocationManager locManager; | private LocationManager locManager; | ||||
| //These are useful for the case of nearby arrivals | //These are useful for the case of nearby arrivals | ||||
| private NearbyArrivalsDownloader arrivalsManager = null; | private NearbyArrivalsDownloader arrivalsManager = null; | ||||
| private ArrivalsStopAdapter arrivalsStopAdapter = null; | private ArrivalsStopAdapter arrivalsStopAdapter = null; | ||||
| private boolean dbUpdateRunning = false; | private boolean dbUpdateRunning = false; | ||||
| private ArrayList<Stop> currentNearbyStops = new ArrayList<>(); | private ArrayList<Stop> currentNearbyStops = new ArrayList<>(); | ||||
| private NearbyArrivalsDownloader nearbyArrivalsDownloader; | private NearbyArrivalsDownloader nearbyArrivalsDownloader; | ||||
| private LocationShowingStatus showingStatus = LocationShowingStatus.NO_PERMISSION; | |||||
| private final NearbyArrivalsDownloader.ArrivalsListener arrivalsListener = new NearbyArrivalsDownloader.ArrivalsListener() { | private final NearbyArrivalsDownloader.ArrivalsListener arrivalsListener = new NearbyArrivalsDownloader.ArrivalsListener() { | ||||
| @Override | @Override | ||||
| public void setProgress(int completedRequests, int pendingRequests) { | public void setProgress(int completedRequests, int pendingRequests) { | ||||
| if(flatProgressBar!=null) { | if(flatProgressBar!=null) { | ||||
| if (pendingRequests == 0) { | if (pendingRequests == 0) { | ||||
| flatProgressBar.setIndeterminate(true); | flatProgressBar.setIndeterminate(true); | ||||
| flatProgressBar.setVisibility(View.GONE); | flatProgressBar.setVisibility(View.GONE); | ||||
| } else { | } else { | ||||
| Show All 39 Lines | public class NearbyStopsFragment extends Fragment { | ||||
| @Override | @Override | ||||
| public void onCreate(Bundle savedInstanceState) { | public void onCreate(Bundle savedInstanceState) { | ||||
| super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
| if (getArguments() != null) { | if (getArguments() != null) { | ||||
| setFragmentType(FragType.fromNum(getArguments().getInt(FRAGMENT_TYPE_KEY))); | setFragmentType(FragType.fromNum(getArguments().getInt(FRAGMENT_TYPE_KEY))); | ||||
| } | } | ||||
| locManager = AppLocationManager.getInstance(getContext()); | locManager = (LocationManager) requireContext().getSystemService(Context.LOCATION_SERVICE); | ||||
| fragmentLocationListener = new FragmentLocationListener(); | fragmentLocationListener = new FragmentLocationListener(); | ||||
| if (getContext()!=null) { | if (getContext()!=null) { | ||||
| globalSharedPref = getContext().getSharedPreferences(getString(R.string.mainSharedPreferences), Context.MODE_PRIVATE); | globalSharedPref = getContext().getSharedPreferences(getString(R.string.mainSharedPreferences), Context.MODE_PRIVATE); | ||||
| globalSharedPref.registerOnSharedPreferenceChangeListener(preferenceChangeListener); | globalSharedPref.registerOnSharedPreferenceChangeListener(preferenceChangeListener); | ||||
| } | } | ||||
| nearbyArrivalsDownloader = new NearbyArrivalsDownloader(getContext().getApplicationContext(), arrivalsListener); | nearbyArrivalsDownloader = new NearbyArrivalsDownloader(getContext().getApplicationContext(), arrivalsListener); | ||||
| Show All 16 Lines | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, | ||||
| titleTextView = root.findViewById(R.id.titleTextView); | titleTextView = root.findViewById(R.id.titleTextView); | ||||
| loadingTextView = root.findViewById(R.id.positionLoadingTextView); | loadingTextView = root.findViewById(R.id.positionLoadingTextView); | ||||
| switchButton = root.findViewById(R.id.switchButton); | switchButton = root.findViewById(R.id.switchButton); | ||||
| scrollListener = new CommonScrollListener(mListener,false); | scrollListener = new CommonScrollListener(mListener,false); | ||||
| switchButton.setOnClickListener(v -> switchFragmentType()); | switchButton.setOnClickListener(v -> switchFragmentType()); | ||||
| Log.d(DEBUG_TAG, "onCreateView"); | Log.d(DEBUG_TAG, "onCreateView"); | ||||
| final Context appContext =requireContext().getApplicationContext(); | |||||
| DatabaseUpdate.watchUpdateWorkStatus(getContext(), this, new Observer<List<WorkInfo>>() { | DatabaseUpdate.watchUpdateWorkStatus(getContext(), this, new Observer<List<WorkInfo>>() { | ||||
| @SuppressLint("MissingPermission") | |||||
| @Override | @Override | ||||
| public void onChanged(List<WorkInfo> workInfos) { | public void onChanged(List<WorkInfo> workInfos) { | ||||
| if(workInfos.isEmpty()) return; | if(workInfos.isEmpty()) return; | ||||
| WorkInfo wi = workInfos.get(0); | WorkInfo wi = workInfos.get(0); | ||||
| if (wi.getState() == WorkInfo.State.RUNNING && locManager.isRequesterRegistered(fragmentLocationListener)) { | if (wi.getState() == WorkInfo.State.RUNNING && fragmentLocationListener.isRegistered) { | ||||
| locManager.removeLocationRequestFor(fragmentLocationListener); | locManager.removeUpdates(fragmentLocationListener); | ||||
| fragmentLocationListener.isRegistered = true; | |||||
| dbUpdateRunning = true; | dbUpdateRunning = true; | ||||
| } else{ | } else{ | ||||
| //start the request | //start the request | ||||
| if(!locManager.isRequesterRegistered(fragmentLocationListener)) | if(!fragmentLocationListener.isRegistered){ | ||||
| locManager.addLocationRequestFor(fragmentLocationListener); | requestLocationUpdates(); | ||||
| } | |||||
| dbUpdateRunning = false; | dbUpdateRunning = false; | ||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| //observe the livedata | //observe the livedata | ||||
| viewModel.getStopsAtDistance().observe(getViewLifecycleOwner(), stops -> { | viewModel.getStopsAtDistance().observe(getViewLifecycleOwner(), stops -> { | ||||
| if (!dbUpdateRunning && (stops.size() < MIN_NUM_STOPS && distance <= MAX_DISTANCE)) { | if (!dbUpdateRunning && (stops.size() < MIN_NUM_STOPS && distance <= MAX_DISTANCE)) { | ||||
| distance = distance + 40; | distance = distance + 40; | ||||
| viewModel.requestStopsAtDistance(distance, true); | viewModel.requestStopsAtDistance(distance, true); | ||||
| //Log.d(DEBUG_TAG, "Doubling distance now!"); | //Log.d(DEBUG_TAG, "Doubling distance now!"); | ||||
| return; | return; | ||||
| } | } | ||||
| if(!stops.isEmpty()) { | if(!stops.isEmpty()) { | ||||
| Log.d(DEBUG_TAG, "Showing "+stops.size()+" stops nearby"); | Log.d(DEBUG_TAG, "Showing "+stops.size()+" stops nearby"); | ||||
| currentNearbyStops =stops; | currentNearbyStops =stops; | ||||
| showStopsInViews(currentNearbyStops, lastPosition); | showStopsInViews(currentNearbyStops, lastPosition); | ||||
| } | } | ||||
| }); | }); | ||||
| if(Permissions.anyLocationPermissionsGranted(appContext)){ | |||||
| setShowingStatus(LocationShowingStatus.SEARCHING); | |||||
| } else { | |||||
| setShowingStatus(LocationShowingStatus.NO_PERMISSION); | |||||
| } | |||||
| return root; | return root; | ||||
| } | } | ||||
| //because linter is stupid and cannot look inside *anyLocationPermissionGranted* | |||||
| @SuppressLint("MissingPermission") | |||||
| private boolean requestLocationUpdates(){ | |||||
| if(Permissions.anyLocationPermissionsGranted(requireContext())) { | |||||
| locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, | |||||
| 3000, 10.0f, fragmentLocationListener | |||||
| ); | |||||
| fragmentLocationListener.isRegistered = true; | |||||
| return true; | |||||
| } else return false; | |||||
| } | |||||
| /** | /** | ||||
| * Use this method to set the fragment type | * Use this method to set the fragment type | ||||
| * @param type the type, TYPE_ARRIVALS or TYPE_STOPS | * @param type the type, TYPE_ARRIVALS or TYPE_STOPS | ||||
| */ | */ | ||||
| private void setFragmentType(FragType type){ | private void setFragmentType(FragType type){ | ||||
| this.fragment_type = type; | this.fragment_type = type; | ||||
| switch(type){ | switch(type){ | ||||
| case ARRIVALS: | case ARRIVALS: | ||||
| TIME_INTERVAL_REQUESTS = 5*1000; | TIME_INTERVAL_REQUESTS = 5*1000; | ||||
| break; | break; | ||||
| case STOPS: | case STOPS: | ||||
| TIME_INTERVAL_REQUESTS = 1000; | TIME_INTERVAL_REQUESTS = 1000; | ||||
| } | } | ||||
| } | } | ||||
| private void setShowingStatus(@NonNull LocationShowingStatus newStatus){ | |||||
| if(newStatus == showingStatus){ | |||||
| Log.d(DEBUG_TAG, "Asked to set new displaying status but it's the same"); | |||||
| return; | |||||
| } | |||||
| switch (newStatus){ | |||||
| case FIRST_FIX: | |||||
| circlingProgressBar.setVisibility(View.GONE); | |||||
| loadingTextView.setVisibility(View.GONE); | |||||
| gridRecyclerView.setVisibility(View.VISIBLE); | |||||
| messageTextView.setVisibility(View.GONE); | |||||
| break; | |||||
| case NO_PERMISSION: | |||||
| circlingProgressBar.setVisibility(View.GONE); | |||||
| loadingTextView.setVisibility(View.GONE); | |||||
| messageTextView.setText(R.string.enable_position_message_nearby); | |||||
| messageTextView.setVisibility(View.VISIBLE); | |||||
| break; | |||||
| case DISABLED: | |||||
| if (showingStatus== LocationShowingStatus.SEARCHING){ | |||||
| circlingProgressBar.setVisibility(View.GONE); | |||||
| loadingTextView.setVisibility(View.GONE); | |||||
| } | |||||
| messageTextView.setText(R.string.enableGpsText); | |||||
| messageTextView.setVisibility(View.VISIBLE); | |||||
| break; | |||||
| case SEARCHING: | |||||
| circlingProgressBar.setVisibility(View.VISIBLE); | |||||
| loadingTextView.setVisibility(View.VISIBLE); | |||||
| gridRecyclerView.setVisibility(View.GONE); | |||||
| messageTextView.setVisibility(View.GONE); | |||||
| } | |||||
| showingStatus = newStatus; | |||||
| } | |||||
| @Override | @Override | ||||
| public void onAttach(@NonNull Context context) { | public void onAttach(@NonNull Context context) { | ||||
| super.onAttach(context); | super.onAttach(context); | ||||
| if (context instanceof FragmentListenerMain) { | if (context instanceof FragmentListenerMain) { | ||||
| mListener = (FragmentListenerMain) context; | mListener = (FragmentListenerMain) context; | ||||
| } else { | } else { | ||||
| throw new RuntimeException(context | throw new RuntimeException(context | ||||
| + " must implement OnFragmentInteractionListener"); | + " must implement OnFragmentInteractionListener"); | ||||
| } | } | ||||
| Log.d(DEBUG_TAG, "OnAttach called"); | Log.d(DEBUG_TAG, "OnAttach called"); | ||||
| viewModel = new ViewModelProvider(this).get(NearbyStopsViewModel.class); | viewModel = new ViewModelProvider(this).get(NearbyStopsViewModel.class); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onPause() { | public void onPause() { | ||||
| super.onPause(); | super.onPause(); | ||||
| gridRecyclerView.setAdapter(null); | gridRecyclerView.setAdapter(null); | ||||
| locManager.removeLocationRequestFor(fragmentLocationListener); | locManager.removeUpdates(fragmentLocationListener); | ||||
| fragmentLocationListener.isRegistered = false; | |||||
| Log.d(DEBUG_TAG,"On paused called"); | Log.d(DEBUG_TAG,"On paused called"); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onResume() { | public void onResume() { | ||||
| super.onResume(); | super.onResume(); | ||||
| try{ | try{ | ||||
| if(!dbUpdateRunning && !locManager.isRequesterRegistered(fragmentLocationListener)) | if(!dbUpdateRunning && !fragmentLocationListener.isRegistered) { | ||||
| locManager.addLocationRequestFor(fragmentLocationListener); | requestLocationUpdates(); | ||||
| } | |||||
| } catch (SecurityException ex){ | } catch (SecurityException ex){ | ||||
| //ignored | //ignored | ||||
| //try another location provider | //try another location provider | ||||
| } | } | ||||
| //fix view if we were showing the stops or the arrivals | //fix view if we were showing the stops or the arrivals | ||||
| prepareForFragmentType(); | prepareForFragmentType(); | ||||
| switch(fragment_type){ | switch(fragment_type){ | ||||
| case STOPS: | case STOPS: | ||||
| ▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | private void showRecyclerHidingLoadMessage(){ | ||||
| gridRecyclerView.setVisibility(View.VISIBLE); | gridRecyclerView.setVisibility(View.VISIBLE); | ||||
| } | } | ||||
| messageTextView.setVisibility(View.GONE); | messageTextView.setVisibility(View.GONE); | ||||
| } | } | ||||
| /** | /** | ||||
| * Local locationListener, to use for the GPS | * Local locationListener, to use for the GPS | ||||
| */ | */ | ||||
| class FragmentLocationListener implements AppLocationManager.LocationRequester{ | class FragmentLocationListener implements LocationListenerCompat { | ||||
| private int oldLocStatus = -2; | |||||
| private LocationCriteria cr; | |||||
| private long lastUpdateTime = -1; | private long lastUpdateTime = -1; | ||||
| public boolean isRegistered = false; | |||||
| @Override | @Override | ||||
| public void onLocationChanged(Location location) { | public void onLocationChanged(Location location) { | ||||
| //set adapter | //set adapter | ||||
| if(location==null){ | if(location==null){ | ||||
| Log.e(DEBUG_TAG, "Location is null, cannot request stops"); | Log.e(DEBUG_TAG, "Location is null, cannot request stops"); | ||||
| return; | return; | ||||
| } else if(viewModel==null){ | } else if(viewModel==null){ | ||||
| return; | return; | ||||
| } | } | ||||
| if(location.getAccuracy()<200 && !dbUpdateRunning) { | if(location.getAccuracy()<200 && !dbUpdateRunning) { | ||||
| if(viewModel.getDistanceMtLiveData().getValue()==null){ | if(viewModel.getDistanceMtLiveData().getValue()==null){ | ||||
| //never run request | //never run request | ||||
| distance = 40; | distance = 40; | ||||
| } | } | ||||
| lastPosition = new GPSPoint(location.getLatitude(), location.getLongitude()); | lastPosition = new GPSPoint(location.getLatitude(), location.getLongitude()); | ||||
| viewModel.requestStopsAtDistance(location.getLatitude(), location.getLongitude(), distance, true); | viewModel.requestStopsAtDistance(location.getLatitude(), location.getLongitude(), distance, true); | ||||
| } | } | ||||
| lastUpdateTime = System.currentTimeMillis(); | lastUpdateTime = System.currentTimeMillis(); | ||||
| Log.d("BusTO:NearPositListen","can start request for stops: "+ !dbUpdateRunning); | Log.d("BusTO:NearPositListen","can start request for stops: "+ !dbUpdateRunning); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onProviderEnabled(@NonNull String provider) { | |||||
| Log.d(DEBUG_TAG, "Location provider "+provider+" enabled"); | |||||
| if(provider.equals(LocationManager.GPS_PROVIDER)){ | |||||
| setShowingStatus(LocationShowingStatus.SEARCHING); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onProviderDisabled(@NonNull String provider) { | |||||
| Log.d(DEBUG_TAG, "Location provider "+provider+" disabled"); | |||||
| if(provider.equals(LocationManager.GPS_PROVIDER)) { | |||||
| setShowingStatus(LocationShowingStatus.DISABLED); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onStatusChanged(@NonNull @NotNull String provider, int status, @Nullable @org.jetbrains.annotations.Nullable Bundle extras) { | |||||
| LocationListenerCompat.super.onStatusChanged(provider, status, extras); | |||||
| } | |||||
| /* | |||||
| @Override | |||||
| public void onLocationStatusChanged(int status) { | public void onLocationStatusChanged(int status) { | ||||
| switch(status){ | switch(status){ | ||||
| case AppLocationManager.LOCATION_GPS_AVAILABLE: | case AppLocationManager.LOCATION_GPS_AVAILABLE: | ||||
| messageTextView.setVisibility(View.GONE); | messageTextView.setVisibility(View.GONE); | ||||
| break; | break; | ||||
| case AppLocationManager.LOCATION_UNAVAILABLE: | case AppLocationManager.LOCATION_UNAVAILABLE: | ||||
| messageTextView.setText(R.string.enableGpsText); | messageTextView.setText(R.string.enableGpsText); | ||||
| Show All 22 Lines | class FragmentLocationListener implements LocationListenerCompat { | ||||
| public void onLocationProviderAvailable() { | public void onLocationProviderAvailable() { | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onLocationDisabled() { | public void onLocationDisabled() { | ||||
| } | } | ||||
| */ | |||||
| } | } | ||||
| } | } | ||||
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