| | |
| | | import android.content.Intent |
| | | import android.os.* |
| | | import android.util.Log |
| | | import android.view.View |
| | | import androidx.fragment.app.Fragment |
| | | import androidx.fragment.app.FragmentManager |
| | | import cn.sinata.rxnetty.LogHelper.initLogs |
| | |
| | | } |
| | | |
| | | Const.SOCKET_METHOD.OFFLINE -> { |
| | | logRecord("socket==>账号被挤下线:$data") |
| | | val simpleData = |
| | | Gson().fromJson( |
| | | data, |
| | |
| | | } |
| | | |
| | | Const.SOCKET_METHOD.AFTER_WORK -> { |
| | | logRecord("socket==>强制下线:$data") |
| | | val simpleData = |
| | | Gson().fromJson( |
| | | data, |
| | |
| | | } |
| | | |
| | | Const.SOCKET_METHOD.ORDER_STATUS -> { |
| | | logRecord("socket==>订单状态改变:$data") |
| | | val orderSimpleData = |
| | | Gson().fromJson( |
| | | data, |
| | |
| | | } |
| | | |
| | | Const.SOCKET_METHOD.OFFLINE_PAYMENT -> { |
| | | logRecord("socket==>离线支付:$data") |
| | | val orderSimpleData = |
| | | Gson().fromJson( |
| | | data, |
| | |
| | | } |
| | | |
| | | Const.SOCKET_METHOD.FROZEN_ORDER -> { |
| | | logRecord("socket==>冻结订单:$data") |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.MODIFY_ADDRESS_SUC)) |
| | | } |
| | | |
| | | Const.SOCKET_METHOD.REASSIGN -> { |
| | | logRecord("socket==>改派:$data") |
| | | Log.e( |
| | | "zmc-socket", |
| | | "EventBus.getDefault().post(BaseEvent(BaseEvent.REFREASH_MAIN))" |
| | |
| | | Const.SOCKET_METHOD.MODIFY_ADDRESS -> { |
| | | val jsob = JSONObject(data) |
| | | // if (jsob.optString("status") == "1") { // 只处理 申请订单消息 |
| | | logRecord("socket==>修改目的地:$jsob") |
| | | val act = activities[activities.size - 1] |
| | | (act as PublicServiceActivity).modifyAddress( |
| | | jsob.optString("audioUrl"), |
| | |
| | | |
| | | Const.SOCKET_METHOD.ORDER_TIME_OUT -> { |
| | | val jsob = JSONObject(data) |
| | | logRecord("socket==>订单超时:$jsob") |
| | | val act = activities[activities.size - 1] |
| | | |
| | | /** |
| | |
| | | |
| | | Const.SOCKET_METHOD.DIFFERENCE -> { |
| | | val jsob = JSONObject(data) |
| | | logRecord("socket==>补差价:$jsob") |
| | | when (jsob.optString("status")) { // status 1=申请,2=同意,3=拒绝 |
| | | "1" -> {} |
| | | "2" -> { |
| | |
| | | if (getUserId() != -1) { |
| | | val map = getMapByAny() |
| | | callNet1(this, Api.getDriverOrderMessage, map, clickAction = { |
| | | logRecord(TAG, "getOrderWhenNoSocket 获取订单成功 $it") |
| | | logRecord("getOrderWhenNoSocket 获取订单成功 $it") |
| | | initnetdata(it ?: "") |
| | | }, { |
| | | logRecord(TAG, "getOrderWhenNoSocket 获取订单失败") |
| | | logRecord("getOrderWhenNoSocket 获取订单失败") |
| | | }, false) |
| | | } |
| | | } |
| | |
| | | map["driverId"] = getUserId() |
| | | map["lon"] = aMapLocation!!.longitude |
| | | map["lat"] = aMapLocation!!.latitude |
| | | logRecord(TAG, "sendLocation 发送定位参数" + Gson().toJson(map)) |
| | | logRecord("sendLocation 发送定位参数" + Gson().toJson(map)) |
| | | callNet1(this, Api.saveOrderPosition, map, clickAction = { |
| | | logRecord(TAG, "sendLocation 发送定位成功") |
| | | logRecord("sendLocation 发送定位成功") |
| | | }, { |
| | | logRecord(TAG, "sendLocation 发送定位失败") |
| | | logRecord("sendLocation 发送定位失败") |
| | | }, false) |
| | | |
| | | val map1 = getMapByAny() |
| | |
| | | map1["directionAngle"] = 0 |
| | | |
| | | callNet1(this, Api.positionSocket, map1, clickAction = { |
| | | logRecord(TAG, "positionSocket 发送定位成功") |
| | | logRecord("positionSocket 发送定位成功") |
| | | }, { |
| | | logRecord(TAG, "positionSocket 发送定位失败") |
| | | logRecord("positionSocket 发送定位失败") |
| | | }, false) |
| | | } |
| | | } |
| | |
| | | val TAG = "MyApplication" |
| | | private fun sendHeart() { |
| | | if (getUserId() != -1) { |
| | | logRecord(TAG, "sendHeart: userId = " + getUserId()) |
| | | logRecord("sendHeart: userId = " + getUserId()) |
| | | val bean = HeartBean() |
| | | bean.data = HeartBean.DataBean() |
| | | NettyClient.getInstance().sendMessage(Gson().toJson(bean)) |
| | |
| | | testHeartNunm++ |
| | | // if ((System.currentTimeMillis() - currentTime) / 1000 > 3) { |
| | | // sysErr("sendHeart_websocket 重新连接") |
| | | logRecord(TAG, "sendHeart check socket status") |
| | | logRecord("sendHeart check socket status") |
| | | currentTime = System.currentTimeMillis() |
| | | val nettyState = NettyClient.getInstance().checkNettyState() |
| | | if (!nettyState) { |
| | |
| | | |
| | | override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { |
| | | activities.add(activity) |
| | | Log.i("zmc-pageA", "onActivityCreated: " + activity.javaClass.name) |
| | | logRecord("onActivityCreated: " + activity.javaClass.name) |
| | | if (activity is MyBaseActivity) { |
| | | activity.supportFragmentManager.registerFragmentLifecycleCallbacks(object : |
| | | FragmentManager.FragmentLifecycleCallbacks() { |
| | |
| | | savedInstanceState: Bundle? |
| | | ) { |
| | | super.onFragmentCreated(fm, f, savedInstanceState) |
| | | Log.i("zmc-pageF", "onFragmentCreated: " + f.javaClass.name) |
| | | logRecord("onFragmentCreated: " + f.javaClass.name) |
| | | } |
| | | |
| | | override fun onFragmentViewCreated( |
| | | fm: FragmentManager, |
| | | f: Fragment, |
| | | v: View, |
| | | savedInstanceState: Bundle? |
| | | ) { |
| | | super.onFragmentViewCreated(fm, f, v, savedInstanceState) |
| | | logRecord("onFragmentViewCreated: " + f.javaClass.name) |
| | | } |
| | | |
| | | override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) { |
| | | super.onFragmentViewDestroyed(fm, f) |
| | | logRecord("onFragmentViewDestroyed: " + f.javaClass.name) |
| | | } |
| | | |
| | | override fun onFragmentDestroyed(fm: FragmentManager, f: Fragment) { |
| | | super.onFragmentDestroyed(fm, f) |
| | | Log.e("zmc-pageF", "onFragmentDestroyed: " + f.javaClass.name) |
| | | logRecord("onFragmentDestroyed: " + f.javaClass.name) |
| | | } |
| | | }, true) |
| | | } |
| | |
| | | |
| | | override fun onActivityStarted(activity: Activity) { |
| | | showNum++ |
| | | Log.d("zmc-pageA", "onActivityStarted: " + activity.javaClass.name) |
| | | } |
| | | |
| | | override fun onActivityResumed(activity: Activity) { |
| | | // Log.i("zmc-pageA", "onActivityResumed: " + activity.javaClass.name) |
| | | logRecord("onActivityResumed: " + activity.javaClass.name) |
| | | } |
| | | |
| | | override fun onActivityPaused(activity: Activity) { |
| | | // Log.e("zmc-pageA", "onActivityPaused: " + activity.javaClass.name) |
| | | // logRecord("onActivityPaused: " + activity.javaClass.name) |
| | | } |
| | | |
| | | override fun onActivityStopped(activity: Activity) { |
| | | Log.e("zmc-pageA", "onActivityStopped: " + activity.javaClass.name) |
| | | logRecord("onActivityStopped: " + activity.javaClass.name) |
| | | showNum-- |
| | | Handler(Looper.getMainLooper()).postDelayed({ |
| | | if (showNum == 0 && isPlayVoice) { |
| | |
| | | } |
| | | |
| | | override fun onActivityDestroyed(activity: Activity) { |
| | | Log.d("zmc-pageA", "onActivityDestroyed: " + activity.javaClass.name) |
| | | logRecord("onActivityDestroyed: " + activity.javaClass.name) |
| | | activities.remove(activity) |
| | | } |
| | | |
| | | override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) { |
| | | // Log.d("zmc-pageA", "onActivitySaveInstanceState: " + activity.javaClass.name) |
| | | // logRecord("onActivitySaveInstanceState: " + activity.javaClass.name) |
| | | } |
| | | |
| | | } |
| | |
| | | import com.driver.igotrip.R |
| | | import com.driver.igotrip.base.BaseEvent |
| | | import com.driver.igotrip.base.Const |
| | | import com.driver.igotrip.base.MyApplication |
| | | import com.driver.igotrip.base.MyBaseActivity |
| | | import com.google.android.gms.maps.GoogleMap |
| | | import com.google.android.libraries.navigation.* |
| | | import com.google.android.gms.maps.model.LatLng |
| | | import com.google.android.libraries.navigation.NavigationApi |
| | | import com.google.android.libraries.navigation.NavigationApi.NavigatorListener |
| | | import com.google.android.libraries.navigation.Navigator |
| | | import com.google.android.libraries.navigation.Navigator.RouteStatus |
| | | import com.google.android.libraries.navigation.RoadSnappedLocationProvider |
| | | import com.google.android.libraries.navigation.RoutingOptions |
| | | import com.google.android.libraries.navigation.SimulationOptions |
| | | import com.google.android.libraries.navigation.SupportNavigationFragment |
| | | import com.google.android.libraries.navigation.Waypoint |
| | | import com.google.android.libraries.navigation.Waypoint.UnsupportedPlaceIdException |
| | | |
| | | |
| | | class NaviGoogleActivity: MyBaseActivity() { |
| | | class NaviGoogleActivity : MyBaseActivity() { |
| | | override fun setContentView() { |
| | | setContentView(R.layout.activity_navgoogle) |
| | | } |
| | | |
| | | private var mNavigator: Navigator? = null |
| | | private var mNavFragment: SupportNavigationFragment? = null |
| | | private var mRoutingOptions: RoutingOptions? = null |
| | | |
| | | private val lat by lazy { intent.getDoubleExtra("lat",0.0) } |
| | | private val lon by lazy { intent.getDoubleExtra("lon",0.0) } |
| | | private var roadSnappedLocationProvider: RoadSnappedLocationProvider? = null |
| | | private val lat by lazy { intent.getDoubleExtra("lat", 0.0) } |
| | | private val lon by lazy { intent.getDoubleExtra("lon", 0.0) } |
| | | |
| | | override fun initView() { |
| | | showTitle(false) |
| | | checkPermission() |
| | | } |
| | | |
| | | private fun checkPermission(){ |
| | | private fun checkPermission() { |
| | | if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { |
| | | initializeNavigationSdk() |
| | | } else { |
| | |
| | | */ |
| | | @SuppressLint("MissingPermission") |
| | | override fun onNavigatorReady(navigator: Navigator) { |
| | | Log.e(Const.GoogleDriver.TAG,"Navigator ready.") |
| | | Log.e(Const.GoogleDriver.TAG, "Navigator ready.") |
| | | mNavigator = navigator |
| | | mNavFragment = supportFragmentManager.findFragmentById(R.id.navigation_fragment) as SupportNavigationFragment |
| | | mNavFragment = |
| | | supportFragmentManager.findFragmentById(R.id.navigation_fragment) as SupportNavigationFragment |
| | | |
| | | // Set the last digit of the car's license plate to get route restrictions |
| | | // in supported countries. (optional) |
| | |
| | | |
| | | // Navigate to a place |
| | | navigateToPlace(lat, lon) |
| | | |
| | | initLocationListener() |
| | | } |
| | | |
| | | /** |
| | |
| | | "Error loading Navigation SDK: Your API key is " |
| | | + "invalid or not authorized to use the Navigation SDK." |
| | | ) |
| | | |
| | | NavigationApi.ErrorCode.TERMS_NOT_ACCEPTED -> displayMessage( |
| | | ("Error loading Navigation SDK: User did not accept " |
| | | + "the Navigation Terms of Use.") |
| | | ) |
| | | |
| | | NavigationApi.ErrorCode.NETWORK_ERROR -> displayMessage("Error loading Navigation SDK: Network error.") |
| | | NavigationApi.ErrorCode.LOCATION_PERMISSION_MISSING -> displayMessage( |
| | | ("Error loading Navigation SDK: Location permission " |
| | | + "is missing.") |
| | | ) |
| | | |
| | | else -> displayMessage("Error loading Navigation SDK: $errorCode") |
| | | } |
| | | } |
| | | |
| | | }) |
| | | |
| | | |
| | | } |
| | | |
| | | private fun navigateToPlace(lat:Double,lon:Double) { |
| | | private fun navigateToPlace(lat: Double, lon: Double) { |
| | | val destination: Waypoint = try { |
| | | Waypoint.builder().setLatLng(lat,lon).build() |
| | | Waypoint.builder().setLatLng(lat, lon).build() |
| | | } catch (e: UnsupportedPlaceIdException) { |
| | | displayMessage("Error starting navigation: Place ID is not supported.") |
| | | return |
| | |
| | | // Start turn-by-turn guidance along the current route. |
| | | mNavigator!!.startGuidance() |
| | | } |
| | | |
| | | RouteStatus.NO_ROUTE_FOUND -> displayMessage("Error starting navigation: No route found.") |
| | | RouteStatus.NETWORK_ERROR -> displayMessage("Error starting navigation: Network error.") |
| | | RouteStatus.ROUTE_CANCELED -> displayMessage("Error starting navigation: Route canceled.") |
| | |
| | | } |
| | | |
| | | override fun onEventMainThread(event: BaseEvent?) { |
| | | if (event?.code == BaseEvent.RELOAD_NAVI){ |
| | | navigateToPlace(event!!.msg.toDouble(),event.msgTwo.toDouble()) |
| | | if (event?.code == BaseEvent.RELOAD_NAVI) { |
| | | navigateToPlace(event!!.msg.toDouble(), event.msgTwo.toDouble()) |
| | | } |
| | | } |
| | | |
| | | private fun displayMessage(s: String) { |
| | | Log.e(Const.GoogleDriver.TAG,s) |
| | | Log.e(Const.GoogleDriver.TAG, s) |
| | | } |
| | | |
| | | override fun setOnclick() { |
| | |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | mNavigator?.stopGuidance() |
| | | removeLocationListener() |
| | | } |
| | | |
| | | //初始化定位监听 |
| | | private fun initLocationListener() { |
| | | roadSnappedLocationProvider = NavigationApi.getRoadSnappedLocationProvider(application) |
| | | roadSnappedLocationProvider?.addLocationListener(listener) |
| | | } |
| | | |
| | | //移除定位监听 |
| | | private fun removeLocationListener() { |
| | | roadSnappedLocationProvider?.removeLocationListener(listener) |
| | | roadSnappedLocationProvider = null |
| | | } |
| | | |
| | | private val listener = RoadSnappedLocationProvider.LocationListener { |
| | | MyApplication.aMapLocation = LatLng(it.latitude, it.longitude) |
| | | } |
| | | } |
| New file |
| | |
| | | package com.driver.igotrip.extension |
| | | |
| | | //扩展函数 清除无效0 |
| | | fun String.extClearInvalidZero(): String { |
| | | if (endsWith(".000")) { |
| | | return replace(".000", "") |
| | | } |
| | | if (endsWith(".00")) { |
| | | return replace(".00", "") |
| | | } |
| | | if (endsWith(".0")) { |
| | | return replace(".0", "") |
| | | } |
| | | return this |
| | | } |
| | |
| | | import android.view.View |
| | | import android.widget.ImageView |
| | | import android.widget.TextView |
| | | import cn.sinata.xldutils.utils.* |
| | | import com.google.android.gms.maps.model.LatLng |
| | | import cn.sinata.xldutils.utils.Toast |
| | | import cn.sinata.xldutils.utils.clickDelay |
| | | import cn.sinata.xldutils.utils.doubleTwo |
| | | import cn.sinata.xldutils.utils.gone |
| | | import cn.sinata.xldutils.utils.sysErr |
| | | import cn.sinata.xldutils.utils.visible |
| | | import com.blankj.utilcode.util.ScreenUtils |
| | | import com.driver.igotrip.R |
| | | import com.driver.igotrip.base.MyApplication |
| | | import com.driver.igotrip.base.PublicServiceDialogActivity |
| | | import com.driver.igotrip.base.gaode.AMapKit |
| | | import com.driver.igotrip.bean.OrderBean |
| | | import com.driver.igotrip.netUtls.* |
| | | import com.driver.igotrip.netUtls.Api |
| | | import com.driver.igotrip.netUtls.callNet |
| | | import com.driver.igotrip.netUtls.callNet1 |
| | | import com.driver.igotrip.netUtls.createView |
| | | import com.driver.igotrip.netUtls.getMapByAny |
| | | import com.driver.igotrip.netUtls.timeOver |
| | | import com.driver.igotrip.ui.UiUtil |
| | | import com.driver.igotrip.ui.main.small_cargo.SmallCargoActivity |
| | | import com.google.android.gms.maps.GoogleMap |
| | | import com.google.android.gms.maps.OnMapReadyCallback |
| | | import com.google.android.gms.maps.SupportMapFragment |
| | | import com.google.android.gms.maps.model.LatLng |
| | | import com.google.gson.Gson |
| | | import org.jetbrains.anko.find |
| | | import org.jetbrains.anko.startActivity |
| | | import org.jetbrains.anko.toast |
| | | |
| | | class GetOrderFragment : PublicServiceDialogActivity(), OnMapReadyCallback, |
| | | GoogleMap.OnMyLocationClickListener { |
| | |
| | | |
| | | lateinit var time: CountDownTimer |
| | | |
| | | private val rl_parent by lazy { find<View>(R.id.rl_parent) } |
| | | private val tv_time by lazy { find<TextView>(R.id.tv_time) } |
| | | private val tv_car_type by lazy { find<TextView>(R.id.tv_car_type) } |
| | | |
| | |
| | | override fun onCreate(savedInstanceState: Bundle?) { |
| | | super.onCreate(savedInstanceState) |
| | | //实例化语音引擎 |
| | | |
| | | window.setLayout(ScreenUtils.getScreenWidth(), ScreenUtils.getScreenHeight()) |
| | | rl_parent.setOnClickListener { } |
| | | } |
| | | |
| | | override fun initView() { |
| | |
| | | import android.widget.Toast |
| | | import cn.sinata.rxnetty.NettyClient |
| | | import cn.sinata.xldutils.utils.SPUtils |
| | | import cn.sinata.xldutils.utils.Utils |
| | | import cn.sinata.xldutils.utils.clickDelay |
| | | import cn.sinata.xldutils.utils.doubleOne |
| | | import cn.sinata.xldutils.utils.getVersionName |
| | | import cn.sinata.xldutils.utils.gone |
| | | import cn.sinata.xldutils.utils.setDrawableLeft |
| | | import cn.sinata.xldutils.utils.textColor |
| | | import com.driver.igotrip.BuildConfig |
| | | import com.driver.igotrip.R |
| | | import com.driver.igotrip.base.BaseEvent |
| | | import com.driver.igotrip.base.Const |
| | |
| | | } |
| | | |
| | | var homeDataBean: HomeDataBean? = null |
| | | /* var navigator: Navigator? = null |
| | | var vehicleReporter: RidesharingVehicleReporter? = null*/ |
| | | /* var navigator: Navigator? = null |
| | | var vehicleReporter: RidesharingVehicleReporter? = null*/ |
| | | |
| | | private val MSG_REFRESH_LOCATIAON = 1 |
| | | |
| | |
| | | |
| | | override fun setContentView() { |
| | | setContentView(R.layout.activity_main) |
| | | /* lifecycleScope.launch { |
| | | while (true){ |
| | | delay(5000) |
| | | var map = getMapByAny() |
| | | callNet(false,getDriverOrderMessage, map) { |
| | | Log.e("长连接接口消息: ",it.toString() ) |
| | | } |
| | | } |
| | | }*/ |
| | | /* lifecycleScope.launch { |
| | | while (true){ |
| | | delay(5000) |
| | | var map = getMapByAny() |
| | | callNet(false,getDriverOrderMessage, map) { |
| | | Log.e("长连接接口消息: ",it.toString() ) |
| | | } |
| | | } |
| | | }*/ |
| | | } |
| | | |
| | | override fun initView() { |
| | | // setTitleText(getString(R.string.IGO司机)) |
| | | // setTitleText(getString(R.string.IGO司机)) |
| | | tv_Left.setDrawableLeft(R.mipmap.icon_nav_user) |
| | | // iv_right_title.setImageResource(R.mipmap.icon_nav_news) |
| | | // iv_right_title.setImageResource(R.mipmap.icon_nav_news) |
| | | |
| | | findViewById<View>(R.id.img_leftuser).setOnClickListener { |
| | | startActivity<MineActivity>() |
| | |
| | | // showOrder("","12634","1",10,1) |
| | | } |
| | | |
| | | // initDriver() |
| | | // initDriver() |
| | | MyApplication.isLogin = true |
| | | beOnDuty(false) |
| | | initCall() |
| | |
| | | /** |
| | | * 初始化司机sdk |
| | | */ |
| | | /* private fun initDriver() { |
| | | if (CacheKey.getKeyStr("vehicleId").isNullOrEmpty()) |
| | | return |
| | | NavigationApi.getNavigator( |
| | | this, // Activity |
| | | object : NavigationApi.NavigatorListener { |
| | | override fun onError(p0: Int) { |
| | | Log.e(Const.GoogleDriver.TAG, "初始化司机sdk失败$p0") |
| | | } |
| | | /* private fun initDriver() { |
| | | if (CacheKey.getKeyStr("vehicleId").isNullOrEmpty()) |
| | | return |
| | | NavigationApi.getNavigator( |
| | | this, // Activity |
| | | object : NavigationApi.NavigatorListener { |
| | | override fun onError(p0: Int) { |
| | | Log.e(Const.GoogleDriver.TAG, "初始化司机sdk失败$p0") |
| | | } |
| | | |
| | | override fun onNavigatorReady(navigator: Navigator) { |
| | | // Keep a reference to the Navigator (used to configure and start nav) |
| | | this@MainActivity.navigator = navigator |
| | | Log.e(Const.GoogleDriver.TAG, "初始化司机sdk成功") |
| | | val driverContext = |
| | | DriverContext.builder(application) |
| | | //.setProviderId("i-go-odrd-testing") |
| | | .setProviderId("gopost-475301") |
| | | .setVehicleId(CacheKey.getKeyStr("vehicleId")) |
| | | .setAuthTokenFactory(JsonAuthTokenFactory()) |
| | | .setNavigator(navigator) |
| | | .setRoadSnappedLocationProvider( |
| | | NavigationApi.getRoadSnappedLocationProvider( |
| | | application |
| | | ) |
| | | ) |
| | | .setDriverStatusListener(this@MainActivity) |
| | | .build() |
| | | val ridesharingDriverApi = RidesharingDriverApi.createInstance(driverContext) |
| | | vehicleReporter = ridesharingDriverApi.ridesharingVehicleReporter |
| | | vehicleReporter!!.enableLocationTracking() |
| | | } |
| | | } |
| | | ) |
| | | }*/ |
| | | override fun onNavigatorReady(navigator: Navigator) { |
| | | // Keep a reference to the Navigator (used to configure and start nav) |
| | | this@MainActivity.navigator = navigator |
| | | Log.e(Const.GoogleDriver.TAG, "初始化司机sdk成功") |
| | | val driverContext = |
| | | DriverContext.builder(application) |
| | | //.setProviderId("i-go-odrd-testing") |
| | | .setProviderId("gopost-475301") |
| | | .setVehicleId(CacheKey.getKeyStr("vehicleId")) |
| | | .setAuthTokenFactory(JsonAuthTokenFactory()) |
| | | .setNavigator(navigator) |
| | | .setRoadSnappedLocationProvider( |
| | | NavigationApi.getRoadSnappedLocationProvider( |
| | | application |
| | | ) |
| | | ) |
| | | .setDriverStatusListener(this@MainActivity) |
| | | .build() |
| | | val ridesharingDriverApi = RidesharingDriverApi.createInstance(driverContext) |
| | | vehicleReporter = ridesharingDriverApi.ridesharingVehicleReporter |
| | | vehicleReporter!!.enableLocationTracking() |
| | | } |
| | | } |
| | | ) |
| | | }*/ |
| | | |
| | | override fun onRestart() { |
| | | super.onRestart() |
| | |
| | | } |
| | | } |
| | | |
| | | var qeeOrderView = object : MyApplication.OrderStatueView { |
| | | private var qeeOrderView = object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | when (it.orderType) { |
| | |
| | | |
| | | private fun checkGps() { |
| | | if (!AMapKit.isLocServiceEnable(this)) { |
| | | DialogUtil.getDelAndSureDialog(this, |
| | | DialogUtil.getDelAndSureDialog( |
| | | this, |
| | | getString(R.string.查看定位), |
| | | getString(R.string.退出), |
| | | getString( |
| | |
| | | |
| | | fun beOnDuty(b: Boolean) { |
| | | if (b) { |
| | | // avv_anim.visible() |
| | | // tv_up_avv.visible() |
| | | // avv_anim.visible() |
| | | // tv_up_avv.visible() |
| | | } else { |
| | | avv_anim.gone() |
| | | tv_up_avv.gone() |
| | |
| | | clickCallOrder() |
| | | } |
| | | |
| | | private fun clickCallOrder(){ |
| | | private fun clickCallOrder() { |
| | | tv_car.clickDelay { |
| | | if (homeDataBean?.data?.work == 1) { |
| | | callNet(Api.work, getMapByAny()) { |
| | |
| | | it.find<TextView>(R.id.tv_hint_base).text = warn |
| | | } |
| | | } |
| | | |
| | | private fun showPayDialog() { |
| | | val l = SPUtils.getString(Const.language) |
| | | val pay:String |
| | | val off:String |
| | | val msg:String |
| | | val warn:String |
| | | when(l){ |
| | | Const.Language.FRENCH->{ |
| | | val pay: String |
| | | val off: String |
| | | val msg: String |
| | | val warn: String |
| | | when (l) { |
| | | Const.Language.FRENCH -> { |
| | | pay = "Payer" |
| | | off = "Fermer" |
| | | warn = "Rappel" |
| | | msg = "Vous avez des frais de règlement en attente de paiement, vous ne pouvez recevoir des commandes qu’après paiement, veuillez payer dès que possible" |
| | | msg = |
| | | "Vous avez des frais de règlement en attente de paiement, vous ne pouvez recevoir des commandes qu’après paiement, veuillez payer dès que possible" |
| | | } |
| | | Const.Language.CHINESE,"zh"->{ |
| | | |
| | | Const.Language.CHINESE, "zh" -> { |
| | | pay = "支付" |
| | | off = "关闭" |
| | | warn = "提示" |
| | | msg = "您有一笔结算费待支付,须支付后才能接单,请尽快支付" |
| | | } |
| | | else->{ |
| | | |
| | | else -> { |
| | | pay = "Pay" |
| | | off = "Close" |
| | | warn = "Reminder" |
| | | msg = "You have a settlement fee pending payment, you can only receive orders after payment, please pay as soon as possible" |
| | | msg = |
| | | "You have a settlement fee pending payment, you can only receive orders after payment, please pay as soon as possible" |
| | | } |
| | | } |
| | | val delAndSureDialog = getDelAndSureDialog(this, |
| | | val delAndSureDialog = getDelAndSureDialog( |
| | | this, |
| | | pay, |
| | | off, |
| | | msg, |
| | |
| | | when (event!!.code) { |
| | | BaseEvent.START_CAR -> { |
| | | beOnDuty(true) |
| | | /* if (vehicleReporter == null) { |
| | | initDriver() |
| | | }*/ |
| | | /* if (vehicleReporter == null) { |
| | | initDriver() |
| | | }*/ |
| | | initCall() |
| | | } |
| | | |
| | |
| | | BaseEvent.OFF_LINE -> { |
| | | Thread() { |
| | | try { |
| | | /* vehicleReporter?.disableLocationTracking() |
| | | RidesharingDriverApi.clearInstance()*/ |
| | | /* vehicleReporter?.disableLocationTracking() |
| | | RidesharingDriverApi.clearInstance()*/ |
| | | } catch (e: Exception) { |
| | | } |
| | | }.start() |
| | |
| | | } |
| | | |
| | | |
| | | /* override fun updateStatus( |
| | | p0: DriverContext.DriverStatusListener.StatusLevel, |
| | | p1: DriverContext.DriverStatusListener.StatusCode, |
| | | p2: String, |
| | | p3: Throwable?, |
| | | ) { |
| | | Log.e( |
| | | Const.GoogleDriver.TAG, |
| | | "StatusLevel:${p0.name},StatusCode:${p1},p2:${p2},错误信息:${p3?.message}" |
| | | ) |
| | | } |
| | | /* override fun updateStatus( |
| | | p0: DriverContext.DriverStatusListener.StatusLevel, |
| | | p1: DriverContext.DriverStatusListener.StatusCode, |
| | | p2: String, |
| | | p3: Throwable?, |
| | | ) { |
| | | Log.e( |
| | | Const.GoogleDriver.TAG, |
| | | "StatusLevel:${p0.name},StatusCode:${p1},p2:${p2},错误信息:${p3?.message}" |
| | | ) |
| | | } |
| | | |
| | | */ |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | RidesharingDriverApi.clearInstance() |
| | | }*/ |
| | | MyApplication.removeOrderView(qeeOrderView) |
| | | } |
| | | } |
| | |
| | | import com.driver.igotrip.bean.OrderBean |
| | | import com.driver.igotrip.bean.OrderSimpleData |
| | | import com.driver.igotrip.bean.StringBean |
| | | import com.driver.igotrip.extension.extClearInvalidZero |
| | | import com.driver.igotrip.netUtls.Api |
| | | import com.driver.igotrip.netUtls.callNet |
| | | import com.driver.igotrip.netUtls.getMapByAny |
| | |
| | | private fun showUi(orderBean: OrderBean.DataBean) { |
| | | orderBean?.let { |
| | | tv_name.text = it.nickName |
| | | tv_car_num.text = getString(R.string.次乘车,it.historyNum.toString()) |
| | | tv_car_num.text = getString(R.string.次乘车, it.historyNum.toString()) |
| | | iv_phone.visible() |
| | | iv_phone.clickDelay { |
| | | MyUtils.getInstans().CallPhone(this, it.phone.toString()) |
| | |
| | | tv_time.text = it.travelTime_ |
| | | tv_start_address.text = it.startAddress |
| | | tv_end_address.text = it.endAddress |
| | | tv_red_money.text = getString(R.string.元红包,it.tipMoney.toString()) |
| | | tv_red_money.text = |
| | | getString(R.string.元红包, it.tipMoney.toString().extClearInvalidZero()) |
| | | remark.text = it.remark |
| | | remark.gone() |
| | | if(orderType == "1"){ |
| | | if (orderType == "1") { |
| | | tv_red_money.gone() |
| | | } |
| | | tv_order_money.text = getString(R.string.money) + it.orderMoney |
| | | tv_service_money.text = getString(R.string.money) + it.platformServerMoney |
| | | tv_coupon_price.text = "-" + getString(R.string.money) + it.couponMoney |
| | | tv_order_money.text = |
| | | getString(R.string.money) + " " + it.orderMoney.toString().extClearInvalidZero() |
| | | tv_service_money.text = |
| | | getString(R.string.money) + " " + it.platformServerMoney.extClearInvalidZero() |
| | | tv_coupon_price.text = |
| | | "-" + getString(R.string.money) + " " + it.couponMoney.extClearInvalidZero() |
| | | ll_coupon_price.isVisible = (it.couponMoney?.toDoubleOrNull() ?: 0.0) > 0 |
| | | tv_real_income.text = getString(R.string.money) + it.driverServerMoney |
| | | tv_real_income.text = |
| | | getString(R.string.money) + " " + it.driverServerMoney.extClearInvalidZero() |
| | | when (orderBean.orderState) { |
| | | 10,12-> { |
| | | 10, 12 -> { |
| | | ll_order_cancel.visible() |
| | | setTitleText(getString(if (orderBean.orderState == 10) R.string.已取消 else R.string.取消待支付)) |
| | | iv_phone.gone() |
| | | tv_cancel_to.text = it.cancelUser |
| | | tv_cancel_money.text = getString(R.string.money) +" "+ doubleOne(it.cancelPayMoney) |
| | | tv_cancel_money.text = |
| | | (getString(R.string.money) + " " + doubleOne(it.cancelPayMoney)).extClearInvalidZero() |
| | | tv_cancel_result.text = it.cancelReason |
| | | tv_cancel_s.text = it.cancelRemark |
| | | if (it.cancelRemark.isNullOrEmpty()){ |
| | | if (it.cancelRemark.isNullOrEmpty()) { |
| | | tv_cancel_s.text = "" |
| | | } |
| | | } |
| | | |
| | | 6, 7 -> { |
| | | if (it.payManner == 2) { |
| | | tv_show_pay_over.visible() |
| | |
| | | showPayResultText(it, it.orderState) |
| | | } |
| | | } |
| | | |
| | | 8, 9 -> { |
| | | if (it.payManner == 2) { |
| | | tv_show_pay_over.visible() |
| | | setTitleText(getString(if(orderBean.orderState == 8) R.string.待评价 else R.string.已完成)) |
| | | setTitleText(getString(if (orderBean.orderState == 8) R.string.待评价 else R.string.已完成)) |
| | | } else { |
| | | showPayResultText(it, it.orderState) |
| | | } |
| | | } |
| | | } |
| | | if (orderBean.orderState in 6..9 && it.driverPay == "1"){ |
| | | if (orderBean.orderState in 6..9 && it.driverPay == "1") { |
| | | var paytype = 3 |
| | | tv_pay_result_title.text = getString(R.string.乘客已现金支付) |
| | | ll_pay_bottom.visible() |
| | |
| | | selectItem(iv_phone_select) |
| | | } |
| | | tv_sure_dan.clickDelay { |
| | | if (paytype == 2){ |
| | | if (paytype == 2) { |
| | | val dialog = ChooseCardDialog() |
| | | dialog.setCallback(object : StringCallback { |
| | | override fun onRlt(rlt: String) { |
| | | payOrder(paytype,rlt) |
| | | payOrder(paytype, rlt) |
| | | } |
| | | }) |
| | | dialog.show(supportFragmentManager,"card") |
| | | }else |
| | | dialog.show(supportFragmentManager, "card") |
| | | } else |
| | | payOrder(paytype) |
| | | } |
| | | } |
| | | if (it.isFrozen == 2){ |
| | | if (it.isFrozen == 2) { |
| | | tv_frozen.visible() |
| | | tv_frozen.setCompoundDrawablesRelativeWithIntrinsicBounds(0, |
| | | UiUtil.getFrozenBitmap(),0,0) |
| | | tv_frozen.setCompoundDrawablesRelativeWithIntrinsicBounds( |
| | | 0, |
| | | UiUtil.getFrozenBitmap(), 0, 0 |
| | | ) |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * @param paytype 支付方式1=线上,2=余额 |
| | | */ |
| | | private fun payOrder(paytype: Int,bank:String? = null) { |
| | | private fun payOrder(paytype: Int, bank: String? = null) { |
| | | var map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | map["payType"] = paytype |
| | | if (paytype == 2&&bank!=null) |
| | | if (paytype == 2 && bank != null) |
| | | map["bankCardId"] = bank |
| | | callNet(Api.payOrder, map) { |
| | | when(paytype){ |
| | | 3->{ //现金支付成功 |
| | | when (paytype) { |
| | | 3 -> { //现金支付成功 |
| | | showToast(getString(R.string.支付成功)) |
| | | ll_pay_bottom.gone() |
| | | } |
| | | else->{ |
| | | |
| | | else -> { |
| | | val data = gson.fromJson(it, StringBean::class.java).data |
| | | toBrowser(data?:"") |
| | | toBrowser(data ?: "") |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | fun toBrowser(url:String){ |
| | | fun toBrowser(url: String) { |
| | | toPay = true |
| | | MyApplication.isPlayVoice = false |
| | | val intent = Intent() |
| | |
| | | |
| | | override fun onResume() { |
| | | super.onResume() |
| | | if (toPay){ |
| | | if (toPay) { |
| | | var map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | callNet(Api.queryOrderInfo, map) { |
| | | val orderBean1 = gson.fromJson(it, OrderBean::class.java) |
| | | if (orderBean1.data.driverPay == "2"){ |
| | | if (orderBean1.data.driverPay == "2") { |
| | | showUi(orderBean1.data) |
| | | toast(getString(R.string.支付成功)) |
| | | }else{ |
| | | } else { |
| | | toast(getString(R.string.支付失败)) |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 提示乘客现金支付 |
| | | */ |
| | | override fun showDriverPayDialog(audioUrl:String,orderId: String, orderType: String,money:Double) { |
| | | override fun showDriverPayDialog( |
| | | audioUrl: String, |
| | | orderId: String, |
| | | orderType: String, |
| | | money: Double |
| | | ) { |
| | | getTTsManager().setVideoText(audioUrl) |
| | | if (orderId == this.orderId&&orderType == this.orderType){ |
| | | if (orderId == this.orderId && orderType == this.orderType) { |
| | | var map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | |
| | | dialog.setCanceledOnTouchOutside(false) |
| | | dialog.setCancelable(false) |
| | | val view = DialogUtil.getView(dialog) |
| | | view.find<TextView>(R.id.tv_price).text = getString(R.string.确认现金金额).format(if (money == 0.0) orderBean.orderMoney else money).replace(",",".") |
| | | view.find<TextView>(R.id.tv_price).text = |
| | | getString(R.string.确认现金金额).format(if (money == 0.0) orderBean.orderMoney else money) |
| | | .replace(",", ".").extClearInvalidZero() |
| | | view.find<TextView>(R.id.tv_close_base).setOnClickListener { dialog.dismiss() } |
| | | view.find<TextView>(R.id.tv_sure_base).setOnClickListener { dialog.dismiss() } |
| | | } |
| | |
| | | } |
| | | |
| | | private fun addSocketLisener() { |
| | | MyApplication.addOrderView(object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | if (it.status == 8 || it.status == 9) { |
| | | Handler(Looper.getMainLooper()).post { |
| | | orderBean.orderState = 8 |
| | | showUi(orderBean) |
| | | } |
| | | MyApplication.addOrderView(listener) |
| | | } |
| | | |
| | | private val listener = object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | if (it.status == 8 || it.status == 9) { |
| | | Handler(Looper.getMainLooper()).post { |
| | | orderBean.orderState = 8 |
| | | showUi(orderBean) |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | var handler: Handler? = null |
| | | fun checkOrderStatue() { |
| | | var map = getMapByAny() |
| | |
| | | |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | MyApplication.removeOrderView(listener) |
| | | handler?.removeCallbacksAndMessages(null) |
| | | } |
| | | |
| | |
| | | setTitleText(getString(R.string.待支付)) |
| | | } else { |
| | | tv_pay_result_title.text = getString(R.string.乘客已支付) |
| | | setTitleText(if(orderBean.orderState == 8) R.string.待评价 else R.string.已完成) |
| | | setTitleText(if (orderBean.orderState == 8) R.string.待评价 else R.string.已完成) |
| | | } |
| | | tv_pay_result_money.text = getString(R.string.money) + if (it.payMoney == 0.0) it.orderMoney.toString() else it.payMoney.toString() |
| | | tv_pay_result_money.text = |
| | | getString(R.string.money) + " " + (if (it.payMoney == 0.0) it.orderMoney.toString() else it.payMoney.toString()).extClearInvalidZero() |
| | | when (orderType) { |
| | | "2" -> { |
| | | tv_pay_result_small_money.text = getString(R.string.其中含红包费用) + it.tipMoney.toString() |
| | | tv_pay_result_small_money.text = |
| | | getString(R.string.其中含红包费用) + " " + it.tipMoney.toString() |
| | | .extClearInvalidZero() |
| | | } |
| | | |
| | | "1" -> { |
| | | tv_pay_result_small_money.text = getString(R.string.查看收费明细) |
| | | view_line_money_detail.visible() |
| | |
| | | package com.driver.igotrip.ui.main |
| | | |
| | | import android.annotation.SuppressLint |
| | | import android.content.Intent |
| | | import android.os.Bundle |
| | | import android.os.Handler |
| | | import android.os.Looper |
| | |
| | | import com.driver.igotrip.base.gaode.AMapKit.initMap |
| | | import com.driver.igotrip.base.gaode.AMapKit.moveCamera |
| | | import com.driver.igotrip.bean.* |
| | | import com.driver.igotrip.extension.extClearInvalidZero |
| | | import com.driver.igotrip.netUtls.Api |
| | | import com.driver.igotrip.netUtls.callNet |
| | | import com.driver.igotrip.netUtls.createView |
| | |
| | | * 页面一共4个marker 1:预约地点 2:起点 3终点 4:司机点 |
| | | */ |
| | | val orderType by lazy { |
| | | intent.getStringExtra("orderType")?:"" |
| | | intent.getStringExtra("orderType") ?: "" |
| | | } |
| | | |
| | | val orderId by lazy { |
| | | intent.getStringExtra("orderId")?:"" |
| | | intent.getStringExtra("orderId") ?: "" |
| | | } |
| | | var isTimeStart = false //限制计时器 |
| | | |
| | |
| | | var graylist = arrayListOf<LatLng>() // 灰色轨迹 |
| | | var grayline: Polyline? = null |
| | | |
| | | var tripInfo:GoogleTripInfo? = null//谷歌订单信息 |
| | | var tripInfo: GoogleTripInfo? = null//谷歌订单信息 |
| | | |
| | | private val iv_move by lazy { find<View>(R.id.iv_move) } |
| | | private val remark by lazy { find<View>(R.id.remark) } |
| | |
| | | |
| | | private fun addSockectCancel() { |
| | | checkOrderStatue() |
| | | MyApplication.addOrderView(object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | if (it.status == 10 || it.status == 12) { |
| | | Handler(Looper.getMainLooper()).post { |
| | | MyApplication.addOrderView(listener) |
| | | } |
| | | |
| | | private val listener = object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | if (it.status == 10 || it.status == 12) { |
| | | Handler(Looper.getMainLooper()).post { |
| | | // toast(getString(R.string.用户已取消订单)) |
| | | // MyApplication.getTTsManager().setVideoText(data.audioUrl) |
| | | MyApplication.currentOrderType = "" |
| | | MyApplication.currentOrderId = "" |
| | | finish() |
| | | } |
| | | MyApplication.currentOrderType = "" |
| | | MyApplication.currentOrderId = "" |
| | | finish() |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | var handler: Handler? = null |
| | | fun checkOrderStatue() { |
| | | var map = getMapByAny() |
| | |
| | | 2, 3 -> { |
| | | moveCamera(aMap, makeMarker!!.position, carMarker!!.position) |
| | | } |
| | | |
| | | 4 -> { |
| | | moveCamera(aMap, carMarker!!.position) |
| | | } |
| | | |
| | | 5, 6 -> { |
| | | moveCamera(aMap, carMarker!!.position, endMarker!!.position) |
| | | } |
| | |
| | | } |
| | | } |
| | | iv_to_gd.clickDelay { |
| | | /* if(true){ |
| | | val intent = Intent(this, BasicNavigationActivity::class.java) |
| | | startActivity(intent) |
| | | return@clickDelay |
| | | }*/ |
| | | /* if(true){ |
| | | val intent = Intent(this, BasicNavigationActivity::class.java) |
| | | startActivity(intent) |
| | | return@clickDelay |
| | | }*/ |
| | | orderBean?.let { |
| | | when (it.data.orderState) { |
| | | 2, 3 -> { |
| | |
| | | } else { |
| | | it.data.orderState++ |
| | | callStatue(it.data.orderState) { |
| | | if (it.data.orderState == 3){ |
| | | if (it.data.orderState == 3) { |
| | | iv_to_gd.callOnClick() |
| | | } |
| | | } |
| | | showStatueMapUI(it) |
| | | } |
| | | } |
| | | |
| | | 5, 6 -> { |
| | | it.data.orderState = 6 |
| | | when (orderType) { |
| | | "2" -> { |
| | | showMoneyTypeDialog() |
| | | } |
| | | |
| | | "1" -> { |
| | | callStatue(6) { |
| | | startActivity<MajorSureMoneyActivity>( |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /*** |
| | | * 定位时司机与线路的改变 |
| | | */ |
| | |
| | | private fun initMineLocation() { |
| | | aMap.setOnMyLocationChangeListener { |
| | | it.let { latlon -> |
| | | MyApplication.aMapLocation = LatLng(it.latitude,it.longitude) |
| | | MyApplication.aMapLocation = LatLng(it.latitude, it.longitude) |
| | | } |
| | | orderBean?.let { |
| | | when (it.data.orderState) { |
| | | 2, 3 -> { |
| | | changeCarThree(false) |
| | | } |
| | | 4->{ |
| | | |
| | | 4 -> { |
| | | //getTripInfo(4,false) |
| | | changeCarThree(false) |
| | | } |
| | | |
| | | 5, 6 -> { |
| | | changeCarFive(false) |
| | | } |
| | | } |
| | | } |
| | | if (System.currentTimeMillis() - lastMoveByGesture > 8*1000L) |
| | | if (System.currentTimeMillis() - lastMoveByGesture > 8 * 1000L) |
| | | iv_move.callOnClick() |
| | | } |
| | | } |
| | |
| | | override fun invoke(p1: MutableList<LatLng>, p2: Float, p3: Long) { |
| | | val s = AMapKit.getTance(this@TripActivity, p2) |
| | | val content = getString(R.string.距预约点, s) |
| | | val sb = SpanBuilder.content(content).colorSpan(this@TripActivity,content.indexOf(s),content.indexOf(s)+s.length,R.color.color_5DB03D).build() |
| | | val sb = SpanBuilder.content(content).colorSpan( |
| | | this@TripActivity, |
| | | content.indexOf(s), |
| | | content.indexOf(s) + s.length, |
| | | R.color.color_5DB03D |
| | | ).build() |
| | | var view = creatCarView(sb) |
| | | carMarker!!.setIcon(getIcon(view)) |
| | | addline(p1) |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | private fun getTripInfo(state:Int,isMove: Boolean){ |
| | | private fun getTripInfo(state: Int, isMove: Boolean) { |
| | | var map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | callNet(false,Api.getTripInfo, map) { |
| | | callNet(false, Api.getTripInfo, map) { |
| | | val bean = Gson().fromJson(it, StringBean::class.java) |
| | | if (bean.code == 200&&!bean.data.isNullOrEmpty()){ |
| | | if (bean.code == 200 && !bean.data.isNullOrEmpty()) { |
| | | val trip = Gson().fromJson(bean.data, GoogleTripInfo::class.java) |
| | | val latlon = if (trip.lastLocation == null) LocationX(MyApplication.aMapLocation!!.latitude,MyApplication.aMapLocation!!.longitude) else trip.lastLocation.location //车辆位置 |
| | | val latlon = if (trip.lastLocation == null) LocationX( |
| | | MyApplication.aMapLocation!!.latitude, |
| | | MyApplication.aMapLocation!!.longitude |
| | | ) else trip.lastLocation.location //车辆位置 |
| | | carMarker?.position = LatLng(latlon.latitude, latlon.longitude) |
| | | if (state != 4){ |
| | | if (state != 4) { |
| | | graylist.add(LatLng(latlon.latitude, latlon.longitude)) |
| | | grayline?.remove() |
| | | grayline = AMapKit.drawLine(this, aMap, graylist, R.color.gray) |
| | | val routs = arrayListOf<LatLng>() |
| | | if (!trip.route.isNullOrEmpty()){ |
| | | routs.addAll(trip.route.map { LatLng(it.latitude,it.longitude) }) |
| | | if (!trip.route.isNullOrEmpty()) { |
| | | routs.addAll(trip.route.map { LatLng(it.latitude, it.longitude) }) |
| | | } |
| | | addline(routs) |
| | | }else{ |
| | | } else { |
| | | closeLine() |
| | | graylist.clear() |
| | | grayline?.remove() |
| | | } |
| | | if (state == 3){ |
| | | if (state == 3) { |
| | | val tance = trip.remainingDistanceMeters.toFloat() |
| | | val s = AMapKit.getTance(this@TripActivity, tance) |
| | | val unit = getString(if (tance > 1000) R.string.公里 else R.string.米) |
| | | val content = getString(R.string.距预约点, s) |
| | | val sb = SpanBuilder.content(content).colorSpan(this@TripActivity,content.indexOf(s),content.indexOf(s)+s.length - unit.length,R.color.color_5DB03D).build() |
| | | val sb = SpanBuilder.content(content).colorSpan( |
| | | this@TripActivity, |
| | | content.indexOf(s), |
| | | content.indexOf(s) + s.length - unit.length, |
| | | R.color.color_5DB03D |
| | | ).build() |
| | | var view = creatCarView(sb) |
| | | carMarker!!.setIcon(getIcon(view)) |
| | | |
| | | } |
| | | if (state == 5){ |
| | | val tance = AMapKit.getTance(this@TripActivity, trip.remainingDistanceMeters.toFloat()) |
| | | val unit = getString(if (trip.remainingDistanceMeters.toFloat() > 1000) R.string.公里 else R.string.米) |
| | | if (state == 5) { |
| | | val tance = |
| | | AMapKit.getTance(this@TripActivity, trip.remainingDistanceMeters.toFloat()) |
| | | val unit = |
| | | getString(if (trip.remainingDistanceMeters.toFloat() > 1000) R.string.公里 else R.string.米) |
| | | val seconds = trip.remainingWaypoints?.firstOrNull()?.duration ?: "0s" |
| | | val time = (seconds.substring(0,seconds.length-1).toDouble()/60).toInt().toString() |
| | | val time = (seconds.substring(0, seconds.length - 1).toDouble() / 60).toInt() |
| | | .toString() |
| | | val content = getString(R.string.预计还需, tance, time) |
| | | val sb = SpanBuilder.content(content).colorSpan(this@TripActivity,content.indexOf(tance),content.indexOf(tance)+tance.length-unit.length,R.color.color_5DB03D) |
| | | .colorSpan(this@TripActivity,content.indexOf(time),content.indexOf(time)+time.length,R.color.color_5DB03D).build() |
| | | val sb = SpanBuilder.content(content).colorSpan( |
| | | this@TripActivity, |
| | | content.indexOf(tance), |
| | | content.indexOf(tance) + tance.length - unit.length, |
| | | R.color.color_5DB03D |
| | | ) |
| | | .colorSpan( |
| | | this@TripActivity, |
| | | content.indexOf(time), |
| | | content.indexOf(time) + time.length, |
| | | R.color.color_5DB03D |
| | | ).build() |
| | | var view = creatCarView(sb) |
| | | carMarker!!.setIcon(getIcon(view)) |
| | | } |
| | |
| | | |
| | | private fun changeCarFive(isMove: Boolean) { |
| | | if (carMarker != null && endMarker != null) { |
| | | // getTripInfo(5,isMove) |
| | | // getTripInfo(5,isMove) |
| | | |
| | | AMapKit.initRouteLine( |
| | | this, |
| | |
| | | val tance = AMapKit.getTance(this@TripActivity, p2) |
| | | val time = p3.toInt().toString() |
| | | val content = getString(R.string.预计还需, tance, time) |
| | | val sb = SpanBuilder.content(content).colorSpan(this@TripActivity,content.indexOf(tance),content.indexOf(tance)+tance.length,R.color.color_5DB03D) |
| | | .colorSpan(this@TripActivity,content.indexOf(time),content.indexOf(time)+time.length,R.color.color_5DB03D).build() |
| | | val sb = SpanBuilder.content(content).colorSpan( |
| | | this@TripActivity, |
| | | content.indexOf(tance), |
| | | content.indexOf(tance) + tance.length, |
| | | R.color.color_5DB03D |
| | | ) |
| | | .colorSpan( |
| | | this@TripActivity, |
| | | content.indexOf(time), |
| | | content.indexOf(time) + time.length, |
| | | R.color.color_5DB03D |
| | | ).build() |
| | | var view = creatCarView(sb) |
| | | carMarker!!.setIcon(getIcon(view)) |
| | | if (isMove) { |
| | |
| | | } |
| | | } |
| | | |
| | | private fun callOrder(reNavi:Boolean = false) { |
| | | private fun callOrder(reNavi: Boolean = false) { |
| | | MyApplication.currentOrderId = orderId |
| | | MyApplication.currentOrderType = orderType |
| | | var map = getMapByAny() |
| | |
| | | callNet(Api.queryOrderInfo, map) { |
| | | orderBean = gson.fromJson(it, OrderBean::class.java) |
| | | showUi(orderBean) |
| | | if (reNavi){ |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.RELOAD_NAVI,orderBean!!.data.endLat.toString(),orderBean!!.data.endLon.toString())) |
| | | if (reNavi) { |
| | | EventBus.getDefault().post( |
| | | BaseEvent( |
| | | BaseEvent.RELOAD_NAVI, |
| | | orderBean!!.data.endLat.toString(), |
| | | orderBean!!.data.endLon.toString() |
| | | ) |
| | | ) |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private fun showUi(orderBean: OrderBean?) { |
| | | orderBean?.let { |
| | | if (it.data.isFrozen == 2){ |
| | | if (it.data.isFrozen == 2) { |
| | | toast(getString(R.string.已冻结)) |
| | | finish() |
| | | } |
| | |
| | | if (orderType == "1") { |
| | | tv_red_money.gone() |
| | | } |
| | | tv_red_money.text = getString(R.string.元红包, it.data.tipMoney.toString()) |
| | | tv_red_money.text = |
| | | getString(R.string.元红包, it.data.tipMoney.toString().extClearInvalidZero()) |
| | | showStatueMapUI(it) |
| | | var latLngList = mutableListOf<LatLng>() |
| | | for (item in orderBean.data.orderPositionList) { |
| | |
| | | } |
| | | } |
| | | |
| | | private fun callOverOrder(){ |
| | | private fun callOverOrder() { |
| | | showDialog() |
| | | var map = getMapByAny() |
| | | map["orderId"] = orderId |
| | |
| | | val view = createView(R.layout.item_map_market, this) |
| | | view.find<ImageView>(R.id.iv_img).setImageResource(UiUtil.getLangEndBitmap()) |
| | | endMarker = addMarker(aMap, it.data.endLat, it.data.endLon, view, "") |
| | | }else{ //可能修改终点 |
| | | } else { //可能修改终点 |
| | | endMarker?.position = LatLng(it.data.endLat, it.data.endLon) |
| | | } |
| | | endMarker!!.isVisible = false |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | 4 -> { |
| | | iv_to_gd.gone() |
| | | if (it.data.reassign == 1) { |
| | |
| | | setTitleText(getString(R.string.等待客户)) |
| | | slide_btn.changeButtonText(getString(R.string.开始行程)) |
| | | } |
| | | |
| | | 5, 6 -> { |
| | | closeTimeStart() |
| | | iv_to_gd.visible() |
| | |
| | | |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | |
| | | MyApplication.removeOrderView(listener) |
| | | if (handler != null) { |
| | | handler?.removeCallbacksAndMessages(null) |
| | | } |
| | |
| | | MyApplication.currentOrderType = "" |
| | | finish() |
| | | } |
| | | |
| | | BaseEvent.BACK_CAR_OVER -> { |
| | | finish() |
| | | } |
| | | |
| | | BaseEvent.ORDER_CANCEL -> { |
| | | finish() |
| | | } |
| | | |
| | | BaseEvent.MODIFY_ADDRESS_SUC -> { |
| | | callOrder(true) |
| | | } |
| | |
| | | import com.driver.igotrip.R |
| | | import com.driver.igotrip.base.MyBaseActivity |
| | | import com.driver.igotrip.bean.MajorMoneyBean |
| | | import com.driver.igotrip.extension.extClearInvalidZero |
| | | import com.driver.igotrip.netUtls.Api |
| | | import com.driver.igotrip.netUtls.callNet |
| | | import com.driver.igotrip.netUtls.getMapByAny |
| | |
| | | |
| | | private fun showUi(bean: MajorMoneyBean?) { |
| | | bean?.let { |
| | | tv_start_money.text = "FCFA"+it.data.startMoney.toString() |
| | | tv_start_money.text = "FCFA"+" "+it.data.startMoney.toString().extClearInvalidZero() |
| | | tv_wait_name.text = getString(R.string.wait_time, doubleTwo(it.data.wait)) |
| | | tv_wait_money.text = "FCFA"+it.data.waitMoney.toString() |
| | | tv_wait_money.text = "FCFA"+" "+it.data.waitMoney.toString().extClearInvalidZero() |
| | | tv_mileage_name.text = getString(R.string.tance_money, doubleTwo(it.data.mileage)) |
| | | tv_mileage_money.text = "FCFA"+it.data.mileageMoney.toString() |
| | | tv_mileage_money.text = "FCFA"+" "+it.data.mileageMoney.toString().extClearInvalidZero() |
| | | tv_time_name.text = getString(R.string.time_money, doubleTwo(it.data.duration)) |
| | | tv_time_money.text = "FCFA"+it.data.durationMoney.toString() |
| | | tv_coupon_price.text = "-FCFA"+it.data.couponMoney.toString() |
| | | tv_time_money.text = "FCFA"+" "+it.data.durationMoney.toString().extClearInvalidZero() |
| | | tv_coupon_price.text = "-FCFA"+" "+it.data.couponMoney.toString().extClearInvalidZero() |
| | | tv_long_distance_name.text = getString(R.string.远途费公里, doubleTwo(it.data.longDistance)) |
| | | tv_long_distance_money.text = "FCFA"+it.data.longDistanceMoney.toString() |
| | | tv_long_go_money.text = "FCFA"+it.data.roadTollMoney.toString() |
| | | et_stop_car_money.text = "FCFA"+it.data.parkMoney.toString() |
| | | tv_all_money.text = "FCFA"+it.data.orderMoney.toString() |
| | | tv_long_distance_money.text = "FCFA"+" "+it.data.longDistanceMoney.toString().extClearInvalidZero() |
| | | tv_long_go_money.text = "FCFA"+" "+it.data.roadTollMoney.toString().extClearInvalidZero() |
| | | et_stop_car_money.text = "FCFA"+" "+it.data.parkMoney.toString().extClearInvalidZero() |
| | | tv_all_money.text = "FCFA"+" "+it.data.orderMoney.toString().extClearInvalidZero() |
| | | rl_start_num.visibility = if (it.data.startMoney == 0.0) View.GONE else View.VISIBLE |
| | | rl_wait_name.visibility = if (it.data.wait == 0.0) View.GONE else View.VISIBLE |
| | | rl_mileage_money.visibility = if (it.data.mileageMoney == 0.0) View.GONE else View.VISIBLE |
| | |
| | | // rl_long_go_money.visibility = if (it.data.roadTollMoney == 0.0) View.GONE else View.VISIBLE |
| | | //rl_stop_car_money.visibility = if (it.data.parkMoney == 0.0) View.GONE else View.VISIBLE |
| | | tv_price_by_platform.visibility = if (it.data.isDispute == 1){ |
| | | tv_price_by_platform.text = getString(R.string.争议订单协商价格).format(it.data.orderMoney) |
| | | tv_price_by_platform.text = getString(R.string.争议订单协商价格).format(it.data.orderMoney.toString().extClearInvalidZero()) |
| | | View.VISIBLE |
| | | } else View.GONE |
| | | } |
| | |
| | | import com.driver.igotrip.base.MyBaseActivity |
| | | import com.driver.igotrip.bean.MajorMoneyBean |
| | | import com.driver.igotrip.bean.OrderBean |
| | | import com.driver.igotrip.extension.extClearInvalidZero |
| | | import com.driver.igotrip.netUtls.Api |
| | | import com.driver.igotrip.netUtls.Api.completeOrder |
| | | import com.driver.igotrip.netUtls.callNet |
| | |
| | | |
| | | callNet(false, Api.queryMoneyInfo, map) { |
| | | var bean = gson.fromJson<MajorMoneyBean>(it, MajorMoneyBean::class.java) |
| | | tv_all_money.text = getString(R.string.money) + " " + bean.data.payMoney.toString() |
| | | tv_all_money.text = getString(R.string.money) + " " + bean.data.payMoney.toString().extClearInvalidZero() |
| | | } |
| | | |
| | | } |
| | |
| | | import com.driver.igotrip.base.MyBaseActivity |
| | | import com.driver.igotrip.bean.MajorMoneyBean |
| | | import com.driver.igotrip.bean.OrderBean |
| | | import com.driver.igotrip.extension.extClearInvalidZero |
| | | import com.driver.igotrip.netUtls.Api |
| | | import com.driver.igotrip.netUtls.callNet |
| | | import com.driver.igotrip.netUtls.getMapByAny |
| | |
| | | private fun showUi(bean: MajorMoneyBean?) { |
| | | bean?.let { |
| | | setbean=it |
| | | tv_start_money.text = "FCFA" + it.data.startMoney.toString() |
| | | tv_start_money.text = "FCFA" +" "+ it.data.startMoney.toString().extClearInvalidZero() |
| | | tv_wait_name.text = getString(R.string.wait_time, it.data.wait.toString()) |
| | | tv_wait_money.text = "FCFA" + it.data.waitMoney.toString() |
| | | tv_wait_money.text = "FCFA" +" "+ it.data.waitMoney.toString().extClearInvalidZero() |
| | | tv_mileage_name.text = getString(R.string.tance_money, it.data.mileage.toString()) |
| | | tv_mileage_money.text = "FCFA" + it.data.mileageMoney.toString() |
| | | tv_mileage_money.text = "FCFA" +" "+ it.data.mileageMoney.toString().extClearInvalidZero() |
| | | tv_time_name.text = getString(R.string.time_money, it.data.duration.toString()) |
| | | tv_time_money.text = "FCFA" + it.data.durationMoney.toString() |
| | | tv_time_money.text = "FCFA" +" "+ it.data.durationMoney.toString().extClearInvalidZero() |
| | | tv_long_distance_name.text = |
| | | getString(R.string.远途费公里, it.data.longDistance.toString()) |
| | | tv_long_distance_money.text = "FCFA" + it.data.longDistanceMoney.toString() |
| | | tv_all_money.text = getString(R.string.money) + " " + it.data.payMoney.toString() |
| | | tv_long_distance_money.text = "FCFA" +" "+ it.data.longDistanceMoney.toString().extClearInvalidZero() |
| | | tv_all_money.text = getString(R.string.money) + " " + it.data.payMoney.toString().extClearInvalidZero() |
| | | |
| | | price_difference_layout.visibility = |
| | | if (it.data.priceDifference != null && it.data.priceDifference > 0) View.VISIBLE else View.GONE |
| | | tv_price_difference_money.text = |
| | | "${getString(R.string.money)} ${it.data.priceDifference}" |
| | | "${getString(R.string.money)} ${it.data.priceDifference}".extClearInvalidZero() |
| | | rl_coupon_price.visibility = |
| | | if (it.data.couponMoney != null && it.data.couponMoney > 0) View.VISIBLE else View.GONE |
| | | tv_coupon_price.text = "-${getString(R.string.money)} ${it.data.couponMoney}" |
| | | tv_coupon_price.text = "-${getString(R.string.money)} ${it.data.couponMoney}".extClearInvalidZero() |
| | | } |
| | | } |
| | | |
| | |
| | | map["orderType"] = orderType |
| | | callNet( Api.queryOrderInfo, map) { |
| | | val orderBean = Gson().fromJson(it, OrderBean::class.java) |
| | | val moneytype="${ this@MajorSureMoneyActivity.getString(R.string.money)}${orderBean.data.orderMoney}" |
| | | val moneytype="${ this@MajorSureMoneyActivity.getString(R.string.money)} ${orderBean.data.orderMoney}".extClearInvalidZero() |
| | | Log.e( "onBindItem: ", moneytype) |
| | | this@MajorSureMoneyActivity.startActivity<MajorSureMoney2Activity>( |
| | | "orderId" to orderId, "orderType" to orderType, |
| | |
| | | import com.driver.igotrip.base.gaode.AMapKit.initMap |
| | | import com.driver.igotrip.base.gaode.AMapKit.moveCamera |
| | | import com.driver.igotrip.bean.* |
| | | import com.driver.igotrip.extension.extClearInvalidZero |
| | | import com.driver.igotrip.netUtls.* |
| | | import com.driver.igotrip.ui.DialogUtil |
| | | import com.driver.igotrip.ui.UiUtil |
| | |
| | | |
| | | private fun addSockectCancel() { |
| | | checkOrderStatue() |
| | | MyApplication.addOrderView(object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | if (it.status == 10 || it.status == 11 || it.status == 12) { |
| | | MyApplication.currentOrderType = "" |
| | | MyApplication.currentOrderId = "" |
| | | Handler(Looper.getMainLooper()).post { |
| | | finish() |
| | | } |
| | | MyApplication.addOrderView(listener) |
| | | } |
| | | |
| | | private val listener = object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | if (it.status == 10 || it.status == 11 || it.status == 12) { |
| | | MyApplication.currentOrderType = "" |
| | | MyApplication.currentOrderId = "" |
| | | Handler(Looper.getMainLooper()).post { |
| | | finish() |
| | | } |
| | | if ((it.orderType == 4 || it.orderType == 5) && it.orderId.toString() == orderId && (it.status != 10 && it.status != 11 && it.status != 12)) { |
| | | Handler(Looper.getMainLooper()).post { |
| | | callOrder() {} |
| | | } |
| | | } |
| | | if ((it.orderType == 4 || it.orderType == 5) && it.orderId.toString() == orderId && (it.status != 10 && it.status != 11 && it.status != 12)) { |
| | | Handler(Looper.getMainLooper()).post { |
| | | callOrder() {} |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | var handler: Handler? = null |
| | | fun checkOrderStatue() { |
| | | var map = getMapByAny() |
| | |
| | | } |
| | | callseatmoney(num) { |
| | | dialog.dismiss() |
| | | btn_gap_money.text = getString(R.string.差价待确认).format(num.toDouble()) |
| | | btn_gap_money.text = |
| | | getString(R.string.差价待确认).format(num.extClearInvalidZero()) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0) |
| | | // toast(getString(R.string.set_success)) |
| | | } |
| | |
| | | tv_money.visible() |
| | | tv_money.text = |
| | | getString(R.string.确认现金金额).format(if (orderType == "4") it.data.expressPayAllMoney else if (it.data.payMoney == 0.0) it.data.orderMoney else it.data.payMoney) |
| | | .replace(",", ".") |
| | | .replace(",", ".").extClearInvalidZero() |
| | | } |
| | | tv_sure_car_num.setOnClickListener { |
| | | val num = et_num_zg.getContent() |
| | |
| | | DialogUtil.getDelAndSureDialog( |
| | | this, |
| | | getString(R.string.确认现金金额).format(it.data.expressPayAllMoney) |
| | | .replace(",", "."), |
| | | .replace(",", ".").extClearInvalidZero(), |
| | | {}, |
| | | { |
| | | confirmPickUp(url, 5) { |
| | |
| | | // } |
| | | if (!it.data.differenceMoney.isNullOrEmpty() && it.data.differenceMoney.toDouble() > 0) { |
| | | btn_gap_money.text = |
| | | getString(R.string.差价点击修改).format(it.data.differenceMoney.toDouble()) |
| | | getString(R.string.差价点击修改).format(it.data.differenceMoney.extClearInvalidZero()) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0) |
| | | } |
| | | var latLngList = mutableListOf<LatLng>() |
| | |
| | | |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | MyApplication.removeOrderView(listener) |
| | | if (handler != null) { |
| | | handler?.removeCallbacksAndMessages(null) |
| | | } |
| | |
| | | import com.driver.igotrip.base.MyBaseActivity |
| | | import com.driver.igotrip.bean.OrderBean |
| | | import com.driver.igotrip.bean.OrderSimpleData |
| | | import com.driver.igotrip.extension.extClearInvalidZero |
| | | import com.driver.igotrip.netUtls.Api |
| | | import com.driver.igotrip.netUtls.callNet |
| | | import com.driver.igotrip.netUtls.getMapByAny |
| | |
| | | tv_tv_num_cargo.text = cargoStrType + it.peopleNumber |
| | | tv_people_cargo.text = it.nickName + "-" + it.phone |
| | | tv_pay_result_money.text = |
| | | "FCFA" + if (it.payMoney == 0.0) it.orderMoney.toString() else it.payMoney.toString() |
| | | "FCFA" +" "+ (if (it.payMoney == 0.0) it.orderMoney.toString() else it.payMoney.toString()).extClearInvalidZero() |
| | | tv_pay_result_small_money.text = |
| | | getString(R.string.其中含加急费用) + it.tipMoney.toString() |
| | | getString(R.string.其中含加急费用) +" "+ it.tipMoney.toString().extClearInvalidZero() |
| | | setTitleText(getSmallStatue(it.orderState)) |
| | | tv_pay_result_title.text = getString(R.string.订单) + getSmallStatue(it.orderState) |
| | | tv_order_money.text = getString(R.string.money) + it.orderMoney |
| | | tv_service_money.text = getString(R.string.money) + it.platformServerMoney |
| | | tv_coupon_price.text = "-" + getString(R.string.money) + it.couponMoney |
| | | tv_order_money.text = getString(R.string.money) +" "+ it.orderMoney.toString().extClearInvalidZero() |
| | | tv_service_money.text = getString(R.string.money) +" "+ it.platformServerMoney.extClearInvalidZero() |
| | | tv_coupon_price.text = "-" + getString(R.string.money) +" "+ it.couponMoney.extClearInvalidZero() |
| | | ll_coupon_price.isVisible = (it.couponMoney?.toDoubleOrNull() ?: 0.0) > 0 |
| | | tv_real_income.text = getString(R.string.money) + it.driverServerMoney |
| | | tv_real_income.text = getString(R.string.money) +" "+ it.driverServerMoney.extClearInvalidZero() |
| | | ll_pay_result.visible() |
| | | if (it.orderState in 6..7) { |
| | | tv_pay_result_title.text = getString(R.string.待乘客支付) |
| | |
| | | import cn.sinata.xldutils.utils.ViewClickDelay.hash |
| | | import cn.sinata.xldutils.utils.ViewClickDelay.lastClickTime |
| | | import com.driver.igotrip.BuildConfig |
| | | import com.driver.igotrip.extension.extClearInvalidZero |
| | | import org.jetbrains.anko.internals.AnkoInternals |
| | | import java.util.* |
| | | import java.util.regex.Pattern |
| | |
| | | |
| | | //设置double精确到小数点后1位 |
| | | fun doubleOne(price: Double): String? { |
| | | return String.format("%.1f", price) |
| | | return String.format("%.1f", price).extClearInvalidZero() |
| | | } |
| | | |
| | | fun doubleTwo(price: Double): String { |
| | | return String.format("%.2f", price) |
| | | return String.format("%.2f", price).extClearInvalidZero() |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | fun TextView.setDrawableLeft(drawableResourseId: Int) { |
| | | val topAct: Drawable = context.resources.getDrawable(drawableResourseId) |
| | | val topAct: Drawable? = ContextCompat.getDrawable(context,drawableResourseId) |
| | | this.setCompoundDrawablesWithIntrinsicBounds(topAct, null, null, null) |
| | | } |
| | | |
| | | |
| | | fun TextView.setDrawableBottom(drawableResourseId: Int) { |
| | | val topAct: Drawable = context.resources.getDrawable(drawableResourseId) |
| | | val topAct: Drawable? = ContextCompat.getDrawable(context,drawableResourseId) |
| | | this.setCompoundDrawablesWithIntrinsicBounds(null, null, null, topAct) |
| | | } |
| | | |
| | | fun TextView.setDrawableRight(drawableResourseId: Int) { |
| | | val topAct: Drawable = context.resources.getDrawable(drawableResourseId) |
| | | val topAct: Drawable? = ContextCompat.getDrawable(context,drawableResourseId) |
| | | this.setCompoundDrawablesWithIntrinsicBounds(null, null, topAct, null) |
| | | } |
| | | |
| | | fun TextView.setDrawableTop(drawableResourseId: Int) { |
| | | val topAct: Drawable = context.resources.getDrawable(drawableResourseId) |
| | | val topAct: Drawable? = ContextCompat.getDrawable(context,drawableResourseId) |
| | | this.setCompoundDrawablesWithIntrinsicBounds(null, topAct, null, null) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | fun getFormatOne(value: Double?): String { |
| | | return Formatter().format("%.1f", value).toString() |
| | | return Formatter().format("%.1f", value).toString().extClearInvalidZero() |
| | | } |
| | | |
| | | fun getFormatTwo(value: Double?): String { |
| | | return Formatter().format("%.2f", value).toString() |
| | | return Formatter().format("%.2f", value).toString().extClearInvalidZero() |
| | | } |
| | | |
| | | fun TextView.setColorBuild(context: Context, content: String, color: Int, start: Int, end: Int) { |
| | |
| | | android:id="@+id/incomeAmount" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_marginEnd="30dp" |
| | | android:layout_centerInParent="true" |
| | | android:textColor="#F07207" |
| | | android:textSize="14sp" |
| | |
| | | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:id="@+id/rl_parent" |
| | | android:background="@color/transparent"> |
| | | |
| | | <LinearLayout |
| | |
| | | <string name="停车费">Parking Fee</string> |
| | | <string name="过路费">Tolls</string> |
| | | <string name="小费">Tip</string> |
| | | <string name="平台服务费">Platform service fee</string> |
| | | <string name="平台服务费">Platform fee</string> |
| | | <string name="工商银行">ICBC</string> |
| | | <string name="修改">Revise</string> |
| | | <string name="删除">Delete</string> |
| | |
| | | <string name="用户取消有费用">The subscriber has cancelled the order\nCancellation fee: FCFA %s</string> |
| | | <string name="平台取消无费用">The platform has cancelled this order.\nShould you have any inquiries, please contact the platform customer service.</string> |
| | | <string name="srl_header_update">\'Last Update\' M-d HH:mm</string> |
| | | <string name="差价待确认">" Fee difference FCFA %.2f\n(Pending confirmation)"</string> |
| | | <string name="差价点击修改">Fee difference FCFA %.2f\n(Click to modify)</string> |
| | | <string name="差价待确认">" Fee difference FCFA %s\n(Pending confirmation)"</string> |
| | | <string name="差价点击修改">Fee difference FCFA %s\n(Click to modify)</string> |
| | | <string name="no_sender">Sender didn\'t show up</string> |
| | | <string name="到达取件地点">Arrive at pickup point</string> |
| | | <string name="订单待评价">Order pending rating</string> |
| | | <string name="订单已完成">Order completed</string> |
| | | <string name="差价">Fee difference</string> |
| | | <string name="争议订单协商价格">( Note: Disputed order, after tripartite negotiation, the final pricing of the platform is FCFA %.2f )</string> |
| | | <string name="争议订单协商价格">( Note: Disputed order, after tripartite negotiation, the final pricing of the platform is FCFA %s )</string> |
| | | <string name="被冻结">The order has been blocked by GOPOST, and GOPOST customer service will contact you</string> |
| | | <string name="取消订单费用">Cancellation fee</string> |
| | | <string name="请求出错" >Request error</string> |
| | |
| | | <string name="停车费">Parking</string> |
| | | <string name="过路费">Péages</string> |
| | | <string name="小费">pointe</string> |
| | | <string name="平台服务费">Frais de service de la plateforme</string> |
| | | <string name="平台服务费">Frais de plateforme</string> |
| | | <string name="工商银行">ICBC</string> |
| | | <string name="修改">Réviser</string> |
| | | <string name="删除">Effacer</string> |
| | |
| | | <string name="用户取消有费用">L’abonné a annulé la commande\nFrais d’annulation : FCFA %s</string> |
| | | <string name="平台取消无费用">La plateforme a annulé cette commande.\nSi vous avez des questions, veuillez contacter le service client de la plateforme.</string> |
| | | <string name="srl_header_update">\'Dernière mise à jour\' M-d HH:mm</string> |
| | | <string name="差价待确认">" Différence FCFA %.2f\n(En attente de confirmation)"</string> |
| | | <string name="差价点击修改">Différence FCFA %.2f\n(Cliquez pour modifier)</string> |
| | | <string name="差价待确认">" Différence FCFA %s\n(En attente de confirmation)"</string> |
| | | <string name="差价点击修改">Différence FCFA %s\n(Cliquez pour modifier)</string> |
| | | <string name="no_sender">L’expéditeur ne s’est pas présenté</string> |
| | | <string name="到达取件地点">Arrivé au lieu de prise en charge</string> |
| | | <string name="订单待评价">Order en attente de commentaires</string> |
| | | <string name="订单已完成">Commande terminée</string> |
| | | <string name="差价">Différence de frais</string> |
| | | <string name="争议订单协商价格">( Remarque: Il s’agit d’une commande contestée, et après des négociations entre trois parties, la plateforme l’a finalement tarifée à FCFA %.2f )</string> |
| | | <string name="争议订单协商价格">( Remarque: Il s’agit d’une commande contestée, et après des négociations entre trois parties, la plateforme l’a finalement tarifée à FCFA %s )</string> |
| | | <string name="被冻结">La commande a été bloquée par GOPOST, et le service client d’GOPOST vous contactera</string> |
| | | <string name="取消订单费用">Frais d\'annulation</string> |
| | | <string name="请求出错" >Erreur de demande</string> |
| | |
| | | <string name="使用记录">使用记录</string> |
| | | <string name="现金支付提示">现金支付提示</string> |
| | | <string name="客户已选择支付现金">客户已选择支付现金,因此您必须收款。</string> |
| | | <string name="确认现金金额">确定您已收到此订单费用:现金FCFA%.2f</string> |
| | | <string name="确认现金金额">确定您已收到此订单费用:现金FCFA %.2f</string> |
| | | <string name="please_enter_car_color">请输入颜色</string> |
| | | <string name="please_enter_car_mode">请输入品牌</string> |
| | | <string name="please_enter_car_type">请输入型号</string> |
| | |
| | | <string name="用户取消有费用">用户已取消此订单\n取消费用:FCFA %s</string> |
| | | <string name="平台取消无费用">平台已取消此订单\n若有疑问,请联系平台客服</string> |
| | | <string name="srl_header_update">上次更新 M-d HH:mm</string> |
| | | <string name="差价待确认">差价 FCFA %.2f (待用户确认)</string> |
| | | <string name="差价点击修改">差价 FCFA %.2f (点击修改)</string> |
| | | <string name="差价待确认">差价 FCFA %s (待用户确认)</string> |
| | | <string name="差价点击修改">差价 FCFA %s (点击修改)</string> |
| | | <string name="no_sender">没见到寄件人</string> |
| | | <string name="到达取件地点">到达取件地点</string> |
| | | <string name="订单待评价">订单待评价</string> |
| | | <string name="订单已完成">订单已完成</string> |
| | | <string name="差价">差价</string> |
| | | <string name="争议订单协商价格">( 注意: 争议订单,经过三方协商,平台最终定价为 FCFA %.2f )</string> |
| | | <string name="争议订单协商价格">( 注意: 争议订单,经过三方协商,平台最终定价为 FCFA %s )</string> |
| | | <string name="被冻结">此订单已被平台冻结,平台客服将会联系您</string> |
| | | <string name="取消订单费用">取消订单费用</string> |
| | | <string name="请求出错">请求出错</string> |
| | |
| | | @Override |
| | | public void onCreate() { |
| | | super.onCreate(); |
| | | logRecord(TAG, "onCreate"); |
| | | logRecord("onCreate"); |
| | | } |
| | | |
| | | void init() { |
| | |
| | | if (mConnection == null || mConnection.getChannel() == null |
| | | || !mConnection.getChannel().isActive() |
| | | || !mConnection.getChannel().isWritable()) { |
| | | logRecord(TAG, "checkState need reConnect"); |
| | | logRecord("checkState need reConnect"); |
| | | return false; |
| | | } else { |
| | | logRecord(TAG, "checkState no need reConnect"); |
| | | logRecord("checkState no need reConnect"); |
| | | return true; |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public void onNetConnected(NetUtils.NetType type) { |
| | | super.onNetConnected(type); |
| | | logRecord(TAG, "onNetConnected start checkState"); |
| | | logRecord("onNetConnected start checkState"); |
| | | boolean state = checkState(); |
| | | if (!state) { |
| | | reConnect(); |
| | |
| | | @Override |
| | | public void onNetDisConnect() { |
| | | super.onNetDisConnect(); |
| | | logRecord(TAG, "onNetDisConnect"); |
| | | logRecord("onNetDisConnect"); |
| | | } |
| | | }; |
| | | NetStateReceiver.registerObserver(mNetChangeObserver); |
| | |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | isDestroy = true; |
| | | logRecord(TAG, "onDestroy"); |
| | | logRecord("onDestroy"); |
| | | NetStateReceiver.unRegisterNetworkStateReceiver(this); |
| | | if (subscriber != null && !subscriber.isUnsubscribed()) { |
| | | subscriber.unsubscribe(); |
| | |
| | | |
| | | private void connectServer() { |
| | | boolean status = NetUtils.isNetworkAvailable(this); |
| | | logRecord(TAG, "connectServer net status = " + status); |
| | | logRecord("connectServer net status = " + status); |
| | | if (status) { |
| | | connectionSub(); |
| | | connect(Config.SOCKET_SERVER, Config.SOCKET_PORT) |
| | |
| | | @Override |
| | | public void onError(Throwable e) { |
| | | e.printStackTrace(); |
| | | logRecord(TAG, "connectionSub onError " + e.getMessage()); |
| | | logRecord("connectionSub onError " + e.getMessage()); |
| | | reConnect(); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onError(Throwable e) { |
| | | logRecord(TAG, "initReceiveOb onError " + e.getMessage()); |
| | | logRecord("initReceiveOb onError " + e.getMessage()); |
| | | reConnect(); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | private void reConnect() { |
| | | logRecord(TAG, "reConnect isDestroy = " + isDestroy); |
| | | logRecord("reConnect isDestroy = " + isDestroy); |
| | | if (isDestroy) { |
| | | return; |
| | | } |
| | |
| | | mConnection.close(); |
| | | mConnection = null; |
| | | } |
| | | logRecord(TAG, "reConnect sendHeart_websocket长连接断开,重新连接"); |
| | | logRecord("reConnect sendHeart_websocket长连接断开,重新连接"); |
| | | connectServer(); |
| | | } |
| | | }); |
| | |
| | | config.setSingleTagSwitch(true); |
| | | config.setLogHeadSwitch(false); |
| | | |
| | | logRecord("MyApplication", "initLogs"); |
| | | logRecord("initLogs"); |
| | | } |
| | | |
| | | public static void logRecord(String name, String info) { |
| | | String tag = name + " [" + Thread.currentThread().getName() + "-" + Thread.currentThread().getId() + "]"; |
| | | LogUtils.iTag(tag, info); |
| | | public static void logRecord(String info) { |
| | | LogUtils.iTag(getDefaultTag(), info); |
| | | } |
| | | |
| | | private static String getDefaultTag() { |
| | | StackTraceElement[] stacks = new Throwable().getStackTrace(); |
| | | StackTraceElement stackTraceElement = stacks[0]; |
| | | for (StackTraceElement stack : stacks) { |
| | | if (stack.getClassName().equalsIgnoreCase(stackTraceElement.getClassName())) { |
| | | continue; |
| | | } |
| | | stackTraceElement = stack; |
| | | break; |
| | | } |
| | | String runningClassName = stackTraceElement.getClassName(); |
| | | String runningMethodName = stackTraceElement.getMethodName(); |
| | | int i = runningClassName.lastIndexOf("."); |
| | | if (i != -1) { |
| | | runningClassName = runningClassName.substring(i + 1); |
| | | } |
| | | Thread thread = Thread.currentThread(); |
| | | return "[" + thread.getName() + "-" + thread.getId() + "] " + runningClassName + "." + runningMethodName; |
| | | } |
| | | } |
| | |
| | | * @param msg |
| | | */ |
| | | public void sendMessage(String msg) { |
| | | logRecord(TAG, "sendMessage sendListener is null " + (sendListener == null) + " msg = " + msg); |
| | | logRecord("sendMessage sendListener is null " + (sendListener == null) + " msg = " + msg); |
| | | if (sendListener != null) { |
| | | sendListener.onSend(msg); |
| | | } |
| | |
| | | * 检测netty连接状况 |
| | | */ |
| | | public boolean checkNettyState() { |
| | | logRecord(TAG, "checkNettyState onCheckListener is null " + (onCheckListener == null)); |
| | | logRecord("checkNettyState onCheckListener is null " + (onCheckListener == null)); |
| | | if (onCheckListener != null) { |
| | | return onCheckListener.doCheck(); |
| | | } else { |