Fixing additional dependency of settings refreshing.
parent
e68c6338f5
commit
99d9e5ab31
|
@ -1,5 +1,6 @@
|
||||||
package pl.tpolgrabia.urbanexplorer.callbacks.wiki;
|
package pl.tpolgrabia.urbanexplorer.callbacks.wiki;
|
||||||
|
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import pl.tpolgrabia.urbanexplorer.AppConstants;
|
import pl.tpolgrabia.urbanexplorer.AppConstants;
|
||||||
|
@ -15,17 +16,16 @@ import java.util.List;
|
||||||
public class FetchWikiLocationsCallback implements AdapterView.OnItemLongClickListener {
|
public class FetchWikiLocationsCallback implements AdapterView.OnItemLongClickListener {
|
||||||
private final WikiUtils wikiUtils;
|
private final WikiUtils wikiUtils;
|
||||||
private WikiLocationsFragment wikiLocationsFragment;
|
private WikiLocationsFragment wikiLocationsFragment;
|
||||||
private final List<WikiAppObject> appObjects;
|
|
||||||
|
|
||||||
public FetchWikiLocationsCallback(WikiLocationsFragment wikiLocationsFragment, List<WikiAppObject> appObjects) {
|
public FetchWikiLocationsCallback(WikiLocationsFragment wikiLocationsFragment) {
|
||||||
this.wikiLocationsFragment = wikiLocationsFragment;
|
this.wikiLocationsFragment = wikiLocationsFragment;
|
||||||
this.wikiUtils = new WikiUtils(wikiLocationsFragment.getActivity(), AppConstants.DEF_WIKI_COUNTRY_CODE);
|
final FragmentActivity activity = wikiLocationsFragment.getActivity();
|
||||||
this.appObjects = appObjects;
|
this.wikiUtils = new WikiUtils(activity, wikiLocationsFragment.getWikiLocale(activity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
|
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
|
||||||
final WikiAppObject item = appObjects.get(position);
|
final WikiAppObject item = wikiLocationsFragment.getAppObjects().get(position);
|
||||||
wikiUtils.fetchSingleWikiInfoItemAndRunWikiPage(
|
wikiUtils.fetchSingleWikiInfoItemAndRunWikiPage(
|
||||||
wikiLocationsFragment.getActivity(),
|
wikiLocationsFragment.getActivity(),
|
||||||
item.getPageId(),
|
item.getPageId(),
|
||||||
|
|
|
@ -5,16 +5,14 @@ import android.view.View;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
|
||||||
import pl.tpolgrabia.urbanexplorer.MainActivity;
|
import pl.tpolgrabia.urbanexplorer.MainActivity;
|
||||||
import pl.tpolgrabia.urbanexplorer.R;
|
import pl.tpolgrabia.urbanexplorer.R;
|
||||||
import pl.tpolgrabia.urbanexplorer.adapters.WikiLocationsAdapter;
|
import pl.tpolgrabia.urbanexplorer.adapters.WikiLocationsAdapter;
|
||||||
import pl.tpolgrabia.urbanexplorerutils.events.RefreshEvent;
|
import pl.tpolgrabia.urbanexplorer.fragments.WikiLocationsFragment;
|
||||||
|
import pl.tpolgrabia.urbanexplorerutils.events.DataLoadingFinishEvent;
|
||||||
|
import pl.tpolgrabia.wikibinding.callback.WikiAppResponseCallback;
|
||||||
import pl.tpolgrabia.wikibinding.callback.WikiStatus;
|
import pl.tpolgrabia.wikibinding.callback.WikiStatus;
|
||||||
import pl.tpolgrabia.wikibinding.dto.app.WikiAppObject;
|
import pl.tpolgrabia.wikibinding.dto.app.WikiAppObject;
|
||||||
import pl.tpolgrabia.urbanexplorerutils.events.DataLoadingFinishEvent;
|
|
||||||
import pl.tpolgrabia.urbanexplorer.fragments.WikiLocationsFragment;
|
|
||||||
import pl.tpolgrabia.wikibinding.callback.WikiAppResponseCallback;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -53,7 +51,7 @@ public class WikiFetchAppDataCallback implements WikiAppResponseCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView locations = (ListView) view.findViewById(R.id.wiki_places);
|
ListView locations = (ListView) view.findViewById(R.id.wiki_places);
|
||||||
locations.setOnItemLongClickListener(new FetchWikiLocationsCallback(wikiLocationsFragment, nobjects));
|
locations.setOnItemLongClickListener(new FetchWikiLocationsCallback(wikiLocationsFragment));
|
||||||
locations.setAdapter(new WikiLocationsAdapter(activity, objects));
|
locations.setAdapter(new WikiLocationsAdapter(activity, objects));
|
||||||
if (objects.isEmpty()) {
|
if (objects.isEmpty()) {
|
||||||
Toast.makeText(wikiLocationsFragment.getActivity(), "No results", Toast.LENGTH_SHORT).show();
|
Toast.makeText(wikiLocationsFragment.getActivity(), "No results", Toast.LENGTH_SHORT).show();
|
||||||
|
|
|
@ -74,6 +74,8 @@ public class WikiLocationsFragment extends Fragment {
|
||||||
private void refreshSettings() {
|
private void refreshSettings() {
|
||||||
geocoderUtils = new GeocoderUtils(getActivity(), AppConstants.GOOGLE_API_KEY);
|
geocoderUtils = new GeocoderUtils(getActivity(), AppConstants.GOOGLE_API_KEY);
|
||||||
wikiUtils = new WikiUtils(getActivity(), getWikiLocale(getActivity()));
|
wikiUtils = new WikiUtils(getActivity(), getWikiLocale(getActivity()));
|
||||||
|
ListView locations = (ListView) getView().findViewById(R.id.wiki_places);
|
||||||
|
locations.setOnItemLongClickListener(new FetchWikiLocationsCallback(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,7 +96,7 @@ public class WikiLocationsFragment extends Fragment {
|
||||||
EventBus.getDefault().register(providerHandler);
|
EventBus.getDefault().register(providerHandler);
|
||||||
|
|
||||||
ListView locations = (ListView) inflatedView.findViewById(R.id.wiki_places);
|
ListView locations = (ListView) inflatedView.findViewById(R.id.wiki_places);
|
||||||
locations.setOnItemLongClickListener(new FetchWikiLocationsCallback(WikiLocationsFragment.this, appObjects));
|
locations.setOnItemLongClickListener(new FetchWikiLocationsCallback(this));
|
||||||
locations.setAdapter(new WikiLocationsAdapter(getActivity(), appObjects));
|
locations.setAdapter(new WikiLocationsAdapter(getActivity(), appObjects));
|
||||||
|
|
||||||
return inflatedView;
|
return inflatedView;
|
||||||
|
@ -203,4 +205,8 @@ public class WikiLocationsFragment extends Fragment {
|
||||||
lg.debug("Refreshing settings {}", event);
|
lg.debug("Refreshing settings {}", event);
|
||||||
refreshSettings();
|
refreshSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<WikiAppObject> getAppObjects() {
|
||||||
|
return appObjects;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue