|
@@ -12,6 +12,7 @@ import android.app.Fragment
|
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
|
import android.databinding.ObservableField
|
|
|
+import android.os.Build
|
|
|
import android.os.Handler
|
|
|
import android.os.Looper
|
|
|
import android.support.v4.content.ContextCompat
|
|
@@ -32,6 +33,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.umeng.socialize.utils.DeviceConfig.context
|
|
|
import io.reactivex.disposables.Disposable
|
|
|
import okhttp3.ResponseBody
|
|
@@ -87,22 +89,26 @@ fun showMessage(message: String) {
|
|
|
if (message == ""){
|
|
|
return
|
|
|
}
|
|
|
- val messageCallback = {
|
|
|
|
|
|
-// Toast.makeText(BaseApplication.appContext, message, Toast.LENGTH_SHORT).show()
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
|
+ Toaster.showShort(message)
|
|
|
+ } else {
|
|
|
+ val messageCallback = {
|
|
|
+ //Toast.makeText(BaseApplication.appContext, message, Toast.LENGTH_SHORT).show()
|
|
|
|
|
|
- if (toast == null) {
|
|
|
- toast = Toast.makeText(BaseApplication.appContext, message, Toast.LENGTH_SHORT)
|
|
|
- } else {
|
|
|
- toast!!.setText(message)
|
|
|
+ if (toast == null) {
|
|
|
+ toast = Toast.makeText(BaseApplication.appContext, message, Toast.LENGTH_SHORT)
|
|
|
+ } else {
|
|
|
+ toast!!.setText(message)
|
|
|
+ }
|
|
|
+ toast!!.show()
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ messageCallback.invoke()
|
|
|
+ } catch (runtime: RuntimeException) {
|
|
|
+ Looper.prepare()
|
|
|
+ messageCallback.invoke()
|
|
|
}
|
|
|
- toast!!.show()
|
|
|
- }
|
|
|
- try {
|
|
|
- messageCallback.invoke()
|
|
|
- } catch (runtime: RuntimeException) {
|
|
|
- Looper.prepare()
|
|
|
- messageCallback.invoke()
|
|
|
}
|
|
|
}
|
|
|
|