package com.abbidot.tracker.ui.common.map

import android.content.Context
import androidx.fragment.app.Fragment
import com.abbidot.baselibrary.util.AppUtils
import com.abbidot.tracker.base.BaseMapCommon
import com.abbidot.tracker.bean.HistoryDataBean
import com.abbidot.tracker.deprecated.ui.fragment.map.baidumap.NavigationBaiduMapFragment
import com.abbidot.tracker.ui.fragment.map.googlemap.WiFiZone2GoogleMapFragment

/**
 *Created  by .yzq on 2024/6/4/004.
 * @link
 * @description:
 */
class WifiZone2MapCommon : BaseMapCommon() {

    private var mWiFiZone2GoogleMapFragment: WiFiZone2GoogleMapFragment? = null
    private var mBaiduMapFragment: NavigationBaiduMapFragment? = null

    fun getMapFragment(context: Context): Fragment {
        return if (AppUtils.isChina(AppUtils.SWITCH_MAP_TYPE)) {
            mBaiduMapFragment = NavigationBaiduMapFragment.newInstance(context)
            mBaiduMapFragment!!
        } else {
            mWiFiZone2GoogleMapFragment = WiFiZone2GoogleMapFragment.newInstance(context)
            mWiFiZone2GoogleMapFragment!!
        }
    }

    fun refreshLocation() {
        mWiFiZone2GoogleMapFragment?.getLastLocation()
    }

    /**
     * 切换地图类型
     */
    fun switchSatelliteAndNormalMapType() {
        switchSatelliteAndNormalMapType(mBaiduMapFragment, mWiFiZone2GoogleMapFragment)
    }

    fun getDecWiFiAddressData(): HistoryDataBean? {
        if (null != mWiFiZone2GoogleMapFragment) {
            if (null !== mWiFiZone2GoogleMapFragment!!.mDecWifiAddressData) return mWiFiZone2GoogleMapFragment!!.mDecWifiAddressData
            return null
        }
        return null
    }
}