package com.mogo.cloud.location;

import android.content.Context;
import android.util.Log;

import androidx.annotation.Keep;

import com.mogo.cloud.tanlu.bean.location.MogoLocation;

@Keep
public class MogoLocationInfoServices {

    private static final String TAG = "LocationInfoServices";

    private static volatile MogoLocationInfoServices sInstance;
    private MogoLocation mLocation;

    private MogoLocationInfoServices() {
    }

    @Keep
    public static MogoLocationInfoServices getInstance() {
        if (sInstance == null) {
            synchronized (MogoLocationInfoServices.class) {
                if (sInstance == null) {
                    sInstance = new MogoLocationInfoServices();
                }
            }
        }
        return sInstance;
    }

    public synchronized void release() {
        sInstance = null;
    }

    public void provideLocation(MogoLocation location) {
        mLocation = location;
    }

    public MogoLocation getLocation() {
        return mLocation;
    }

    public void start() {
        LocationManager.getInstance().start();
        Log.d(TAG, "sdk - start");
    }

    public void stop() {
        LocationManager.getInstance().stop();
        Log.d(TAG, "sdk - stop");
    }

    public void init(Context context) {
        LocationManager.getInstance().init(context);
        Log.d(TAG, "sdk - init");
    }
}
