Skip to content

Commit 674c6af

Browse files
author
admin_dell
committed
fix first screen
1 parent 2710260 commit 674c6af

File tree

9 files changed

+101
-117
lines changed

9 files changed

+101
-117
lines changed

tbs_app/APPApplication.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,19 @@ public override void OnCreate()
2525

2626
utils.LoggerManager.Configure();
2727

28-
29-
utils.LoggerManager.CurrentLogger.Debug("Application OnCreate");
30-
3128
AndroidEnvironment.UnhandledExceptionRaiser += AppUnhandledExceptionRaiser;
3229
CrashExceptionHandler.Instance.Init(this);
3330

3431
QbSdk.IPreInitCallback cb = new CusPreInitCallback();
3532
//x5内核初始化接口
3633
QbSdk.InitX5Environment(ApplicationContext, cb);
37-
34+
QbSdk.SetTbsListener(new TbsListener());
3835
}
3936

4037

4138
private void AppUnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
4239
{
40+
utils.LoggerManager.CurrentLogger.Error(e.Exception, "UncaughtException");
4341

4442
System.Threading.Tasks.Task.Run(() =>
4543
{
@@ -75,12 +73,13 @@ public void OnCoreInitFinished()
7573
public void OnViewInitFinished(bool arg0)
7674
{
7775
// TODO Auto-generated method stub
78-
//x5內核初始化完成的回调,为true表示x5内核加载成功,否则表示x5内核加载失败,会自动切换到系统内核。
79-
Android.Util.Log.Debug("app", " onViewInitFinished is " + arg0);
76+
//x5內核初始化完成的回调,为true表示x5内核加载成功,否则表示x5内核加载失败,会自动切换到系统内核
77+
78+
utils.LoggerManager.CurrentLogger.Debug("ViewInitFinished is x5内核是否加载成功? " + arg0);
8079
}
8180
}
8281

83-
public class CrashExceptionHandler : Java.Lang.Object, Java.Lang.Thread.IUncaughtExceptionHandler
82+
internal class CrashExceptionHandler : Java.Lang.Object, Java.Lang.Thread.IUncaughtExceptionHandler
8483
{
8584
//系统默认的UncaughtException处理类
8685
private Java.Lang.Thread.IUncaughtExceptionHandler mDefaultHandler;
@@ -96,6 +95,7 @@ private CrashExceptionHandler()
9695

9796
public void UncaughtException(Java.Lang.Thread t, Java.Lang.Throwable e)
9897
{
98+
utils.LoggerManager.CurrentLogger.Error("UncaughtException", e);
9999
if (!HandleException(e) && mDefaultHandler != null)
100100
{
101101
mDefaultHandler.UncaughtException(t, e);
@@ -139,4 +139,22 @@ public void Init(Context ctx)
139139
}
140140
}
141141

142+
internal class TbsListener : Java.Lang.Object, ITbsListener
143+
{
144+
public void OnDownloadFinish(int p0)
145+
{
146+
utils.LoggerManager.CurrentLogger.Debug($"TbsListener OnDownloadFinish args:{p0}");
147+
}
148+
149+
public void OnDownloadProgress(int p0)
150+
{
151+
utils.LoggerManager.CurrentLogger.Debug($"TbsListener OnDownloadProgress args:{p0}");
152+
}
153+
154+
public void OnInstallFinish(int p0)
155+
{
156+
utils.LoggerManager.CurrentLogger.Debug($"TbsListener OnInstallFinish args:{p0}");
157+
}
158+
}
159+
142160
}

tbs_app/Activity/BrowserActivity.cs

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class BrowserActivity : Activity
3737
private EditText mUrl;
3838

3939
private static readonly string mHomeUrl = "http://app.html5.qq.com/navi/index";
40-
private static readonly string TAG = "SdkDemo";
40+
//private static readonly string TAG = "SdkDemo";
4141
private static readonly int MAX_LENGTH = 14;
4242
private static bool mNeedTestPage = false;
4343

@@ -54,6 +54,8 @@ protected override void OnCreate(Bundle savedInstanceState)
5454
{
5555
base.OnCreate(savedInstanceState);
5656

57+
utils.LoggerManager.CurrentLogger.Debug("BrowserActivity OnCreate");
58+
5759
currentActivity = this;
5860

5961
Window.SetFormat(Android.Graphics.Format.Translucent);
@@ -147,7 +149,7 @@ private void InitBtnListenser()
147149
}));
148150
}
149151

