Search in sources :

Example 6 with Area

use of org.infobip.mobile.messaging.geo.Area in project mobile-messaging-sdk-android by infobip.

the class GeoReportHelper method createNewMessageForReport.

/**
 * Creates new message based on geofencing report
 *
 * @param report          geofencing report for any supported event
 * @param reportingResult result of reporting geo events to server
 * @param originalMessage original signaling message
 * @return new message based on triggering event, area and original signaling message
 */
private static Message createNewMessageForReport(@NonNull final GeoReport report, @NonNull GeoReportingResult reportingResult, @NonNull Message originalMessage) {
    GeoLatLng triggeringLocation = report.getTriggeringLocation();
    if (triggeringLocation == null) {
        triggeringLocation = new GeoLatLng(null, null);
    }
    List<Area> areas = new ArrayList<>();
    if (report.getArea() != null) {
        areas.add(report.getArea());
    }
    Geo geo;
    Geo originalMessageGeo = GeoDataMapper.geoFromInternalData(originalMessage.getInternalData());
    if (originalMessageGeo != null) {
        geo = new Geo(triggeringLocation.getLat(), triggeringLocation.getLng(), originalMessageGeo.getDeliveryTime(), originalMessageGeo.getExpiryTime(), originalMessageGeo.getStartTime(), originalMessageGeo.getCampaignId(), areas, originalMessageGeo.getEvents(), originalMessage.getSentTimestamp(), originalMessage.getContentUrl());
    } else {
        geo = new Geo(triggeringLocation.getLat(), triggeringLocation.getLng(), null, null, null, null, areas, null, Time.now(), originalMessage.getContentUrl());
    }
    String internalData = GeoDataMapper.geoToInternalData(geo);
    return new Message(getMessageIdFromReport(report, reportingResult), originalMessage.getTitle(), originalMessage.getBody(), originalMessage.getSound(), originalMessage.isVibrate(), originalMessage.getIcon(), // enforcing non-silent
    false, originalMessage.getCategory(), originalMessage.getFrom(), Time.now(), 0, Time.now(), originalMessage.getCustomPayload(), internalData, originalMessage.getDestination(), originalMessage.getStatus(), originalMessage.getStatusMessage(), originalMessage.getContentUrl());
}
Also used : Geo(org.infobip.mobile.messaging.geo.Geo) Area(org.infobip.mobile.messaging.geo.Area) Message(org.infobip.mobile.messaging.Message) GeoLatLng(org.infobip.mobile.messaging.geo.GeoLatLng) ArrayList(java.util.ArrayList)

Aggregations

Area (org.infobip.mobile.messaging.geo.Area)6 ArrayList (java.util.ArrayList)5 Message (org.infobip.mobile.messaging.Message)5 Geo (org.infobip.mobile.messaging.geo.Geo)4 Date (java.util.Date)3 ArrayMap (android.support.v4.util.ArrayMap)2 List (java.util.List)2 NonNull (android.support.annotation.NonNull)1 ArraySet (android.support.v4.util.ArraySet)1 Pair (android.util.Pair)1 Geofence (com.google.android.gms.location.Geofence)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GeoLatLng (org.infobip.mobile.messaging.geo.GeoLatLng)1 GeoSQLiteMessageStore (org.infobip.mobile.messaging.geo.storage.GeoSQLiteMessageStore)1