use of org.infobip.mobile.messaging.geo.storage.GeoSQLiteMessageStore in project mobile-messaging-sdk-android by infobip.
the class MessageStoreTest method test_shouldUseGeoSqlStoreForGeo_whenConfiguredWithoutMessageStore.
@Test
public void test_shouldUseGeoSqlStoreForGeo_whenConfiguredWithoutMessageStore() {
MobileMessagingCore.setMessageStoreClass(context, null);
assertTrue(new GeofencingHelper(context).getMessageStoreForGeo() instanceof GeoSQLiteMessageStore);
}
use of org.infobip.mobile.messaging.geo.storage.GeoSQLiteMessageStore in project mobile-messaging-sdk-android by infobip.
the class GeofencingImpl method removeExpiredAreasFromStorage.
void removeExpiredAreasFromStorage() {
GeoSQLiteMessageStore messageStoreForGeo = (GeoSQLiteMessageStore) geofencingHelper.getMessageStoreForGeo();
List<Message> messages = messageStoreForGeo.findAll(context);
List<String> messageIdsToDelete = new ArrayList<>(messages.size());
Date now = new Date();
for (Message message : messages) {
Geo geo = GeoDataMapper.geoFromInternalData(message.getInternalData());
if (geo == null) {
continue;
}
List<Area> areasList = geo.getAreasList();
Date expiryDate = geo.getExpiryDate();
if (areasList == null || areasList.isEmpty()) {
continue;
}
for (Area area : areasList) {
if (!area.isValid() || expiryDate == null) {
continue;
}
if (expiryDate.before(now)) {
messageIdsToDelete.add(message.getMessageId());
}
}
}
if (!messageIdsToDelete.isEmpty()) {
messageStoreForGeo.deleteByIds(context, messageIdsToDelete.toArray(new String[] {}));
}
}
use of org.infobip.mobile.messaging.geo.storage.GeoSQLiteMessageStore in project mobile-messaging-sdk-android by infobip.
the class MessageStoreTest method test_shouldUseGeoSqlStoreForGeo_whenConfiguredWithMessageStore.
@Test
public void test_shouldUseGeoSqlStoreForGeo_whenConfiguredWithMessageStore() {
MobileMessagingCore.setMessageStoreClass(context, TestMessageStore.class);
assertTrue(new GeofencingHelper(context).getMessageStoreForGeo() instanceof GeoSQLiteMessageStore);
}
Aggregations