Merge branch 'dev_robobus-d_230413_3.1.0' into dev_robobus-d_230418_3.1.0_fuzhou
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
"socket_tech_url": "https://och-driver-eh.zhidaozhixing.com/arch/",
|
||||
"eagle_mis_url": "https://och-hailing-eh.zhidaozhixing.com/",
|
||||
"eagle_dns_url": "https://och-hailing-eh.zhidaozhixing.com/",
|
||||
"bind_driver_qr_url": "https://tech.zhidaohulian.com?pipe=ehsafety&sn=%1$s",
|
||||
"bind_driver_qr_url": "https://och-mini-eh.zhidaozhixing.com?pipe=ehsafety&sn=%1$s",
|
||||
"chart_socket_url":"wss://acp-eh.zhidaozhixing.com/ws"
|
||||
},
|
||||
"demo": {
|
||||
@@ -89,7 +89,7 @@
|
||||
"socket_tech_url": "https://och-driver-yt.zhidaozhixing.com/arch/",
|
||||
"eagle_mis_url": "https://och-hailing-yt.zhidaozhixing.com/",
|
||||
"eagle_dns_url": "https://och-hailing-yt.zhidaozhixing.com/",
|
||||
"bind_driver_qr_url": "https://tech.zhidaohulian.com?pipe=ytsafety&sn=%1$s",
|
||||
"bind_driver_qr_url": "https://och-mini-yt.zhidaozhixing.com?pipe=ytsafety&sn=%1$s",
|
||||
"chart_socket_url":""
|
||||
},
|
||||
"demo": {
|
||||
|
||||
@@ -52,7 +52,7 @@ class BusPassengerMsgBoxBubbleView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onDataChanged(category: MsgCategory, msgBoxList: MsgBoxBean){
|
||||
UiThreadHandler.post{
|
||||
UiThreadHandler.post({
|
||||
if(category == MsgCategory.NOTICE){
|
||||
if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X
|
||||
|| msgBoxList.type == MsgBoxType.OBU || msgBoxList.type == MsgBoxType.OPERATION){
|
||||
@@ -65,7 +65,7 @@ class BusPassengerMsgBoxBubbleView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
|
||||
@@ -70,7 +70,7 @@ class DriverMsgBoxBubbleView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onDataChanged(category: MsgCategory, msgBoxBean: MsgBoxBean) {
|
||||
UiThreadHandler.post {
|
||||
UiThreadHandler.post({
|
||||
when (category) {
|
||||
MsgCategory.NOTICE -> {
|
||||
MsgBoxConfig.noticeList.add(msgBoxBean)
|
||||
@@ -98,7 +98,7 @@ class DriverMsgBoxBubbleView @JvmOverloads constructor(
|
||||
driverMsgBoxBubbleAdapter?.setData(dataList)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
|
||||
@@ -171,7 +171,7 @@ class DriverMsgBoxListView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onDataChanged(category: MsgCategory, msgBoxList: MsgBoxBean) {
|
||||
UiThreadHandler.post{
|
||||
UiThreadHandler.post({
|
||||
when (category) {
|
||||
MsgCategory.NOTICE -> {
|
||||
noticeList?.add(0,msgBoxList)
|
||||
@@ -192,7 +192,7 @@ class DriverMsgBoxListView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
|
||||
@@ -55,7 +55,7 @@ class MBoxBubbleView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onDataChanged(category: MsgCategory, msgBoxList: MsgBoxBean) {
|
||||
UiThreadHandler.post {
|
||||
UiThreadHandler.post({
|
||||
if(category == MsgCategory.NOTICE){
|
||||
if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X
|
||||
|| msgBoxList.type == MsgBoxType.OBU || msgBoxList.type == MsgBoxType.OPERATION){
|
||||
@@ -68,7 +68,7 @@ class MBoxBubbleView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
|
||||
@@ -49,14 +49,14 @@ class MMsgBoxBubbleView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onDataChanged(category: MsgCategory, msgBoxList: MsgBoxBean) {
|
||||
UiThreadHandler.post {
|
||||
UiThreadHandler.post({
|
||||
if(category == MsgCategory.NOTICE){
|
||||
if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X
|
||||
|| msgBoxList.type == MsgBoxType.OBU || msgBoxList.type == MsgBoxType.OPERATION){
|
||||
update(msgBoxList)
|
||||
}
|
||||
}
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
private fun update(msgBoxList: MsgBoxBean){
|
||||
|
||||
@@ -56,7 +56,7 @@ class MMsgBoxListView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onDataChanged(category: MsgCategory, msgBoxList: MsgBoxBean) {
|
||||
UiThreadHandler.post{
|
||||
UiThreadHandler.post({
|
||||
if(category == MsgCategory.NOTICE){
|
||||
if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X
|
||||
|| msgBoxList.type == MsgBoxType.OBU || msgBoxList.type == MsgBoxType.OPERATION){
|
||||
@@ -66,7 +66,7 @@ class MMsgBoxListView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
|
||||
@@ -57,7 +57,7 @@ class PassengerMsgBoxBubbleView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onDataChanged(category: MsgCategory, msgBoxList: MsgBoxBean) {
|
||||
UiThreadHandler.post {
|
||||
UiThreadHandler.post({
|
||||
if(category == MsgCategory.NOTICE){
|
||||
if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X
|
||||
|| msgBoxList.type == MsgBoxType.OBU){
|
||||
@@ -70,7 +70,7 @@ class PassengerMsgBoxBubbleView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
|
||||
@@ -60,7 +60,7 @@ class PassengerMsgBoxListView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onDataChanged(category: MsgCategory, msgBoxList: MsgBoxBean) {
|
||||
UiThreadHandler.post{
|
||||
UiThreadHandler.post({
|
||||
if(category == MsgCategory.NOTICE){
|
||||
if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X
|
||||
|| msgBoxList.type == MsgBoxType.OBU){
|
||||
@@ -70,7 +70,7 @@ class PassengerMsgBoxListView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
|
||||
@@ -53,6 +53,18 @@ public final class ThreadUtils {
|
||||
|
||||
private static Executor sDeliver;
|
||||
|
||||
public enum MODE {
|
||||
/**
|
||||
* 多次post同一个Runnable对象,只会执行最后一次
|
||||
*/
|
||||
LATEST,
|
||||
|
||||
/**
|
||||
* 多次post,在主线程消息队列中排队执行
|
||||
*/
|
||||
QUEUE
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the thread is the main thread.
|
||||
*
|
||||
@@ -63,23 +75,40 @@ public final class ThreadUtils {
|
||||
}
|
||||
|
||||
public static void runOnUiThread(final Runnable r) {
|
||||
runOnUiThread(r, MODE.LATEST);
|
||||
}
|
||||
|
||||
public static void runOnUiThread(final Runnable r, MODE mode) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
r.run();
|
||||
} else {
|
||||
int what = ObjectHashCodeUtils.getHashCodeIfNeed(r);
|
||||
HANDLER.removeMessages(what);
|
||||
Message msg = Message.obtain(HANDLER, r);
|
||||
msg.what = what;
|
||||
HANDLER.sendMessage(msg);
|
||||
if (mode == MODE.LATEST) {
|
||||
int what = ObjectHashCodeUtils.getHashCodeIfNeed(r);
|
||||
HANDLER.removeMessages(what);
|
||||
Message msg = Message.obtain(HANDLER, r);
|
||||
msg.what = what;
|
||||
HANDLER.sendMessage(msg);
|
||||
} else {
|
||||
HANDLER.post(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void runOnUiThreadDelayed(final Runnable r, long delayMillis) {
|
||||
int what = ObjectHashCodeUtils.getHashCodeIfNeed(r);
|
||||
HANDLER.removeMessages(what);
|
||||
Message msg = Message.obtain(HANDLER, r);
|
||||
msg.what = what;
|
||||
HANDLER.sendMessageDelayed(msg, delayMillis);
|
||||
runOnUiThreadDelayed(r, delayMillis, MODE.LATEST);
|
||||
}
|
||||
|
||||
public static void runOnUiThreadDelayed(final Runnable r, long delayMillis, MODE mode) {
|
||||
if (mode == MODE.LATEST) {
|
||||
int what = ObjectHashCodeUtils.getHashCodeIfNeed(r);
|
||||
HANDLER.removeMessages(what);
|
||||
Message msg = Message.obtain(HANDLER, r);
|
||||
msg.what = what;
|
||||
HANDLER.sendMessageDelayed(msg, delayMillis);
|
||||
} else {
|
||||
HANDLER.postDelayed(r, delayMillis);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,24 +10,58 @@ public class UiThreadHandler {
|
||||
|
||||
private UiThreadHandler() { }
|
||||
|
||||
public enum MODE {
|
||||
/**
|
||||
* 多次post同一个Runnable对象,只会执行最后一次
|
||||
*/
|
||||
LATEST,
|
||||
|
||||
/**
|
||||
* 多次post,在主线程消息队列中排队执行
|
||||
*/
|
||||
QUEUE
|
||||
}
|
||||
|
||||
public static boolean post( Runnable r ) {
|
||||
int what = ObjectHashCodeUtils.getHashCodeIfNeed(r);
|
||||
sUiHandler.removeMessages(what);
|
||||
Message msg = Message.obtain(sUiHandler, r);
|
||||
msg.what = what;
|
||||
return sUiHandler.sendMessage(msg);
|
||||
return post(r, MODE.LATEST);
|
||||
}
|
||||
|
||||
public static boolean post(Runnable r, MODE mode) {
|
||||
if (mode == MODE.LATEST) {
|
||||
int what = ObjectHashCodeUtils.getHashCodeIfNeed(r);
|
||||
sUiHandler.removeMessages(what);
|
||||
Message msg = Message.obtain(sUiHandler, r);
|
||||
msg.what = what;
|
||||
return sUiHandler.sendMessage(msg);
|
||||
}
|
||||
return sUiHandler.post(r);
|
||||
}
|
||||
|
||||
public static boolean postDelayed( Runnable r, long delayMillis ) {
|
||||
int what = ObjectHashCodeUtils.getHashCodeIfNeed(r);
|
||||
sUiHandler.removeMessages(what);
|
||||
Message msg = Message.obtain(sUiHandler, r);
|
||||
msg.what = what;
|
||||
return sUiHandler.sendMessageDelayed(msg, delayMillis);
|
||||
return postDelayed(r, delayMillis, MODE.LATEST);
|
||||
}
|
||||
|
||||
public static boolean postDelayed( Runnable r, long delayMillis, MODE mode ) {
|
||||
if (mode == MODE.LATEST) {
|
||||
int what = ObjectHashCodeUtils.getHashCodeIfNeed(r);
|
||||
sUiHandler.removeMessages(what);
|
||||
Message msg = Message.obtain(sUiHandler, r);
|
||||
msg.what = what;
|
||||
return sUiHandler.sendMessageDelayed(msg, delayMillis);
|
||||
}
|
||||
return sUiHandler.postDelayed(r, delayMillis);
|
||||
}
|
||||
|
||||
public static void removeCallbacks( Runnable r ) {
|
||||
int what = ObjectHashCodeUtils.getHashCodeIfNeed(r);
|
||||
sUiHandler.removeMessages(what);
|
||||
removeCallbacks(r, MODE.LATEST);
|
||||
}
|
||||
|
||||
public static void removeCallbacks( Runnable r, MODE mode ) {
|
||||
if (mode == MODE.LATEST) {
|
||||
int what = ObjectHashCodeUtils.getHashCodeIfNeed(r);
|
||||
sUiHandler.removeMessages(what);
|
||||
} else {
|
||||
sUiHandler.removeCallbacks(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user