Fix of refresh for google places fragment.

master
Tomasz Półgrabia 2016-10-09 21:45:32 +02:00
parent 0dfbb152b3
commit 43b94f923b
1 changed files with 16 additions and 2 deletions

View File

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