diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index ca11b8a456..78d2b67fa7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -63,6 +63,7 @@ import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; import net.osmand.plus.openplacereviews.AddPhotosBottomSheetDialogFragment; import net.osmand.plus.openplacereviews.OPRConstants; +import net.osmand.plus.openplacereviews.OpenPlaceReviewsPlugin; import net.osmand.plus.openplacereviews.OprStartFragment; import net.osmand.plus.osmedit.opr.OpenDBAPI; import net.osmand.plus.poi.PoiFiltersHelper; @@ -91,7 +92,7 @@ import java.util.Set; import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener; -public class MenuBuilder implements UploadPhotosListener { +public class MenuBuilder { private static final Log LOG = PlatformUtil.getLog(MenuBuilder.class); private static final int PICK_IMAGE = 1231; @@ -173,25 +174,6 @@ public class MenuBuilder implements UploadPhotosListener { } } - @Override - public void uploadPhotosSuccess(final String response) { - app.runInUIThread(new Runnable() { - @Override - public void run() { - if (AndroidUtils.isActivityNotDestroyed(mapActivity)) { - try { - ImageCard imageCard = ImageCard.createCardOpr(mapActivity, new JSONObject(response)); - if (imageCard != null) { - addImageCard(imageCard); - } - } catch (JSONException e) { - LOG.error(e); - } - } - } - }); - } - public interface CollapseExpandListener { void onCollapseExpand(boolean collapsed); } @@ -512,7 +494,27 @@ public class MenuBuilder implements UploadPhotosListener { } } } - execute(new UploadPhotosAsyncTask(mapActivity, imagesUri, placeId, MenuBuilder.this)); + UploadPhotosListener listener = new UploadPhotosListener() { + @Override + public void uploadPhotosSuccess(final String response) { + app.runInUIThread(new Runnable() { + @Override + public void run() { + if (AndroidUtils.isActivityNotDestroyed(mapActivity)) { + try { + ImageCard imageCard = OpenPlaceReviewsPlugin.createCardOpr(mapActivity, new JSONObject(response)); + if (imageCard != null) { + addImageCard(imageCard); + } + } catch (JSONException e) { + LOG.error(e); + } + } + } + }); + } + }; + execute(new UploadPhotosAsyncTask(mapActivity, imagesUri, placeId, listener)); } } })); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java index 1c2339648e..c754e6fc84 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java @@ -196,14 +196,6 @@ public abstract class ImageCard extends AbstractCard { return imageCard; } - public static ImageCard createCardOpr(MapActivity mapActivity, JSONObject imageObject) { - ImageCard imageCard = null; - if (imageObject.has("cid")) { - imageCard = new IPFSImageCard(mapActivity, imageObject); - } - return imageCard; - } - public double getCa() { return ca; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/IPFSImageCard.java b/OsmAnd/src/net/osmand/plus/openplacereviews/IPFSImageCard.java similarity index 93% rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/IPFSImageCard.java rename to OsmAnd/src/net/osmand/plus/openplacereviews/IPFSImageCard.java index 64bf146d56..ccf52f7de9 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/IPFSImageCard.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/IPFSImageCard.java @@ -1,4 +1,4 @@ -package net.osmand.plus.mapcontextmenu.builders.cards; +package net.osmand.plus.openplacereviews; import android.view.View; @@ -8,7 +8,7 @@ import androidx.core.content.ContextCompat; import net.osmand.PlatformUtil; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.openplacereviews.OPRConstants; +import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java index abf4d23b0e..42a8399c34 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java @@ -120,7 +120,7 @@ public class OpenPlaceReviewsPlugin extends OsmandPlugin { try { JSONObject imageObject = (JSONObject) images.get(i); if (imageObject != JSONObject.NULL) { - ImageCard imageCard = ImageCard.createCardOpr(mapActivity, imageObject); + ImageCard imageCard = createCardOpr(mapActivity, imageObject); if (imageCard != null) { result.add(imageCard); } @@ -137,6 +137,14 @@ public class OpenPlaceReviewsPlugin extends OsmandPlugin { } } + public static ImageCard createCardOpr(MapActivity mapActivity, JSONObject imageObject) { + ImageCard imageCard = null; + if (imageObject.has("cid")) { + imageCard = new IPFSImageCard(mapActivity, imageObject); + } + return imageCard; + } + private static String[] getIdFromResponse(String response) { try { JSONArray obj = new JSONObject(response).getJSONArray("objects");