| | |
| | | package com.driver.igotrip.base.gaode |
| | | |
| | | //import com.google.android.libraries.places.api.Places |
| | | //import com.google.android.libraries.places.api.model.* |
| | | //import com.google.android.libraries.places.api.net.FetchPlaceRequest |
| | | //import com.google.android.libraries.places.api.net.FindAutocompletePredictionsRequest |
| | | //import com.google.android.libraries.places.api.net.FindCurrentPlaceRequest |
| | | import android.Manifest |
| | | import android.annotation.SuppressLint |
| | | import android.content.Context |
| | | import android.content.Intent |
| | | import android.content.pm.PackageInfo |
| | | import android.content.pm.PackageManager |
| | | import android.graphics.Bitmap |
| | | import android.graphics.Color |
| | | import android.location.LocationManager |
| | | import android.net.Uri |
| | | import android.os.Handler |
| | | import android.os.Looper |
| | | import android.text.TextUtils |
| | |
| | | import cn.sinata.xldutils.utils.SPUtils |
| | | import com.driver.igotrip.R |
| | | import com.driver.igotrip.base.Const |
| | | import com.driver.igotrip.base.MyApplication |
| | | import com.driver.igotrip.base.MyBaseActivity.TAG |
| | | import com.driver.igotrip.bean.GoogleBackBean |
| | | import com.driver.igotrip.bean.GoogleNearBean2 |
| | | import com.driver.igotrip.bean.GoogleRouteBean |
| | | import com.google.android.gms.common.api.ApiException |
| | | import com.google.android.gms.maps.* |
| | | import com.google.android.gms.maps.model.* |
| | | //import com.google.android.libraries.places.api.Places |
| | | //import com.google.android.libraries.places.api.model.* |
| | | //import com.google.android.libraries.places.api.net.FetchPlaceRequest |
| | | //import com.google.android.libraries.places.api.net.FindAutocompletePredictionsRequest |
| | | //import com.google.android.libraries.places.api.net.FindCurrentPlaceRequest |
| | | import com.google.android.gms.maps.CameraUpdateFactory |
| | | import com.google.android.gms.maps.GoogleMap |
| | | import com.google.android.gms.maps.GoogleMapOptions |
| | | import com.google.android.gms.maps.SupportMapFragment |
| | | import com.google.android.gms.maps.model.BitmapDescriptor |
| | | import com.google.android.gms.maps.model.BitmapDescriptorFactory |
| | | import com.google.android.gms.maps.model.CameraPosition |
| | | import com.google.android.gms.maps.model.Circle |
| | | import com.google.android.gms.maps.model.CircleOptions |
| | | import com.google.android.gms.maps.model.LatLng |
| | | import com.google.android.gms.maps.model.LatLngBounds |
| | | import com.google.android.gms.maps.model.Marker |
| | | import com.google.android.gms.maps.model.MarkerOptions |
| | | import com.google.android.gms.maps.model.Polygon |
| | | import com.google.android.gms.maps.model.PolygonOptions |
| | | import com.google.android.gms.maps.model.Polyline |
| | | import com.google.android.gms.maps.model.PolylineOptions |
| | | import com.google.gson.Gson |
| | | import com.lljjcoder.style.citylist.Toast.ToastUtils |
| | | import okhttp3.* |
| | | import okhttp3.MediaType.Companion.toMediaTypeOrNull |
| | | import java.util.* |
| | | import okhttp3.OkHttpClient |
| | | import okhttp3.Request |
| | | import okhttp3.RequestBody |
| | | |
| | | |
| | | object AMapKit { |
| | |
| | | endLat: Double, |
| | | endLon: Double |
| | | ) { |
| | | // if (isAvilible(context, "com.google.android.apps.maps")) { |
| | | // val gmmIntentUri: Uri = Uri.parse("google.navigation:q=$endLat,$endLon") |
| | | // val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) |
| | | // mapIntent.setPackage("com.google.android.apps.maps") |
| | | // context.startActivity(mapIntent) |
| | | // } else { |
| | | // ToastUtils.showShortToast(context, context.getString(R.string.您尚未安装谷歌地图)) |
| | | // val uri: Uri = Uri.parse("market://details?id=com.google.android.apps.maps") |
| | | // var intent = Intent(Intent.ACTION_VIEW, uri) |
| | | // context.startActivity(intent) |
| | | // } |
| | | val intent = Intent(context, NaviGoogleActivity::class.java) |
| | | intent.putExtra("lat", endLat) |
| | | intent.putExtra("lon", endLon) |
| | | context.startActivity(intent) |
| | | } |
| | | |
| | | |
| | | /**检测应用是否安装 */ |
| | | private fun isAvilible(context: Context, packageName: String): Boolean { |
| | | val packageManager = context.packageManager //获取packagemanager |
| | | val pinfo: List<PackageInfo>? = packageManager.getInstalledPackages(0) //获取所有已安装程序的包信息 |
| | | val pName: MutableList<String> = ArrayList() //用于存储所有已安装程序的包名 |
| | | //从pinfo中将包名字逐一取出,压入pName list中 |
| | | if (pinfo != null) { |
| | | for (i in pinfo.indices) { |
| | | val pn: String = pinfo[i].packageName |
| | | pName.add(pn) |
| | | } |
| | | } |
| | | return pName.contains(packageName) //判断pName中是否有目标程序的包名,有TRUE,没有FALSE |
| | | } |
| | | } |