package com.dayu.pipirrapp.js;
|
|
import android.os.Handler;
|
import android.os.Looper;
|
import android.webkit.JavascriptInterface;
|
|
import com.dayu.pipirrapp.fragment.MapFragment;
|
import com.dayu.pipirrapp.utils.ToastUtil;
|
|
/**
|
* author: zuo
|
* Date: 2024-01-18
|
* Time: 9:14
|
* 备注:供Vue调用原生
|
*/
|
public class MyWebViewInterface {
|
|
private MapFragment myContext;
|
|
|
public MyWebViewInterface(MapFragment context) {
|
myContext = context;
|
}
|
|
@JavascriptInterface
|
public void showToast(String msg) {
|
ToastUtil.showToastLong(myContext.getContext(), msg);
|
}
|
|
/**
|
* 显示取水口详情
|
*
|
* @param data
|
*/
|
@JavascriptInterface
|
public void showWaterIntakeView(String data) {
|
if (myContext instanceof MapFragment) {
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
@Override
|
public void run() {
|
// 在主线程上执行UI操作
|
// 更新或操作UI元素的代码
|
myContext.showWaterIntakeDetail(data);
|
}
|
});
|
|
}
|
}
|
|
/**
|
* 隐藏取水口详情
|
*/
|
@JavascriptInterface
|
public void closeWaterIntakeView() {
|
if (myContext instanceof MapFragment) {
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
@Override
|
public void run() {
|
// 在主线程上执行UI操作
|
// 更新或操作UI元素的代码
|
myContext.closeWaterIntakeDetail();
|
}
|
});
|
// myContext.closeWaterIntakeDetail();
|
}
|
}
|
|
@JavascriptInterface
|
public void loadMarker() {
|
if (myContext instanceof MapFragment) {
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
@Override
|
public void run() {
|
// 在主线程上执行UI操作
|
// 更新或操作UI元素的代码
|
// myContext.addMarker();
|
myContext.jumpCenterPoint();
|
myContext.setMapMarker();
|
}
|
});
|
}
|
}
|
|
|
}
|