package com.navinfo.outdoor.util;

import android.content.Context;
import com.tencent.tencentmap.mapsdk.maps.LocationSource;


/**
 * 腾讯地图的当前位置数据源
 * */
public class MyTecentLocationSource implements LocationSource{
    private OnLocationChangedListener locationChangedListener;
    private Context mContext;
    /**
     * 初始化locationSource，务必在MapActivity界面中调用，保证传入的Context在整个应用生命周期中不会被销毁
     * */
    public MyTecentLocationSource(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public void activate(OnLocationChangedListener onLocationChangedListener) {
        locationChangedListener = onLocationChangedListener;
        TecentLocationUtils.getInstance(mContext).getLocationChangedListenerList().add(onLocationChangedListener);
    }

    @Override
    public void deactivate() {
        if (locationChangedListener!=null) {
            TecentLocationUtils.getInstance(mContext).getLocationChangedListenerList().remove(locationChangedListener);
        }
    }


}
