|
@ -0,0 +1,78 @@
|
|
1
|
package com.wade.mobile.func;
|
|
2
|
|
|
3
|
import java.util.Map;
|
|
4
|
|
|
5
|
import android.view.KeyEvent;
|
|
6
|
import android.webkit.WebView;
|
|
7
|
import android.widget.LinearLayout;
|
|
8
|
|
|
9
|
import com.ai.ipu.mobile.util.IpuMobileUtility;
|
|
10
|
import com.ailk.common.data.impl.DataMap;
|
|
11
|
import com.wade.mobile.frame.IWadeMobile;
|
|
12
|
import com.wade.mobile.frame.activity.WadeMobileActivity;
|
|
13
|
import com.wade.mobile.frame.client.WadeWebViewClient;
|
|
14
|
import com.wade.mobile.frame.config.ServerPageConfig;
|
|
15
|
import com.wade.mobile.frame.event.impl.TemplateWebViewEvent;
|
|
16
|
import com.wade.mobile.frame.template.TemplateWebView;
|
|
17
|
import com.wade.mobile.ui.anim.AnimationResource;
|
|
18
|
import com.wade.mobile.ui.view.FlipperLayout;
|
|
19
|
import com.wade.mobile.util.Messages;
|
|
20
|
|
|
21
|
/**
|
|
22
|
* IpuWindowWebView用于替换CustomWindowActivity,保留openWindow和closeWindow的API使用
|
|
23
|
*/
|
|
24
|
public class IpuWindowWebView extends TemplateWebView {
|
|
25
|
|
|
26
|
public IpuWindowWebView(IWadeMobile wademobile) {
|
|
27
|
super(wademobile);
|
|
28
|
}
|
|
29
|
|
|
30
|
@Override
|
|
31
|
protected void initialize() {
|
|
32
|
setWebViewClient(new WadeWebViewClient(wademobile,
|
|
33
|
new TemplateWebViewEvent(wademobile) {
|
|
34
|
@Override
|
|
35
|
public void loadingFinished(WebView view, String url) {
|
|
36
|
wademobile.getFlipperLayout().showNextView();
|
|
37
|
}
|
|
38
|
}));
|
|
39
|
clearCache(true);
|
|
40
|
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
|
41
|
((WadeMobileActivity) wademobile).getWebviewSetting().setWebViewStyle(this);
|
|
42
|
}
|
|
43
|
|
|
44
|
public void openWindow(String pageAction, String data) throws Exception {
|
|
45
|
/* 获取模板相对路径 */
|
|
46
|
final String templatePath = ServerPageConfig.getTemplate(pageAction);
|
|
47
|
if (templatePath == null || "".equals(templatePath)) {
|
|
48
|
IpuMobileUtility.error(Messages.NO_TEMPLATE + ",Action:" + pageAction);
|
|
49
|
}
|
|
50
|
|
|
51
|
Map<?, ?> dataMap = null;
|
|
52
|
if(data != null) {
|
|
53
|
dataMap = new DataMap(data.replaceAll("\"null\"", "\"\"").replaceAll("null", "\"\""));
|
|
54
|
}
|
|
55
|
FlipperLayout flipperLayout = wademobile.getFlipperLayout();
|
|
56
|
flipperLayout.setAnimation(AnimationResource.pushLeft[0],
|
|
57
|
AnimationResource.pushLeft[1]);
|
|
58
|
flipperLayout.setBackAnimation(AnimationResource.pushRight[0],
|
|
59
|
AnimationResource.pushRight[1]);
|
|
60
|
flipperLayout.addNextView(this);// 增加view
|
|
61
|
flipperLayout.setPreCurrView(this);
|
|
62
|
loadTemplate(templatePath, dataMap);
|
|
63
|
|
|
64
|
}
|
|
65
|
|
|
66
|
public void closeWindow(String resultData) {
|
|
67
|
wademobile.getFlipperLayout().back();
|
|
68
|
}
|
|
69
|
|
|
70
|
@Override
|
|
71
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
72
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
73
|
closeWindow(null);
|
|
74
|
return true;
|
|
75
|
}
|
|
76
|
return super.onKeyDown(keyCode, event);
|
|
77
|
}
|
|
78
|
}
|