Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/fragments/NearbyStopsFragment.java
| Show All 38 Lines | |||||
| import android.util.Log; | import android.util.Log; | ||||
| import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||
| import android.view.View; | import android.view.View; | ||||
| import android.view.ViewGroup; | import android.view.ViewGroup; | ||||
| import android.widget.ProgressBar; | import android.widget.ProgressBar; | ||||
| import android.widget.TextView; | import android.widget.TextView; | ||||
| import com.android.volley.*; | import com.android.volley.*; | ||||
| import it.reyboz.bustorino.BuildConfig; | |||||
| 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.backend.FiveTAPIFetcher.QueryType; | import it.reyboz.bustorino.backend.FiveTAPIFetcher.QueryType; | ||||
| import it.reyboz.bustorino.middleware.AppLocationManager; | import it.reyboz.bustorino.middleware.AppLocationManager; | ||||
| import it.reyboz.bustorino.data.AppDataProvider; | import it.reyboz.bustorino.data.AppDataProvider; | ||||
| import it.reyboz.bustorino.data.NextGenDB.Contract.*; | import it.reyboz.bustorino.data.NextGenDB.Contract.*; | ||||
| import it.reyboz.bustorino.adapters.SquareStopAdapter; | import it.reyboz.bustorino.adapters.SquareStopAdapter; | ||||
| ▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | public void onResume() { | ||||
| mListener.enableRefreshLayout(false); | mListener.enableRefreshLayout(false); | ||||
| Log.d(DEBUG_TAG,"OnResume called"); | Log.d(DEBUG_TAG,"OnResume called"); | ||||
| //Re-read preferences | //Re-read preferences | ||||
| SharedPreferences shpr = PreferenceManager.getDefaultSharedPreferences(getContext().getApplicationContext()); | SharedPreferences shpr = PreferenceManager.getDefaultSharedPreferences(getContext().getApplicationContext()); | ||||
| //For some reason, they are all saved as strings | //For some reason, they are all saved as strings | ||||
| MAX_DISTANCE = shpr.getInt(getString(R.string.pref_key_radius_recents),600); | MAX_DISTANCE = shpr.getInt(getString(R.string.pref_key_radius_recents),600); | ||||
| boolean isMinStopInt = true; | |||||
| try{ | |||||
| MIN_NUM_STOPS = shpr.getInt(getString(R.string.pref_key_num_recents), 10); | |||||
| } catch (ClassCastException ex){ | |||||
| isMinStopInt = false; | |||||
| } | |||||
| if(!isMinStopInt) | |||||
| try { | |||||
| MIN_NUM_STOPS = Integer.parseInt(shpr.getString(getString(R.string.pref_key_num_recents),"10")); | MIN_NUM_STOPS = Integer.parseInt(shpr.getString(getString(R.string.pref_key_num_recents), "10")); | ||||
| } catch (NumberFormatException ex){ | |||||
| MIN_NUM_STOPS = 10; | |||||
| } | |||||
| if(BuildConfig.DEBUG) | |||||
| Log.d(DEBUG_TAG, "Max distance for stops: "+MAX_DISTANCE+ | |||||
| ", Min number of stops: "+MIN_NUM_STOPS); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||||
| super.onViewCreated(view, savedInstanceState); | super.onViewCreated(view, savedInstanceState); | ||||
| gridRecyclerView.setVisibility(View.INVISIBLE); | gridRecyclerView.setVisibility(View.INVISIBLE); | ||||
| gridRecyclerView.addOnScrollListener(scrollListener); | gridRecyclerView.addOnScrollListener(scrollListener); | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor data) { | ||||
| } else { | } else { | ||||
| setNoStopsLayout(); | setNoStopsLayout(); | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onLoaderReset(Loader<Cursor> loader) { | public void onLoaderReset(@NonNull Loader<Cursor> loader) { | ||||
| } | } | ||||
| /** | /** | ||||
| * To enable targeting from the Button | * To enable targeting from the Button | ||||
| */ | */ | ||||
| public void switchFragmentType(View v){ | public void switchFragmentType(View v){ | ||||
| switchFragmentType(); | switchFragmentType(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 309 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