use of fr.free.nrw.commons.utils.UriDeserializer in project apps-android-commons by commons-app.
the class NearbyListFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// Check that this is the first time view is created,
// to avoid double list when screen orientation changed
Bundle bundle = this.getArguments();
Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriDeserializer()).create();
if (bundle != null) {
String gsonPlaceList = bundle.getString("PlaceList");
String gsonLatLng = bundle.getString("CurLatLng");
Type listType = new TypeToken<List<Place>>() {
}.getType();
placeList = gson.fromJson(gsonPlaceList, listType);
Type curLatLngType = new TypeToken<LatLng>() {
}.getType();
LatLng curLatLng = gson.fromJson(gsonLatLng, curLatLngType);
placeList = NearbyController.loadAttractionsFromLocationToPlaces(curLatLng, placeList);
}
if (savedInstanceState == null) {
adapter.clear();
Timber.d("Saved instance state is null, populating ListView");
}
adapter.clear();
adapter.addAll(placeList);
adapter.notifyDataSetChanged();
}
use of fr.free.nrw.commons.utils.UriDeserializer in project apps-android-commons by commons-app.
the class NearbyMapFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = this.getArguments();
Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriDeserializer()).create();
if (bundle != null) {
String gsonPlaceList = bundle.getString("PlaceList");
String gsonLatLng = bundle.getString("CurLatLng");
Type listType = new TypeToken<List<Place>>() {
}.getType();
List<Place> placeList = gson.fromJson(gsonPlaceList, listType);
Type curLatLngType = new TypeToken<fr.free.nrw.commons.location.LatLng>() {
}.getType();
curLatLng = gson.fromJson(gsonLatLng, curLatLngType);
baseMarkerOptions = NearbyController.loadAttractionsFromLocationToBaseMarkerOptions(curLatLng, placeList, getActivity());
}
Mapbox.getInstance(getActivity(), getString(R.string.mapbox_commons_app_token));
MapboxTelemetry.getInstance().setTelemetryEnabled(false);
}
Aggregations