| | |
| | | import cn.sinata.rxnetty.LogHelper.logRecord |
| | | import cn.sinata.rxnetty.NettyClient |
| | | import cn.sinata.xldutils.BaseApplication |
| | | import cn.sinata.xldutils.utils.sysErr |
| | | import com.driver.igotrip.R |
| | | import com.driver.igotrip.bean.OrderBean |
| | | import com.driver.igotrip.bean.OrderResData |
| | |
| | | import com.driver.igotrip.utils.Cache.CacheKey |
| | | import com.driver.igotrip.utils.Cache.CacheUtil |
| | | import com.driver.igotrip.utils.LogUtils |
| | | import com.driver.igotrip.utils.crash.CrashHandler |
| | | import com.google.android.gms.maps.model.LatLng |
| | | import com.google.cloud.texttospeech.v1.* |
| | | import com.google.gson.Gson |
| | | import com.google.protobuf.ByteString |
| | | import com.xuexiang.xui.XUI |
| | | import org.greenrobot.eventbus.EventBus |
| | | import org.jetbrains.anko.startActivity |
| | | import org.jetbrains.anko.toast |
| | | import org.json.JSONObject |
| | | import java.io.FileOutputStream |
| | | import java.security.SecureRandom |
| | | import java.security.cert.X509Certificate |
| | | import java.util.* |
| | | import javax.net.ssl.HttpsURLConnection |
| | | import javax.net.ssl.SSLContext |
| | | import javax.net.ssl.TrustManager |
| | | import javax.net.ssl.X509TrustManager |
| | | |
| | | //MD5: A6:19:B7:92:10:27:61:22:BC:37:1B:98:9B:9E:1A:82 |
| | | //SHA1: B9:D3:9B:10:B1:25:77:FF:62:D2:56:83:CC:14:1B:EA:DB:BC:97:74 |
| | |
| | | * Created by Administrator on 2018/1/17. |
| | | */ |
| | | open class MyApplication : BaseApplication(), Application.ActivityLifecycleCallbacks { |
| | | //设置debug模式 |
| | | var isDebug = false |
| | | var heartHandler: Handler? = null |
| | | var currentTime = System.currentTimeMillis() |
| | | private val heartHandler = Handler(Looper.getMainLooper()) |
| | | private var currentTime = System.currentTimeMillis() |
| | | |
| | | override fun setSharedPreferencesName(): String { |
| | | return "MyApplication" |
| | |
| | | // PlatformConfig.setQQZone("1111276329", "JuAotVjQcUiesxgp") //qq互联 |
| | | // CrashReport.initCrashReport(this, "163c95c374", true); |
| | | LogUtils.OpenLog(true) |
| | | initLogs() |
| | | initLogs(this) |
| | | initSocket() |
| | | // JPushInterface.setDebugMode(true) |
| | | // JPushInterface.init(this) |
| | | setAlisa() |
| | | CrashHandler.init(this) |
| | | } |
| | | |
| | | public fun setAlisa() { |
| | | if (CacheKey.getUserId().isNotEmpty()) { |
| | | var alisa = "DRIVER" + CacheKey.getUserId() |
| | | sysErr(alisa) |
| | | val alisa = "DRIVER" + CacheKey.getUserId() |
| | | mHandler.sendMessage(mHandler.obtainMessage(MSG_SET_ALIAS, alisa)) |
| | | } |
| | | } |
| | |
| | | MSG_ORDER_CANCEL -> { |
| | | val pair = msg.obj as Pair<String, OrderSimpleData> |
| | | val orderBean = Gson().fromJson(pair.first, OrderBean::class.java) |
| | | val act = activities[activities.size - 1] |
| | | val act = getTopActivity() |
| | | if (orderBean.data.cancelMidway == 1) { |
| | | logRecord("订单被中途取消") |
| | | (act as PublicServiceActivity).cancelOrder( |
| | | pair.second.audioUrl, |
| | | pair.second.orderId.toString(), |
| | |
| | | ) |
| | | if (act is PublicServiceDialogActivity) act.finish() |
| | | } else if (pair.second.status == 12) { //取消待乘客支付弹窗 |
| | | logRecord("订单取消待支付") |
| | | (act as PublicServiceActivity).cancelOrder( |
| | | pair.second.audioUrl, |
| | | "${orderBean.data.cancelPayMoney}" |
| | | pair.second.audioUrl, "${orderBean.data.cancelPayMoney}" |
| | | ) |
| | | if (act is PublicServiceDialogActivity) act.finish() |
| | | } else { |
| | | if (pair.second.status == 10 && orderBean.data.cancelPayMoney != 0.0) { |
| | | //乘客已支付的取消,不做处理 |
| | | logRecord("乘客已支付的取消") |
| | | } else if (orderBean.data.timeOutCancel < System.currentTimeMillis()) { //已超时弹窗 |
| | | logRecord("订单已超时") |
| | | (act as PublicServiceActivity).cancelOrder( |
| | | pair.second.from, |
| | | pair.second.audioUrl, |
| | |
| | | // "orderId" to pair.second.orderId.toString(), |
| | | // "orderType" to pair.second.orderType.toString() |
| | | // ) |
| | | Handler(mainLooper).post { |
| | | getTTsManager().setVideoText(pair.second.audioUrl) |
| | | } |
| | | logRecord("司机没超时,用户也无取消费用,只播语音 不做处理") |
| | | getTTsManager().setVideoText(pair.second.audioUrl) |
| | | } |
| | | } |
| | | } |
| | |
| | | // } |
| | | |
| | | private fun initSocket() { |
| | | Log.e("sendLocation: ", "开始链接") |
| | | NettyClient.getInstance().init(this, Api.SOCKET_SERVER, Api.SOCKET_PORT, true) |
| | | NettyClient.getInstance().addOnMessageListener { message: String -> |
| | | initnetdata(message) |
| | |
| | | NettyClient.getInstance().setOnConnectListener { |
| | | sendHeart() |
| | | } |
| | | if (frist) { |
| | | /* MainScope().launch { |
| | | while (true){ |
| | | delay(5000) |
| | | var map = getMapByAny() |
| | | if (getDriverOrderMessage.startsWith("api")) { |
| | | map["appid"] = getAppId() |
| | | var sign = DES.getSign(map) |
| | | map["sign"] = sign |
| | | } |
| | | HttpManager.getInstance().post(getDriverOrderMessage, map, object : MyNoMsgObserver(this@MyApplication) { |
| | | override fun success(responseString: String?) { |
| | | Log.e("长连接接口消息: ",responseString.toString() ) |
| | | initnetdata(responseString.toString()) |
| | | } |
| | | }) |
| | | } |
| | | }*/ |
| | | frist = false |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | val json = JSONObject(message) |
| | | val method = json.optString("method") |
| | | if (method != "OK") { |
| | | Log.d("zmc-socket", message) |
| | | Log.d(TAG, message) |
| | | } |
| | | val data = json.optString("data") |
| | | val code = json.optInt("code", -1) |
| | | if (code == 200) { |
| | | Log.e(" 订单: ", method) |
| | | Log.e(TAG, "method: $method") |
| | | when (method) { |
| | | Const.SOCKET_METHOD.OK -> { |
| | | testReceiveNum++ |
| | | |
| | | } |
| | | |
| | | Const.SOCKET_METHOD.OFFLINE -> { |
| | | logRecord("socket==>账号被挤下线:$data") |
| | | val simpleData = |
| | | Gson().fromJson( |
| | | data, |
| | | OrderSimpleData::class.java |
| | | ) |
| | | CacheUtil.get().clear() |
| | | CacheKey.putKeyStr("isAgreen", "1") |
| | | NettyClient.getInstance().stopService() |
| | |
| | | |
| | | Const.SOCKET_METHOD.AFTER_WORK -> { |
| | | logRecord("socket==>强制下线:$data") |
| | | val simpleData = |
| | | Gson().fromJson( |
| | | data, |
| | | OrderSimpleData::class.java |
| | | ) |
| | | val simpleData = Gson().fromJson( |
| | | data, OrderSimpleData::class.java |
| | | ) |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.FORCED_OFFLINE)) |
| | | val act = activities[activities.size - 1] |
| | | val act = getTopActivity() |
| | | (act as PublicServiceActivity).forceOffline( |
| | | simpleData.audioUrl, |
| | | simpleData.msg |
| | | simpleData.audioUrl, simpleData.msg |
| | | ) |
| | | if (act is PublicServiceDialogActivity) act.finish() |
| | | } |
| | | |
| | | Const.SOCKET_METHOD.ORDER_STATUS -> { |
| | | logRecord("socket==>订单状态改变:$data") |
| | | val orderSimpleData = |
| | | Gson().fromJson( |
| | | data, |
| | | OrderSimpleData::class.java |
| | | ) |
| | | |
| | | OrderTimeOutManager.instance.checkOrderManager( |
| | | "${orderSimpleData.orderId}", |
| | | "${orderSimpleData.orderType}", |
| | | orderSimpleData.status |
| | | val orderSimpleData = Gson().fromJson( |
| | | data, OrderSimpleData::class.java |
| | | ) |
| | | |
| | | for (view in orderStatueViews.asReversed().indices) { |
| | | orderStatueViews[view].orderInfo(orderSimpleData) |
| | | } |
| | | if (orderSimpleData.status == 1) { |
| | | val act = activities[activities.size - 1] |
| | | // MyApplication.getTTsManager().setVideoText("收到新的订单") |
| | | val act = getTopActivity() |
| | | // MyApplication.getTTsManager().setVideoText("收到新的订单") |
| | | |
| | | Log.e(" 订单: ", "showOrder") |
| | | logRecord("socket==>收到新的订单") |
| | | when (orderSimpleData.orderType) { |
| | | |
| | | 1, 2 -> { |
| | |
| | | } |
| | | } |
| | | if (orderSimpleData.status == 2) { |
| | | val act = activities[activities.size - 1] |
| | | logRecord("socket==>处理订单") |
| | | val act = getTopActivity() |
| | | when (orderSimpleData.orderType) { |
| | | 1, 2 -> { |
| | | (act as PublicServiceActivity).toDorderAct( |
| | | orderSimpleData.orderId.toString(), |
| | | orderSimpleData.orderType.toString() |
| | | orderSimpleData.orderId.toString(), orderSimpleData.orderType.toString() |
| | | ) |
| | | if (act is PublicServiceDialogActivity) act.finish() |
| | | } |
| | | |
| | | 4, 5 -> { |
| | | act?.startActivity<SmallCargoActivity>( |
| | | "orderId" to orderSimpleData.orderId.toString(), |
| | | "orderType" to orderSimpleData.orderType.toString() |
| | | "orderId" to orderSimpleData.orderId.toString(), "orderType" to orderSimpleData.orderType.toString() |
| | | ) |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | if (orderSimpleData.status == 10 || orderSimpleData.status == 12) { |
| | | logRecord("socket==>订单被取消") |
| | | val map = getMapByAny() |
| | | map["orderId"] = orderSimpleData.orderId |
| | | map["orderType"] = orderSimpleData.orderType |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.ORDER_CANCEL)) |
| | | callNet(this, Api.queryOrderInfo, map) { |
| | | callNet1(this, Api.queryOrderInfo, map, clickAction = { |
| | | logRecord("socket==>订单被取消获取订单详情成功data:$it") |
| | | val message = Message().apply { |
| | | what = MSG_ORDER_CANCEL |
| | | obj = Pair(it, orderSimpleData) |
| | | } |
| | | mHandler.sendMessage(message) |
| | | } |
| | | }, errorAction = { code, msg -> |
| | | logRecord("socket==>订单被取消获取订单详情失败code:${code} msg:${msg}") |
| | | }, showError = false) |
| | | } |
| | | } |
| | | |
| | | Const.SOCKET_METHOD.OFFLINE_PAYMENT -> { |
| | | logRecord("socket==>离线支付:$data") |
| | | val orderSimpleData = |
| | | Gson().fromJson( |
| | | data, |
| | | OrderResData::class.java |
| | | ) |
| | | val act = activities[activities.size - 1] |
| | | val orderSimpleData = Gson().fromJson(data, OrderResData::class.java) |
| | | val act = getTopActivity() |
| | | (act as PublicServiceActivity).showDriverPayDialog( |
| | | orderSimpleData.audioUrl, |
| | | orderSimpleData.orderId.toString(), |
| | | orderSimpleData.orderType.toString(), orderSimpleData.money |
| | | orderSimpleData.audioUrl, orderSimpleData.orderId.toString(), orderSimpleData.orderType.toString(), orderSimpleData.money |
| | | ) |
| | | if (act is PublicServiceDialogActivity) act.finish() |
| | | } |
| | |
| | | |
| | | Const.SOCKET_METHOD.REASSIGN -> { |
| | | logRecord("socket==>改派:$data") |
| | | Log.e( |
| | | "zmc-socket", |
| | | "EventBus.getDefault().post(BaseEvent(BaseEvent.REFREASH_MAIN))" |
| | | ) |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.REFREASH_MAIN)) |
| | | |
| | | // val orderSimpleData = |
| | |
| | | // data, |
| | | // OrderResData::class.java |
| | | // ) |
| | | // val act = activities[activities.size - 1] |
| | | // val act = getTopActivity() |
| | | // when (orderSimpleData.orderType) { |
| | | //// 1, 2, 4 -> { |
| | | //// (act as PublicServiceActivity).showOrder( |
| | |
| | | val jsob = JSONObject(data) |
| | | // if (jsob.optString("status") == "1") { // 只处理 申请订单消息 |
| | | logRecord("socket==>修改目的地:$jsob") |
| | | val act = activities[activities.size - 1] |
| | | val act = getTopActivity() |
| | | (act as PublicServiceActivity).modifyAddress( |
| | | jsob.optString("audioUrl"), |
| | | jsob.optString("orderId"), |
| | | jsob.optString("orderType") |
| | | jsob.optString("audioUrl"), jsob.optString("orderId"), jsob.optString("orderType") |
| | | ) |
| | | // } |
| | | if (act is PublicServiceDialogActivity) act.finish() |
| | |
| | | Const.SOCKET_METHOD.ORDER_TIME_OUT -> { |
| | | val jsob = JSONObject(data) |
| | | logRecord("socket==>订单超时:$jsob") |
| | | val act = activities[activities.size - 1] |
| | | val act = getTopActivity() |
| | | |
| | | /** |
| | | * 司机超时推送 |
| | |
| | | if (act is PublicServiceDialogActivity) act.finish() |
| | | } else if (timeOutType == "2") { // 提示并查看订单详情 |
| | | (act as PublicServiceActivity).goOrderTips( |
| | | orderId, |
| | | orderType, |
| | | audioUrl, |
| | | describe |
| | | orderId, orderType, audioUrl, describe |
| | | ) |
| | | if (act is PublicServiceDialogActivity) act.finish() |
| | | } |
| | |
| | | when (jsob.optString("status")) { // status 1=申请,2=同意,3=拒绝 |
| | | "1" -> {} |
| | | "2" -> { |
| | | EventBus.getDefault() |
| | | .post(BaseEvent(BaseEvent.DIFF_PRICE_AGREE)) |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.DIFF_PRICE_AGREE)) |
| | | } |
| | | |
| | | "3" -> { |
| | | val act = activities[activities.size - 1] |
| | | val act = getTopActivity() |
| | | val tips = "${act!!.getString(R.string.您的包裹订单)}${ |
| | | jsob.optString("orderId") |
| | | }\n${ |
| | |
| | | } ${act.getString(R.string.money)} ${jsob.optString("money")} ${ |
| | | act.getString(R.string.补差价被拒) |
| | | }" |
| | | EventBus.getDefault() |
| | | .post(BaseEvent(BaseEvent.DIFF_PRICE_REFUSE)) |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.DIFF_PRICE_REFUSE)) |
| | | (act as PublicServiceActivity).onlyTips( |
| | | jsob.optString("audioUrl"), |
| | | tips |
| | | jsob.optString("audioUrl"), tips |
| | | ) |
| | | if (act is PublicServiceDialogActivity) act.finish() |
| | | } |
| | |
| | | |
| | | } |
| | | } else { |
| | | sysErr("socket return code ===$code") |
| | | Log.e(TAG, "socket return code ===$code") |
| | | } |
| | | } catch (e: Exception) { |
| | | e.printStackTrace() |
| | |
| | | } |
| | | |
| | | private fun getOrderWhenNoSocket() { |
| | | Log.e("sendLocation: ", "定时获取司机订单数据" + (getUserId() != -1).toString()) |
| | | Log.e(TAG, "定时获取socket数据" + (getUserId() != -1).toString()) |
| | | if (getUserId() != -1) { |
| | | val map = getMapByAny() |
| | | callNet1(this, Api.getDriverOrderMessage, map, clickAction = { |
| | | logRecord("getOrderWhenNoSocket 获取订单成功 $it") |
| | | initnetdata(it ?: "") |
| | | }, { |
| | | logRecord("getOrderWhenNoSocket 获取订单失败") |
| | | }, { code, msg -> |
| | | Log.e(TAG, "定时获取socket数据: code:${code} msg:${msg}") |
| | | }, false) |
| | | } |
| | | } |
| | | |
| | | private fun sendLocation() { |
| | | Log.e( |
| | | "sendLocation: ", |
| | | "发送定位 userId = ${getUserId()}, aMapLocation = ${Gson().toJson(aMapLocation)}" |
| | | TAG, "发送定位 userId = ${getUserId()}, latitude = ${aMapLocation?.latitude},longitude = ${aMapLocation?.longitude}" |
| | | ) |
| | | if (getUserId() != -1 && aMapLocation != null) { |
| | | val map = getMapByAny() |
| | |
| | | map["driverId"] = getUserId() |
| | | map["lon"] = aMapLocation!!.longitude |
| | | map["lat"] = aMapLocation!!.latitude |
| | | logRecord("sendLocation 发送定位参数" + Gson().toJson(map)) |
| | | callNet1(this, Api.saveOrderPosition, map, clickAction = { |
| | | logRecord("sendLocation 发送定位成功") |
| | | }, { |
| | | logRecord("sendLocation 发送定位失败") |
| | | callNet1(this, Api.saveOrderPosition, map, clickAction = {}, { code, msg -> |
| | | Log.e(TAG, "saveOrderPosition失败: code:${code} msg:${msg}") |
| | | }, false) |
| | | |
| | | val map1 = getMapByAny() |
| | |
| | | map1["altitude"] = 0 |
| | | map1["directionAngle"] = 0 |
| | | |
| | | callNet1(this, Api.positionSocket, map1, clickAction = { |
| | | logRecord("positionSocket 发送定位成功") |
| | | }, { |
| | | logRecord("positionSocket 发送定位失败") |
| | | callNet1(this, Api.positionSocket, map1, clickAction = {}, { code, msg -> |
| | | Log.e(TAG, "positionSocket失败: code:${code} msg:${msg}") |
| | | }, false) |
| | | } |
| | | } |
| | | |
| | | val TAG = "MyApplication" |
| | | private val TAG = "MyApplication" |
| | | private fun sendHeart() { |
| | | if (getUserId() != -1) { |
| | | logRecord("sendHeart: userId = " + getUserId()) |
| | | val bean = HeartBean() |
| | | bean.data = HeartBean.DataBean() |
| | | NettyClient.getInstance().sendMessage(Gson().toJson(bean)) |
| | | sendLocation() |
| | | if (heartHandler == null) { |
| | | heartHandler = Handler(mainLooper) |
| | | } |
| | | heartHandler!!.removeCallbacksAndMessages(null) |
| | | testHeartNunm++ |
| | | heartHandler.removeCallbacksAndMessages(null) |
| | | // if ((System.currentTimeMillis() - currentTime) / 1000 > 3) { |
| | | // sysErr("sendHeart_websocket 重新连接") |
| | | logRecord("sendHeart check socket status") |
| | | currentTime = System.currentTimeMillis() |
| | | val nettyState = NettyClient.getInstance().checkNettyState() |
| | | if (!nettyState) { |
| | |
| | | // sysErr("sendHeart_websocket 发送心跳") |
| | | // } |
| | | } |
| | | heartHandler!!.postDelayed({ sendHeart() }, 5000) |
| | | heartHandler.postDelayed({ sendHeart() }, 5000) |
| | | } |
| | | |
| | | interface OrderStatueView { |
| | |
| | | |
| | | |
| | | companion object { |
| | | var frist = true |
| | | private const val TAG = "MyApplication" |
| | | public var appContext: MyApplication? = null |
| | | var appContext: MyApplication? = null |
| | | var mTtsManager: AudioRecoderUtils? = null |
| | | var isPlayVoice = true |
| | | var lastPlayTime = 0L //上次提示播放时间 |
| | | var hasAutoGoTripping = false //true 本次启动已经自动跳转过 |
| | | public var isLogin: Boolean = true |
| | | var isLogin: Boolean = true |
| | | fun getInstance(): MyApplication? { |
| | | if (appContext == null) { |
| | | appContext = MyApplication() |
| | |
| | | } |
| | | |
| | | fun getLocation(): LatLng? { |
| | | if (aMapLocation == null) { |
| | | return null |
| | | } else { |
| | | return aMapLocation!! |
| | | } |
| | | return aMapLocation |
| | | } |
| | | |
| | | fun tts(content: String) { |
| | | Thread { |
| | | |
| | | TextToSpeechClient.create().use { textToSpeechClient -> |
| | | // Set the text input to be synthesized |
| | | val input: SynthesisInput = |
| | | SynthesisInput.newBuilder().setText(content).build() |
| | | |
| | | // Build the voice request, select the language code ("en-US") and the ssml voice gender |
| | | // ("neutral") |
| | | val voice: VoiceSelectionParams = VoiceSelectionParams.newBuilder() |
| | | .setLanguageCode("en-US") |
| | | .setSsmlGender(SsmlVoiceGender.NEUTRAL) |
| | | .build() |
| | | |
| | | // Select the type of audio file you want returned |
| | | val audioConfig: AudioConfig = |
| | | AudioConfig.newBuilder().setAudioEncoding(AudioEncoding.MP3).build() |
| | | |
| | | // Perform the text-to-speech request on the text input with the selected voice parameters and |
| | | // audio file type |
| | | val response: SynthesizeSpeechResponse = |
| | | textToSpeechClient.synthesizeSpeech(input, voice, audioConfig) |
| | | |
| | | // Get the audio contents from the response |
| | | val audioContents: ByteString = response.getAudioContent() |
| | | |
| | | FileOutputStream("output.mp3").use { out -> |
| | | out.write(audioContents.toByteArray()) |
| | | println("Audio content written to file \"output.mp3\"") |
| | | } |
| | | } |
| | | |
| | | }.start() |
| | | } |
| | | |
| | | var aMapLocation: LatLng? = null |
| | | private var aMapLocation: LatLng? = null |
| | | var currentOrderId: String = "" |
| | | var currentOrderType: String = "" |
| | | var orderStatueViews: MutableList<OrderStatueView> = |
| | | mutableListOf() |
| | | var testHeartNunm = 0 |
| | | var testReceiveNum = 0 |
| | | fun handleSSLHandshake() { |
| | | try { |
| | | val trustAllCerts = arrayOf<TrustManager>(object : X509TrustManager { |
| | | override fun getAcceptedIssuers(): Array<X509Certificate?> { |
| | | return arrayOfNulls(0) |
| | | } |
| | | var orderStatueViews: MutableList<OrderStatueView> = mutableListOf() |
| | | |
| | | override fun checkClientTrusted( |
| | | certs: Array<X509Certificate>, |
| | | authType: String, |
| | | ) { |
| | | } |
| | | //设置定位 |
| | | fun setLocation(latLng: LatLng) { |
| | | setLocation(latLng.latitude, latLng.longitude) |
| | | } |
| | | |
| | | override fun checkServerTrusted( |
| | | certs: Array<X509Certificate>, |
| | | authType: String, |
| | | ) { |
| | | } |
| | | }) |
| | | val sc = SSLContext.getInstance("TLS") |
| | | // trustAllCerts信任所有的证书 |
| | | sc.init(null, trustAllCerts, SecureRandom()) |
| | | HttpsURLConnection.setDefaultSSLSocketFactory(sc.socketFactory) |
| | | HttpsURLConnection.setDefaultHostnameVerifier { hostname, session -> true } |
| | | } catch (ignored: Exception) { |
| | | } |
| | | //设置定位 |
| | | fun setLocation(latitude: Double, longitude: Double) { |
| | | this.aMapLocation = LatLng(latitude, longitude) |
| | | } |
| | | |
| | | fun addOrderView(view: OrderStatueView) { |
| | |
| | | } |
| | | } |
| | | |
| | | val activities = ArrayList<Activity?>() |
| | | private val activities = ArrayList<Activity?>() |
| | | |
| | | //获取顶部activity |
| | | private fun getTopActivity(): Activity? { |
| | | return activities.lastOrNull() |
| | | } |
| | | |
| | | private var showNum = 0 |
| | | |
| | | fun finishAll() { |
| | |
| | | } |
| | | } |
| | | |
| | | fun getCurrentActivity(): Activity? { |
| | | var act: Activity? = try { |
| | | activities[activities.size - 1] |
| | | } catch (e: Exception) { |
| | | null |
| | | } |
| | | return act |
| | | } |
| | | |
| | | |
| | | override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { |
| | | activities.add(activity) |
| | | logRecord("onActivityCreated: " + activity.javaClass.name) |
| | | if (activity is MyBaseActivity) { |
| | | activity.supportFragmentManager.registerFragmentLifecycleCallbacks(object : |
| | | FragmentManager.FragmentLifecycleCallbacks() { |
| | | activity.supportFragmentManager.registerFragmentLifecycleCallbacks(object : FragmentManager.FragmentLifecycleCallbacks() { |
| | | override fun onFragmentCreated( |
| | | fm: FragmentManager, |
| | | f: Fragment, |
| | | savedInstanceState: Bundle? |
| | | fm: FragmentManager, f: Fragment, savedInstanceState: Bundle? |
| | | ) { |
| | | super.onFragmentCreated(fm, f, savedInstanceState) |
| | | logRecord("onFragmentCreated: " + f.javaClass.name) |
| | | } |
| | | |
| | | override fun onFragmentViewCreated( |
| | | fm: FragmentManager, |
| | | f: Fragment, |
| | | v: View, |
| | | savedInstanceState: Bundle? |
| | | fm: FragmentManager, f: Fragment, v: View, savedInstanceState: Bundle? |
| | | ) { |
| | | super.onFragmentViewCreated(fm, f, v, savedInstanceState) |
| | | logRecord("onFragmentViewCreated: " + f.javaClass.name) |