150-
bool[] m_selected = new bool[] { true, true, true, true, false, false, true };
152+
//bool[] m_selected = new bool[] { true, true, true, true, false, false, true };
151153
public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
152154
{
153155
if (keyCode == Keycode.Back)
@@ -192,8 +194,7 @@ private static void ChangGoForwardButton(WebView view)
192194

193195
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
194196
{
195-
196-
TbsLog.D(TAG, "onActivityResult, requestCode:" + requestCode + ",resultCode:" + resultCode);
197+
utils.LoggerManager.CurrentLogger.Debug("onActivityResult, requestCode:" + requestCode + ",resultCode:" + resultCode);
197198

198199
if (resultCode == Android.App.Result.Ok)
199200
{
@@ -265,42 +266,23 @@ internal CusHandler(X5WebView view)
265266

266267
public override void HandleMessage(Message msg)
267268
{
268-
269-
switch (msg.What)
270-
{
271-
case MSG_OPEN_TEST_URL:
272-
if (!mNeedTestPage)
273-
{
274-
return;
275-
}
276-
277-
string testUrl = "file:///sdcard/outputHtml/html/" + mCurrentUrl + ".html";
278-
if (webview != null)
279-
{
280-
webview.LoadUrl(testUrl);
281-
}
282-
283-
mCurrentUrl++;
284-
break;
285-
case MSG_INIT_UI:
286-
Init();
287-
break;
288-
}
289269
switch (msg.What)
290270
{
291271
case MSG_OPEN_TEST_URL:
292-
if (!mNeedTestPage)
293272
{
294-
return;
273+
if (!mNeedTestPage)
274+
{
275+
return;
276+
}
277+
278+
string testUrl = "file:///sdcard/outputHtml/html/" + mCurrentUrl + ".html";
279+
if (webview != null)
280+
{
281+
webview.LoadUrl(testUrl);
282+
}
283+
284+
mCurrentUrl++;
295285
}
296-
297-
string testUrl = "file:///sdcard/outputHtml/html/" + mCurrentUrl + ".html";
298-
if (webview != null)
299-
{
300-
webview.LoadUrl(testUrl);
301-
}
302-
303-
mCurrentUrl++;
304286
break;
305287
case MSG_INIT_UI:
306288
Init();
@@ -310,7 +292,6 @@ public override void HandleMessage(Message msg)
310292
base.HandleMessage(msg);
311293
}
312294

313-
314295
}
315296

316297
private static void Init()
@@ -491,7 +472,7 @@ public CusDownloadListener(Activity activity)
491472

492473
public void OnDownloadStart(string p0, string p1, string p2, string p3, long p4)
493474
{
494-
TbsLog.D(TAG, "url: " + p0);
475+
utils.LoggerManager.CurrentLogger.Debug($"OnDownloadStart url:{p0}");
495476

496477
new AlertDialog.Builder(currentActivity)
497478
.SetTitle("allow to download?")

tbs_app/Activity/FullScreenActivity.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@ namespace tbs_app
1717
[Activity(Label = "FullScreenActivity")]
1818
public class FullScreenActivity : Activity
1919
{
20-
private static X5WebView webView;
20+
private X5WebView webView;
2121

2222
protected override void OnCreate(Bundle savedInstanceState)
2323
{
2424
base.OnCreate(savedInstanceState);
2525

26+
utils.LoggerManager.CurrentLogger.Debug("FullScreenActivity OnCreate");
27+
2628
SetContentView(Resource.Layout.filechooser_layout);
2729
webView = FindViewById<X5WebView>(Resource.Id.web_filechooser);
2830
webView.LoadUrl("file:///android_asset/webpage/fullscreenVideo.html");
2931

3032
Window.SetFormat(Android.Graphics.Format.Translucent);
3133

3234
webView.View.OverScrollMode = OverScrollMode.Always;
33-
webView.AddJavascriptInterface(new CusWebViewJavaScriptFunction(this), "Android");
35+
webView.AddJavascriptInterface(new CusWebViewJavaScriptFunction(this, webView), "Android");
3436
}
3537

3638
protected override void OnDestroy()
@@ -70,10 +72,12 @@ public override void OnConfigurationChanged(Configuration newConfig)
7072
internal class CusWebViewJavaScriptFunction : Java.Lang.Object, IWebViewJavaScriptFunction
7173
{
7274
private readonly Activity currentActivity;
75+
private readonly X5WebView webView;
7376

74-
internal CusWebViewJavaScriptFunction(Activity activity)
77+
internal CusWebViewJavaScriptFunction(Activity activity, X5WebView view)
7578
{
7679
currentActivity = activity;
80+
webView = view;
7781
}
7882

7983

@@ -84,25 +88,25 @@ public void OnJsFunctionCalled(string tag)
8488

8589

8690
[Android.Webkit.JavascriptInterface]
87-
public void onX5ButtonClicked()
91+
public void OnX5ButtonClicked()
8892
{
8993
EnableX5FullscreenFunc();
9094
}
9195

9296
[Android.Webkit.JavascriptInterface]
93-
public void onCustomButtonClicked()
97+
public void OnCustomButtonClicked()
9498
{
9599
DisableX5FullscreenFunc();
96100
}
97101

98102
[Android.Webkit.JavascriptInterface]
99-
public void onLiteWndButtonClicked()
103+
public void OnLiteWndButtonClicked()
100104
{
101105
EnableLiteWndFunc();
102106
}
103107

104108
[Android.Webkit.JavascriptInterface]
105-
public void onPageVideoClicked()
109+
public void OnPageVideoClicked()
106110
{
107111
EnablePageVideoFunc();
108112
}

tbs_app/Assets/webpage/fullscreenVideo.html

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<!DOCTYPE html>
1+
<!DOCTYPE html>
22
<html>
33
<head lang="en">
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, maximum-scale=1, minimum-scale=1, user-scale=1">
66
<title></title>
77
<style type="text/css" rel="stylesheet">
8-
.line{
9-
width:100%;
8+
.line {
9+
width: 100%;
1010
background: #000000;
1111
height: 1px;
1212
margin-top: 5px;
@@ -15,37 +15,37 @@
1515
</style>
1616
</head>
1717
<body>
18-
<video style="width:100%; height: auto;" controls>
19-
<source src=http://125.64.133.74/data9/userfiles/video02/2014/12/11/2796948-280-068-1452.mp4 >
20-
</video>
21-
<div style="width:100%;height: 25px;"></div>
22-
<button onclick="click_x5()" style="width:50%;height: 50px; float: left"> x5模式全屏</button>
23-
<button onclick="click_normal()" style="width:50%;height: 50px;"> 普通模式全屏</button>
24-
<div class="line"></div>
25-
<button onclick="click_LiteWnd()" style="width:50%;height: 50px; float: left"> 小窗模式</button>
26-
<button onclick="click_normal()" style="width:50%;height: 50px;"> 关闭小窗模式</button>
27-
<div class="line"></div>
28-
<button onclick="click_PageVideo()" style="width:50%;height: 50px; float: left"> 页面内全屏</button>
29-
<button onclick="click_normal()" style="width:50%;height: 50px;"> 关闭页面内全屏</button>
18+
<video style="width:100%; height: auto;" controls>
19+
<source src="http://vd3.bdstatic.com/mda-ia8vb7keat7sn694/mda-ia8vb7keat7sn694.mp4">
20+
</video>
21+
<div style="width:100%;height: 25px;"></div>
22+
<button onclick="click_x5()" style="width:50%;height: 50px; float: left"> x5模式全屏</button>
23+
<button onclick="click_normal()" style="width:50%;height: 50px;"> 普通模式全屏</button>
24+
<div class="line"></div>
25+
<button onclick="click_LiteWnd()" style="width:50%;height: 50px; float: left"> 小窗模式</button>
26+
<button onclick="click_normal()" style="width:50%;height: 50px;"> 关闭小窗模式</button>
27+
<div class="line"></div>
28+
<button onclick="click_PageVideo()" style="width:50%;height: 50px; float: left"> 页面内全屏</button>
29+
<button onclick="click_normal()" style="width:50%;height: 50px;"> 关闭页面内全屏</button>
3030
</body>
3131

32-
33-
<script type="text/javascript" >
34-
function click_x5 (){
35-
Android.onX5ButtonClicked();
32+
<script type="text/javascript">
33+
function click_x5() {
34+
alert(Android)
35+
alert(JSON.stringify(Android))
36+
Android.OnX5ButtonClicked();
3637
location.reload(false);
37-
3838
}
39-
function click_normal(){
40-
Android.onCustomButtonClicked();
39+
function click_normal() {
40+
Android.OnCustomButtonClicked();
4141
location.reload(false);
4242
}
43-
function click_LiteWnd(){
44-
Android.onLiteWndButtonClicked();
43+
function click_LiteWnd() {
44+
Android.OnLiteWndButtonClicked();
4545
location.reload(false);
4646
}
47-
function click_PageVideo(){
48-
Android.onPageVideoClicked();
47+
function click_PageVideo() {
48+
Android.OnPageVideoClicked();
4949
location.reload(false);
5050
}
5151
</script>

0 commit comments

Comments
 (0)