管灌系统巡查员智能手机App
zuoxiao
2024-10-16 bc0643f42cc19cfa1153f355851968e5486281ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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();
                }
            });
        }
    }
 
 
}