| | |
| | | import com.google.gson.JsonObject |
| | | import com.igo.user.data.HomeDatas |
| | | import com.igo.user.network.entity.Anchor |
| | | import com.igo.user.network.entity.AutoCompleteBean |
| | | import com.igo.user.network.entity.CarPrice |
| | | import com.igo.user.network.entity.City |
| | | import com.igo.user.network.entity.Coupon |
| | |
| | | import com.igo.user.network.entity.EmailBean |
| | | import com.igo.user.network.entity.Evaluation |
| | | import com.igo.user.network.entity.Function |
| | | import com.igo.user.network.entity.GPoiBean |
| | | import com.igo.user.network.entity.GeoBean |
| | | import com.igo.user.network.entity.Goods |
| | | import com.igo.user.network.entity.GoogleToken |
| | | import com.igo.user.network.entity.InviteHis |
| | |
| | | import com.igo.user.network.entity.OpenCity |
| | | import com.igo.user.network.entity.Order |
| | | import com.igo.user.network.entity.Phone |
| | | import com.igo.user.network.entity.PlaceDetailBean |
| | | import com.igo.user.network.entity.Point |
| | | import com.igo.user.network.entity.RealName |
| | | import com.igo.user.network.entity.RouteBean |
| | | import com.igo.user.network.entity.SearchBean |
| | | import com.igo.user.network.entity.SeatInfo |
| | | import com.igo.user.network.entity.ServiceRecord |
| | | import com.igo.user.network.entity.Shift |
| | |
| | | @POST(Apis.queryGoodsInfo) |
| | | fun queryGoodsInfo(@Field("id") pageNum:Int,@Field("sign") sign:String, |
| | | @Field("appid") appid:String): Flowable<ResultData<Goods>> |
| | | |
| | | @POST(Apis.getPoi) |
| | | fun getPoi(@Query("location")location:String,@Query("radius")radius:Int = 2000,@Query("key")key:String = Const.google_key, |
| | | @Query("language")language:String): Flowable<GPoiBean> |
| | | |
| | | @POST(Apis.geoCode) |
| | | fun geoCode(@Header("X-Goog-Maps-Experience-ID") tripId:String,@Query("latlng")location:String,@Query("language")language:String,@Query("key")key:String = Const.google_key, |
| | | @Query("appid")appid:String = "c780a308a35740bfb946e10452ba62e0"): Flowable<GeoBean> |
| | | |
| | | @POST(Apis.textsearch) |
| | | fun textsearch(@Header("X-Goog-Maps-Experience-ID") tripId:String,@Query("query")query:String,@Query("location")location:String?, |
| | | @Query("language")language:String,@Query("radius")radius:Int = 25000,@Query("key")key:String = Const.google_key): Flowable<SearchBean> |
| | | |
| | | @POST(Apis.autocomplete) |
| | | fun autocomplete(@Header("X-Goog-Maps-Experience-ID") tripId:String,@Query("input")query:String, @Query("language")language:String,@Query("components")region:String="country:gh", |
| | | @Query("key")key:String = Const.google_key): Flowable<AutoCompleteBean> |
| | | |
| | | @POST(Apis.placeDetails) |
| | | fun placeDetails(@Header("X-Goog-Maps-Experience-ID") tripId:String,@Query("place_id")place_id:String, @Query("fields")region:String="name,geometry", |
| | | @Query("key")key:String = Const.google_key): Flowable<PlaceDetailBean> |
| | | |
| | | @POST(Apis.directions) |
| | | fun directions(@Header("X-Goog-Maps-Experience-ID") tripId:String,@Query("origin")origin:String,@Query("destination")destination:String,@Query("language")language:String,@Query("mode")mode:String = "driving", |
| | | @Query("key")key:String = Const.google_key): Flowable<RouteBean> |
| | | |
| | | @POST(Apis.getFleetEngineAuth) |
| | | fun getFleetEngineAuth(@Query("tripId")origin:String): Flowable<ResultData<GoogleToken>> |
| | |
| | | const val getEmailList = "api/user/getEmailList" |
| | | const val queryRechargeRecord = "api/user/queryRechargeRecord" |
| | | |
| | | /** |
| | | * Google |
| | | */ |
| | | const val getPoi = "https://maps.googleapis.com/maps/api/place/nearbysearch/json" |
| | | const val geoCode = "https://maps.googleapis.com/maps/api/geocode/json" |
| | | const val textsearch = "https://maps.googleapis.com/maps/api/place/textsearch/json" |
| | | const val directions = "https://maps.googleapis.com/maps/api/directions/json" |
| | | const val autocomplete = "https://maps.googleapis.com/maps/api/place/autocomplete/json" |
| | | const val placeDetails = "https://maps.googleapis.com/maps/api/place/details/json" |
| | | |
| | | |
| | | |
| | | const val getOrderDrivingData = "api/taxi/getOrderDrivingData" //服务中手动刷新下方行程数据 |
| | | |
| | | |
| New file |
| | |
| | | package com.igo.user.network |
| | | |
| | | import com.igo.user.network.entity.AutoCompleteBean |
| | | import com.igo.user.network.entity.GPoiBean |
| | | import com.igo.user.network.entity.GeoBean |
| | | import com.igo.user.network.entity.PlaceDetailBean |
| | | import com.igo.user.network.entity.RouteBean |
| | | import com.igo.user.network.entity.SearchBean |
| | | import com.igo.user.utils.Const |
| | | import io.reactivex.Flowable |
| | | import retrofit2.http.Header |
| | | import retrofit2.http.POST |
| | | import retrofit2.http.Query |
| | | |
| | | interface GoogleApiService { |
| | | |
| | | @POST(GoogleApis.getPoi) |
| | | fun getPoi( |
| | | @Query("location") location: String, @Query("radius") radius: Int = 2000, @Query("key") key: String = Const.google_key, |
| | | @Query("language") language: String |
| | | ): Flowable<GPoiBean> |
| | | |
| | | @POST(GoogleApis.geoCode) |
| | | fun geoCode( |
| | | @Header("X-Goog-Maps-Experience-ID") tripId: String, |
| | | @Query("latlng") location: String, |
| | | @Query("language") language: String, |
| | | @Query("key") key: String = Const.google_key, |
| | | @Query("appid") appid: String = "c780a308a35740bfb946e10452ba62e0" |
| | | ): Flowable<GeoBean> |
| | | |
| | | @POST(GoogleApis.textsearch) |
| | | fun textsearch( |
| | | @Header("X-Goog-Maps-Experience-ID") tripId: String, @Query("query") query: String, @Query("location") location: String?, |
| | | @Query("language") language: String, @Query("radius") radius: Int = 25000, @Query("key") key: String = Const.google_key |
| | | ): Flowable<SearchBean> |
| | | |
| | | @POST(GoogleApis.autocomplete) |
| | | fun autocomplete( |
| | | @Header("X-Goog-Maps-Experience-ID") tripId: String, |
| | | @Query("input") query: String, |
| | | @Query("language") language: String, |
| | | @Query("components") region: String = "country:gh", |
| | | @Query("key") key: String = Const.google_key |
| | | ): Flowable<AutoCompleteBean> |
| | | |
| | | @POST(GoogleApis.placeDetails) |
| | | fun placeDetails( |
| | | @Header("X-Goog-Maps-Experience-ID") tripId: String, @Query("place_id") place_id: String, @Query("fields") region: String = "name,geometry", |
| | | @Query("key") key: String = Const.google_key |
| | | ): Flowable<PlaceDetailBean> |
| | | |
| | | @POST(GoogleApis.directions) |
| | | fun directions( |
| | | @Header("X-Goog-Maps-Experience-ID") tripId: String, |
| | | @Query("origin") origin: String, |
| | | @Query("destination") destination: String, |
| | | @Query("language") language: String, |
| | | @Query("mode") mode: String = "driving", |
| | | @Query("key") key: String = Const.google_key |
| | | ): Flowable<RouteBean> |
| | | } |
| New file |
| | |
| | | package com.igo.user.network |
| | | |
| | | /** |
| | | * Google相关Api |
| | | */ |
| | | object GoogleApis { |
| | | |
| | | const val getPoi = "https://maps.googleapis.com/maps/api/place/nearbysearch/json" |
| | | const val geoCode = "https://maps.googleapis.com/maps/api/geocode/json" |
| | | const val textsearch = "https://maps.googleapis.com/maps/api/place/textsearch/json" |
| | | const val directions = "https://maps.googleapis.com/maps/api/directions/json" |
| | | const val autocomplete = "https://maps.googleapis.com/maps/api/place/autocomplete/json" |
| | | const val placeDetails = "https://maps.googleapis.com/maps/api/place/details/json" |
| | | |
| | | } |
| | |
| | | object HttpManager { |
| | | private const val PAGE_SIZE = 20 |
| | | private val service: ApiService = RRetrofit.instance().create(ApiService::class.java) |
| | | private val googleService: GoogleApiService = RRetrofit.instance(false).create(GoogleApiService::class.java) |
| | | |
| | | /** |
| | | * 发起请求方法 |
| | | */ |
| | | private fun request() = service |
| | | |
| | | /** |
| | | * 发起请求方法 |
| | | */ |
| | | private fun googleRequest() = googleService |
| | | |
| | | private fun getAppId() = SPUtils.instance().getString(Const.User.APP_ID) |
| | | /** |
| | |
| | | //1=简体中文,2=英语,3=法语 |
| | | val language = LanguageUtil.getLanguage() |
| | | val lan = if (language == Const.Language.CHINESE) "zh-CN" else language |
| | | return request().geoCode(IGoApplication.tripId,"${lat},${lon}",lan) |
| | | return googleRequest().geoCode(IGoApplication.tripId,"${lat},${lon}",lan) |
| | | } |
| | | |
| | | /** |
| | |
| | | //1=简体中文,2=英语,3=法语 |
| | | val language = LanguageUtil.getLanguage() |
| | | val lan = if (language == Const.Language.CHINESE) "zh-CN" else language |
| | | return request().textsearch(IGoApplication.tripId,key,"${lat},${lon}",lan) |
| | | return googleRequest().textsearch(IGoApplication.tripId,key,"${lat},${lon}",lan) |
| | | // return request().textsearch(key,5.586363,-0.187788,IGoApplication.chooseCityName,lan) //阿克拉 5.586363,-0.187788 |
| | | } |
| | | |
| | |
| | | //1=简体中文,2=英语,3=法语 |
| | | val language = LanguageUtil.getLanguage() |
| | | val lan = if (language == Const.Language.CHINESE) "zh-CN" else language |
| | | return request().autocomplete(IGoApplication.tripId,key,lan,"country:$country") |
| | | return googleRequest().autocomplete(IGoApplication.tripId,key,lan,"country:$country") |
| | | } |
| | | |
| | | /** |
| | | * 搜索2:获取经纬度 |
| | | */ |
| | | fun placeDetails(placeId:String): Flowable<PlaceDetailBean> { |
| | | return request().placeDetails(IGoApplication.tripId,placeId) |
| | | return googleRequest().placeDetails(IGoApplication.tripId,placeId) |
| | | } |
| | | |
| | | /** |
| | |
| | | fun directions(startLat: Double,startLon: Double,endLat: Double,endLon: Double): Flowable<RouteBean> { |
| | | val language = LanguageUtil.getLanguage() |
| | | val lan = if (language == Const.Language.CHINESE) "zh-CN" else language |
| | | return request().directions(IGoApplication.tripId,"${startLat},${startLon}","${endLat},${endLon}",lan) |
| | | return googleRequest().directions(IGoApplication.tripId,"${startLat},${startLon}","${endLat},${endLon}",lan) |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 网络请求retrofit初始化。 |
| | | */ |
| | | class RRetrofit private constructor() { |
| | | class RRetrofit(val isUseCert: Boolean = false) { |
| | | |
| | | private val loggingInterceptor by lazy { |
| | | LoggingInterceptor() |
| | |
| | | chain.proceed(request) |
| | | } |
| | | .apply { |
| | | createTrustManager(R.raw.star_gopost_ci)?.also { |
| | | sslSocketFactory(getSSLSocketFactory(it), it) |
| | | if (isUseCert) { |
| | | createTrustManager(R.raw.star_gopost_ci)?.also { |
| | | sslSocketFactory(getSSLSocketFactory(it), it) |
| | | } |
| | | } |
| | | if (BuildConfig.DEBUG) { |
| | | addInterceptor(loggingInterceptor) |
| | |
| | | .build() |
| | | |
| | | companion object { |
| | | fun instance() = RRetrofit() |
| | | fun instance(isUseCert: Boolean = true) = RRetrofit(isUseCert) |
| | | fun getLanguageType(language: String): String { |
| | | return when (language) { |
| | | Const.Language.CHINESE -> "1" |