ex
Fork of mbed-os-example-mbed5-blinky by
dcs-sdk-java-master/app/src/main/java/com/baidu/duer/dcs/androidapp/DcsSampleScreenHtmlActivity.java@45:2aa9f933c8d2, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:34:48 2017 +0800
- Revision:
- 45:2aa9f933c8d2
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 45:2aa9f933c8d2 | 1 | /* |
| TMBOY | 45:2aa9f933c8d2 | 2 | * Copyright (c) 2017 Baidu, Inc. All Rights Reserved. |
| TMBOY | 45:2aa9f933c8d2 | 3 | * |
| TMBOY | 45:2aa9f933c8d2 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| TMBOY | 45:2aa9f933c8d2 | 5 | * you may not use this file except in compliance with the License. |
| TMBOY | 45:2aa9f933c8d2 | 6 | * You may obtain a copy of the License at |
| TMBOY | 45:2aa9f933c8d2 | 7 | * |
| TMBOY | 45:2aa9f933c8d2 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| TMBOY | 45:2aa9f933c8d2 | 9 | * |
| TMBOY | 45:2aa9f933c8d2 | 10 | * Unless required by applicable law or agreed to in writing, software |
| TMBOY | 45:2aa9f933c8d2 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| TMBOY | 45:2aa9f933c8d2 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| TMBOY | 45:2aa9f933c8d2 | 13 | * See the License for the specific language governing permissions and |
| TMBOY | 45:2aa9f933c8d2 | 14 | * limitations under the License. |
| TMBOY | 45:2aa9f933c8d2 | 15 | */ |
| TMBOY | 45:2aa9f933c8d2 | 16 | package com.baidu.duer.dcs.androidapp; |
| TMBOY | 45:2aa9f933c8d2 | 17 | |
| TMBOY | 45:2aa9f933c8d2 | 18 | import android.graphics.Bitmap; |
| TMBOY | 45:2aa9f933c8d2 | 19 | import android.os.Bundle; |
| TMBOY | 45:2aa9f933c8d2 | 20 | import android.webkit.WebView; |
| TMBOY | 45:2aa9f933c8d2 | 21 | import android.widget.RelativeLayout; |
| TMBOY | 45:2aa9f933c8d2 | 22 | |
| TMBOY | 45:2aa9f933c8d2 | 23 | import com.baidu.duer.dcs.R; |
| TMBOY | 45:2aa9f933c8d2 | 24 | import com.baidu.duer.dcs.androidsystemimpl.webview.BaseWebView; |
| TMBOY | 45:2aa9f933c8d2 | 25 | import com.baidu.duer.dcs.devicemodule.screen.message.HtmlPayload; |
| TMBOY | 45:2aa9f933c8d2 | 26 | |
| TMBOY | 45:2aa9f933c8d2 | 27 | /** |
| TMBOY | 45:2aa9f933c8d2 | 28 | * show html UI. |
| TMBOY | 45:2aa9f933c8d2 | 29 | * <p> |
| TMBOY | 45:2aa9f933c8d2 | 30 | * Created by zhangyan42@baidu.com on 2017/5/31. |
| TMBOY | 45:2aa9f933c8d2 | 31 | */ |
| TMBOY | 45:2aa9f933c8d2 | 32 | public class DcsSampleScreenHtmlActivity extends DcsSampleBaseActivity { |
| TMBOY | 45:2aa9f933c8d2 | 33 | private HtmlPayload htmlPayLoad; |
| TMBOY | 45:2aa9f933c8d2 | 34 | private RelativeLayout relativeLayout; |
| TMBOY | 45:2aa9f933c8d2 | 35 | private BaseWebView webView; |
| TMBOY | 45:2aa9f933c8d2 | 36 | |
| TMBOY | 45:2aa9f933c8d2 | 37 | @Override |
| TMBOY | 45:2aa9f933c8d2 | 38 | protected void onCreate(Bundle savedInstanceState) { |
| TMBOY | 45:2aa9f933c8d2 | 39 | super.onCreate(savedInstanceState); |
| TMBOY | 45:2aa9f933c8d2 | 40 | setContentView(R.layout.dcs_sample_activity_screen_html); |
| TMBOY | 45:2aa9f933c8d2 | 41 | htmlPayLoad = (HtmlPayload) this.getIntent().getSerializableExtra("HTML_PLAY_LOAD"); |
| TMBOY | 45:2aa9f933c8d2 | 42 | initView(); |
| TMBOY | 45:2aa9f933c8d2 | 43 | addView(); |
| TMBOY | 45:2aa9f933c8d2 | 44 | } |
| TMBOY | 45:2aa9f933c8d2 | 45 | |
| TMBOY | 45:2aa9f933c8d2 | 46 | private void initView() { |
| TMBOY | 45:2aa9f933c8d2 | 47 | relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout); |
| TMBOY | 45:2aa9f933c8d2 | 48 | } |
| TMBOY | 45:2aa9f933c8d2 | 49 | |
| TMBOY | 45:2aa9f933c8d2 | 50 | private void addView() { |
| TMBOY | 45:2aa9f933c8d2 | 51 | webView = new BaseWebView(DcsSampleScreenHtmlActivity.this.getApplicationContext()); |
| TMBOY | 45:2aa9f933c8d2 | 52 | webView.setWebViewClientListen(new BaseWebView.WebViewClientListener() { |
| TMBOY | 45:2aa9f933c8d2 | 53 | @Override |
| TMBOY | 45:2aa9f933c8d2 | 54 | public BaseWebView.LoadingWebStatus shouldOverrideUrlLoading(WebView view, String url) { |
| TMBOY | 45:2aa9f933c8d2 | 55 | return BaseWebView.LoadingWebStatus.STATUS_UNKNOW; |
| TMBOY | 45:2aa9f933c8d2 | 56 | } |
| TMBOY | 45:2aa9f933c8d2 | 57 | |
| TMBOY | 45:2aa9f933c8d2 | 58 | @Override |
| TMBOY | 45:2aa9f933c8d2 | 59 | public void onPageStarted(WebView view, String url, Bitmap favicon) { |
| TMBOY | 45:2aa9f933c8d2 | 60 | |
| TMBOY | 45:2aa9f933c8d2 | 61 | } |
| TMBOY | 45:2aa9f933c8d2 | 62 | |
| TMBOY | 45:2aa9f933c8d2 | 63 | @Override |
| TMBOY | 45:2aa9f933c8d2 | 64 | public void onPageFinished(WebView view, String url) { |
| TMBOY | 45:2aa9f933c8d2 | 65 | |
| TMBOY | 45:2aa9f933c8d2 | 66 | } |
| TMBOY | 45:2aa9f933c8d2 | 67 | |
| TMBOY | 45:2aa9f933c8d2 | 68 | @Override |
| TMBOY | 45:2aa9f933c8d2 | 69 | public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { |
| TMBOY | 45:2aa9f933c8d2 | 70 | |
| TMBOY | 45:2aa9f933c8d2 | 71 | } |
| TMBOY | 45:2aa9f933c8d2 | 72 | }); |
| TMBOY | 45:2aa9f933c8d2 | 73 | relativeLayout.addView(webView); |
| TMBOY | 45:2aa9f933c8d2 | 74 | if (null != htmlPayLoad) { |
| TMBOY | 45:2aa9f933c8d2 | 75 | webView.loadUrl(htmlPayLoad.getUrl()); |
| TMBOY | 45:2aa9f933c8d2 | 76 | } |
| TMBOY | 45:2aa9f933c8d2 | 77 | } |
| TMBOY | 45:2aa9f933c8d2 | 78 | } |
