/*
 * Created by Orchextra
 *
 * Copyright (C) 2017 Gigigo Mobile Services SL
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package gigigo.com.orchextrasdk.demo.geofences;

import com.google.android.gms.maps.model.LatLng;
import java.util.ArrayList;
import java.util.List;

public final class GeofencesProvider {

  public GeofencesProvider() {
  }

  public void getGeofences(GeofencesProviderCallback geofencesProviderCallback) {

    List<Geofence> geofences = new ArrayList<>();
    geofences.add(new Geofence(new LatLng(40.446561303262, -3.6278459079346), 131));

    geofencesProviderCallback.onGetGeofencesSuccess(geofences);
  }

  public interface GeofencesProviderCallback {

    void onGetGeofencesSuccess(List<Geofence> geofences);

    void onGetGeofencesError(String error);
  }
}

@@ -679,16 +679,179 @@
 ences;%0A%0A
+import com.gigigo.orchextra.core.Orchextra;%0Aimport com.gigigo.orchextra.core.domain.entities.GeoMarketing;%0Aimport com.gigigo.orchextra.core.domain.entities.Point;%0A
 import c
@@ -1110,202 +1110,657 @@
     
-List%3CGeofence%3E geofences = new ArrayList%3C%3E
+Orchextra orchextra = Orchextra.INSTANCE;%0A    List%3CGeoMarketing%3E geoMarketings =%0A        orchextra.getTriggerManager().getConfiguration().getGeoMarketing
 ();%0A
+%0A
     
-g
+List%3CG
 eofence
-s.add(new Geofence(new LatLng(40.446561303262, -3.6278459079346), 131));%0A%0A    geofencesProviderCallback.onGetGeofencesSuccess(geofences)
+%3E geofences = map(geoMarketings);%0A%0A    geofencesProviderCallback.onGetGeofencesSuccess(geofences);%0A  %7D%0A%0A  private List%3CGeofence%3E map(List%3CGeoMarketing%3E geoMarketings) %7B%0A%0A    List%3CGeofence%3E geofences = new ArrayList%3C%3E();%0A    Point point;%0A%0A    for (GeoMarketing geoMarketing : geoMarketings) %7B%0A      point = geoMarketing.getPoint();%0A      geofences.add(%0A          new Geofence(new LatLng(point.getLat(), point.getLng()), geoMarketing.getRadius()));%0A    %7D%0A%0A    return geofences
 ;%0A  

Load geofences from orchextra config