Fix of refresh for google places fragment.
parent
0dfbb152b3
commit
43b94f923b
|
@ -40,9 +40,7 @@ import pl.tpolgrabia.urbanexplorerutils.utils.SettingsUtils;
|
|||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -165,6 +163,8 @@ public class PlacesFragment extends Fragment {
|
|||
location.getLatitude(), location.getLongitude()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
cleanAdapter();
|
||||
|
||||
places = null;
|
||||
nextPageToken = null;
|
||||
noMoreResults = false;
|
||||
|
@ -333,6 +333,14 @@ public class PlacesFragment extends Fragment {
|
|||
public void refresh(RefreshEvent event) {
|
||||
lg.debug("Refreshing event...");
|
||||
Toast.makeText(getActivity(), "Refreshing event google places", Toast.LENGTH_SHORT).show();
|
||||
|
||||
if (getView() == null) {
|
||||
lg.debug("Sorry, headless fragment");
|
||||
return;
|
||||
}
|
||||
|
||||
cleanAdapter();
|
||||
|
||||
pageId = 0L;
|
||||
places = null;
|
||||
nextPageToken = null;
|
||||
|
@ -340,4 +348,10 @@ public class PlacesFragment extends Fragment {
|
|||
fetchNearbyPlacesAndPresent(LocationUtils.getLastKnownLocation(getActivity()));
|
||||
}
|
||||
|
||||
private void cleanAdapter() {
|
||||
ListView plagesWidget = (ListView) getView().findViewById(R.id.google_places);
|
||||
PlacesAdapter adapter = (PlacesAdapter) plagesWidget.getAdapter();
|
||||
adapter.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue