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