// Path: app/src/main/java/com/github/gfx/hankei_n/toolbox/MarkerHueAllocator.java
// public class MarkerHueAllocator {
// 
//     static final String kMarkerHue = "marker_hue";
// 
//     static float INITIAL_HUE = BitmapDescriptorFactory.HUE_RED;
// 
//     final Prefs prefs;
// 
//     @Inject
//     public MarkerHueAllocator(Prefs prefs) {
//         this.prefs = prefs;
//     }
// 
//     public void reset() {
//         prefs.put(kMarkerHue, INITIAL_HUE);
//     }
// 
//     public float allocate() {
//         float hue = prefs.get(kMarkerHue, INITIAL_HUE);
//         prefs.put(kMarkerHue, (hue + 30.0f) % 360.0f);
//         return hue;
//     }
// }


import com.google.android.gms.maps.model.LatLng;
import com.github.gfx.hankei_n.R;
import com.github.gfx.hankei_n.toolbox.MarkerHueAllocator;
import android.content.Context;
import java.util.Iterator;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.inject.Inject;
import javax.inject.Singleton;
    public LocationMemoManager(OrmaDatabase orma) {
        relation = orma.relationOfLocationMemo()
                .orderByIdAsc();
        count = relation.count();
    }

    public int count() {
        assert count == relation.count();
        return count;
    }

    public LocationMemo get(int i) {
        return relation.get(i);
    }

    public LocationMemo newMemo(Context context, MarkerHueAllocator markerHueAllocator, LatLng latLng) {
        double radius = Double.parseDouble(context.getString(R.string.default_radius));
        return new LocationMemo("", "", latLng, radius, getDefaultDrawCircle(context), markerHueAllocator.allocate());
    }

    public static boolean getDefaultDrawCircle(Context context) {
        return new Prefs(context).get(kDefaultDrawCircle, true);
    }

    public static void setDefaultDrawCircle(Context context, boolean value) {
        new Prefs(context).put(kDefaultDrawCircle, value);
    }

    public void upsert(LocationMemo memo) {
        assert memo.id != -1;
// Path: app/src/main/java/com/github/gfx/hankei_n/toolbox/MarkerHueAllocator.java
// public class MarkerHueAllocator {
// 
//     static final String kMarkerHue = "marker_hue";
// 
//     static float INITIAL_HUE = BitmapDescriptorFactory.HUE_RED;
// 
//     final Prefs prefs;
// 
//     @Inject
//     public MarkerHueAllocator(Prefs prefs) {
//         this.prefs = prefs;
//     }
// 
//     public void reset() {
//         prefs.put(kMarkerHue, INITIAL_HUE);
//     }
// 
//     public float allocate() {
//         float hue = prefs.get(kMarkerHue, INITIAL_HUE);
//         prefs.put(kMarkerHue, (hue + 30.0f) % 360.0f);
//         return hue;
//     }
// }


// Path: app/src/main/java/com/github/gfx/hankei_n/model/LocationMemoManager.java
import com.google.android.gms.maps.model.LatLng;
import com.github.gfx.hankei_n.R;
import com.github.gfx.hankei_n.toolbox.MarkerHueAllocator;
import android.content.Context;
import java.util.Iterator;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.inject.Inject;
import javax.inject.Singleton;

    public LocationMemoManager(OrmaDatabase orma) {
        relation = orma.relationOfLocationMemo()
                .orderByIdAsc();
        count = relation.count();
    }

    public int count() {
        assert count == relation.count();
        return count;
    }

    public LocationMemo get(int i) {
        return relation.get(i);
    }

    public LocationMemo newMemo(Context context, MarkerHueAllocator markerHueAllocator, LatLng latLng) {
        double radius = Double.parseDouble(context.getString(R.string.default_radius));
        return new LocationMemo("", "", latLng, radius, getDefaultDrawCircle(context), markerHueAllocator.allocate());
    }

    public static boolean getDefaultDrawCircle(Context context) {
        return new Prefs(context).get(kDefaultDrawCircle, true);
    }

    public static void setDefaultDrawCircle(Context context, boolean value) {
        new Prefs(context).put(kDefaultDrawCircle, value);
    }

    public void upsert(LocationMemo memo) {
        assert memo.id != -1;
        if (memo.id == 0) {