removed CallbackWithObject

This commit is contained in:
Chumva 2018-05-10 11:36:59 +03:00
parent ca4d2d47a3
commit 487e3f0219

View file

@ -9,7 +9,6 @@ import android.os.AsyncTask;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.util.Log; import android.util.Log;
import net.osmand.CallbackWithObject;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -43,7 +42,6 @@ public class WikipediaArticleHelper {
private WikiArticleSearchTask articleSearchTask; private WikiArticleSearchTask articleSearchTask;
private MapActivity mapActivity; private MapActivity mapActivity;
private String regionName;
private boolean nightMode; private boolean nightMode;
public WikipediaArticleHelper(MapActivity mapActivity, boolean nightMode) { public WikipediaArticleHelper(MapActivity mapActivity, boolean nightMode) {
@ -54,7 +52,6 @@ public class WikipediaArticleHelper {
public static class WikiArticleSearchTask extends AsyncTask<Void, Void, List<Amenity>> { public static class WikiArticleSearchTask extends AsyncTask<Void, Void, List<Amenity>> {
private ProgressDialog dialog; private ProgressDialog dialog;
private CallbackWithObject<String> callback;
private WeakReference<MapActivity> weakMapActivity; private WeakReference<MapActivity> weakMapActivity;
private LatLon articleLatLon; private LatLon articleLatLon;
@ -65,17 +62,13 @@ public class WikipediaArticleHelper {
private boolean isNightMode; private boolean isNightMode;
WikiArticleSearchTask(LatLon articleLatLon, WikiArticleSearchTask(LatLon articleLatLon,
String regionName,
MapActivity mapActivity, MapActivity mapActivity,
boolean nightMode, boolean nightMode,
String url, String url) {
final CallbackWithObject<String> callback) {
this.articleLatLon = articleLatLon; this.articleLatLon = articleLatLon;
this.regionName = regionName;
weakMapActivity = new WeakReference<>(mapActivity); weakMapActivity = new WeakReference<>(mapActivity);
this.isNightMode = nightMode; this.isNightMode = nightMode;
this.url = url; this.url = url;
this.callback = callback;
dialog = createProgressDialog(mapActivity); dialog = createProgressDialog(mapActivity);
} }
@ -112,7 +105,6 @@ public class WikipediaArticleHelper {
if (repository == null) { if (repository == null) {
if ((regionName == null || regionName.isEmpty()) && item != null) { if ((regionName == null || regionName.isEmpty()) && item != null) {
regionName = (getRegionName(item.getFileName(), application.getRegions())); regionName = (getRegionName(item.getFileName(), application.getRegions()));
callback.processResult(regionName);
} }
return null; return null;
} else { } else {
@ -133,7 +125,6 @@ public class WikipediaArticleHelper {
dialog.dismiss(); dialog.dismiss();
} }
dialog = null; dialog = null;
callback = null;
} }
@Override @Override
@ -184,13 +175,7 @@ public class WikipediaArticleHelper {
if (articleLatLon == null) { if (articleLatLon == null) {
return; return;
} }
articleSearchTask = new WikiArticleSearchTask(articleLatLon, regionName, mapActivity, nightMode, url, new CallbackWithObject<String>() { articleSearchTask = new WikiArticleSearchTask(articleLatLon, mapActivity, nightMode, url);
@Override
public boolean processResult(String s) {
regionName = s;
return true;
}
});
articleSearchTask.execute(); articleSearchTask.execute();
} }