فهرست منبع

更新toast框架,解决部分Android版本上会报android.view.WindowManager$BadTokenException异常问题

weizhengliang 1 سال پیش
والد
کامیت
b96993cc48

+ 1 - 1
android_host/src/main/java/com/wdkl/ncs/android/component/nursehome/util/LedHelper.java

@@ -144,7 +144,7 @@ public class LedHelper {
 
         if (interactionVO.getToDeviceType() == DeviceTypeEnum.DIGIT_BED_DEVICE.value()
                 || interactionVO.getToDeviceType() == DeviceTypeEnum.SIMULATE_BED_DEVICE.value()
-                || interactionVO.getFromDeviceType() == DeviceTypeEnum.DOOR_DEVICE.value()) {
+                || interactionVO.getToDeviceType() == DeviceTypeEnum.DOOR_DEVICE.value()) {
             String frameName = interactionVO.getToFrameFullName().replace("-", "");
             String call = BaseApplication.appContext.getString(R.string.led_show_voice_call, frameName);
             LedManagerUtils.getInstance().updateProgram(call, 2);

+ 3 - 0
app/src/main/code/com/wdkl/app/ncs/application/Application.kt

@@ -5,6 +5,7 @@ import android.content.Context
 import android.content.res.Configuration
 import com.enation.javashop.android.jrouter.JRouter
 import com.enation.javashop.android.welcome.BuildConfig
+import com.hjq.toast.Toaster
 import com.wdkl.ncs.android.lib.base.BaseApplication
 import com.wdkl.ncs.android.lib.core.locale.LocaleMangerUtils
 import com.wdkl.ncs.android.lib.core.locale.SettingConfigNew
@@ -111,6 +112,8 @@ class Application : BaseApplication() {
      * @return rx观察者
      */
     private fun initFrame() {
+        // 初始化 Toast 框架
+        Toaster.init(this)
     }
 
     override fun attachBaseContext(base: Context) {

+ 2 - 0
common/build.gradle

@@ -267,6 +267,8 @@ dependencies {
     //linphone sip sdk
     api(name: 'linphone-sdk-android-5.0.71', ext: 'aar')
 
+    api(name: 'Toaster-12.2', ext: 'aar')
+
     compile project(':resource')
 
     //大朝华15.6寸rk主机api

BIN
common/libs/Toaster-12.2.aar


+ 10 - 2
common/src/main/code/com/wdkl/ncs/android/lib/utils/ExtendMethods.kt

@@ -31,6 +31,7 @@ import com.enation.javashop.net.engine.plugin.rxbus.RxBus
 import com.enation.javashop.utils.base.tool.CommonTool
 import com.enation.javashop.utils.base.tool.ScreenTool
 import com.enation.javashop.utils.logger.LoggerFactory
+import com.hjq.toast.Toaster
 import com.wdkl.ncs.android.lib.R
 import io.reactivex.disposables.Disposable
 import okhttp3.ResponseBody
@@ -85,7 +86,14 @@ fun showMessage(message: String) {
     if (message == ""){
         return
     }
-    val messageCallback = {
+
+    try {
+        Toaster.showShort(message)
+    } catch (ex: Exception) {
+        //
+    }
+
+    /*val messageCallback = {
         Toast.makeText(BaseApplication.appContext, message, Toast.LENGTH_SHORT).show()
     }
     try {
@@ -93,7 +101,7 @@ fun showMessage(message: String) {
     } catch (runtime: RuntimeException) {
         Looper.prepare()
         messageCallback.invoke()
-    }
+    }*/
 }
 
 fun showMessage(resId: Int) {