Move IPFSImageCard to plugin
This commit is contained in:
parent
9efab732f2
commit
2a4818f630
4 changed files with 34 additions and 32 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue