-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
191 additions
and
41 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,94 @@ | ||
package com.hjq.logcat.demo; | ||
|
||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.webkit.WebChromeClient; | ||
import android.webkit.WebView; | ||
import android.webkit.WebViewClient; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
import com.hjq.bar.OnTitleBarListener; | ||
import com.hjq.bar.TitleBar; | ||
|
||
public class MainActivity extends AppCompatActivity implements OnTitleBarListener { | ||
|
||
private TitleBar mTitleBar; | ||
private WebView mWebView; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
mTitleBar = findViewById(R.id.tb_main_title); | ||
mTitleBar.setOnTitleBarListener(this); | ||
|
||
mWebView = findViewById(R.id.wv_main_web); | ||
mWebView.setWebViewClient(new WebViewClient()); | ||
mWebView.setWebChromeClient(new MyWebChromeClient()); | ||
mWebView.loadUrl("https://github.com/getActivity/Logcat"); | ||
} | ||
|
||
private class MyWebChromeClient extends WebChromeClient { | ||
|
||
@Override | ||
public void onReceivedTitle(WebView view, String title) { | ||
mTitleBar.setTitle(title); | ||
} | ||
} | ||
|
||
@Override | ||
public void onLeftClick(View v) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTitleClick(View v) { | ||
String url = mWebView.getUrl(); | ||
if (url != null && !"".equals(url)) { | ||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
startActivity(intent); | ||
} | ||
} | ||
|
||
@Override | ||
public void onRightClick(View v) { | ||
|
||
} | ||
|
||
@Override | ||
public void onResume() { | ||
mWebView.onResume(); | ||
mWebView.resumeTimers(); | ||
super.onResume(); | ||
} | ||
|
||
@Override | ||
public void onPause() { | ||
mWebView.onPause(); | ||
mWebView.pauseTimers(); | ||
super.onPause(); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
((ViewGroup) mWebView.getParent()).removeView(mWebView); | ||
//清除历史记录 | ||
mWebView.clearHistory(); | ||
//停止加载 | ||
mWebView.stopLoading(); | ||
//加载一个空白页 | ||
mWebView.loadUrl("about:blank"); | ||
mWebView.setWebChromeClient(null); | ||
mWebView.setWebViewClient(null); | ||
//移除WebView所有的View对象 | ||
mWebView.removeAllViews(); | ||
//销毁此的WebView的内部状态 | ||
mWebView.destroy(); | ||
super.onDestroy(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="200dp" | ||
android:height="200dp" | ||
android:viewportWidth="1024" | ||
android:viewportHeight="1024"> | ||
|
||
<path | ||
android:fillColor="#AED796" | ||
android:pathData="M112 16h736v992H112z" /> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M320 640h320v256H320z" /> | ||
<path | ||
android:fillColor="#F48284" | ||
android:pathData="M320 544h320v96H320z" /> | ||
<path | ||
android:fillColor="#2B3139" | ||
android:pathData="M896 128h-32V32a32 32 0 0 0-32-32H128a32 32 0 0 0-32 32v960a32 32 0 0 0 32 | ||
32h704a32 32 0 0 0 32-32V416h32a32 32 0 0 0 32-32V160a32 32 0 0 0-32-32z m-64 | ||
0H448a32 32 0 0 0-32 32v224a32 32 0 0 0 32 32h384v576H128V32h704v96zM560 | ||
720H400a16 16 0 1 0 0 32h160a16 16 0 1 0 0-32zM336 912h288a32 32 0 0 0 | ||
32-32V560a32 32 0 0 0-32-32h-32v-16a16 16 0 1 0-32 0v16h-32v-16a16 16 0 1 0-32 | ||
0v16h-32v-16a16 16 0 1 0-32 0v16h-32v-16a16 16 0 1 0-32 0v16h-32a32 32 0 0 0-32 | ||
32v320a32 32 0 0 0 32 32z m0-352h32v16a16 16 0 1 0 32 0v-16h32v16a16 16 0 1 0 32 | ||
0v-16h32v16a16 16 0 1 0 32 0v-16h32v16a16 16 0 1 0 32 0v-16h32v64H336v-64z m0 | ||
96h288v224H336V656z m224 128H400a16 16 0 1 0 0 32h160a16 16 0 1 0 0-32z" /> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M448 160h448v224H448z" /> | ||
<path | ||
android:fillColor="#2B3139" | ||
android:pathData="M499.472 213.824h35.184v84.912h50.528V328h-85.712v-114.176zM654.8 211.104c34.704 | ||
0 57.888 24.944 57.888 59.792s-23.184 59.808-57.888 | ||
59.808-57.888-24.96-57.888-59.808 23.184-59.792 57.888-59.792z m0 91.152c8.96 0 | ||
22.704-5.904 22.704-31.344 0-25.424-13.744-31.344-22.704-31.344s-22.704 | ||
5.92-22.704 31.344 13.744 31.344 22.704 31.344zM811.264 316.336c-7.84 10.08-20 | ||
14.384-32.464 14.384-33.728 0-54.528-26.224-54.528-58.688 0-43.504 30.544-60.928 | ||
56.304-60.928 29.088 0 47.488 15.824 52.608 | ||
42.688h-33.744c-1.28-8.32-8.32-14.24-16.624-14.24-24.16 0-23.344 25.44-23.344 | ||
33.264 0 10.72 4.32 29.424 25.728 29.424 8.16 0 16.48-4.16 | ||
18.24-12.624h-15.52v-24.464h46.704V328h-22.24l-1.12-11.664z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<WebView xmlns:android="http://schemas.android.com/apk/res/android" | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/wv_main_web" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_gravity="center" | ||
android:orientation="vertical" | ||
tools:context=".MainActivity" /> | ||
android:orientation="vertical"> | ||
|
||
<com.hjq.bar.TitleBar | ||
android:id="@+id/tb_main_title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:backButton="false" | ||
app:title="Logcat" /> | ||
|
||
<WebView | ||
android:id="@+id/wv_main_web" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_gravity="center" | ||
android:orientation="vertical" | ||
tools:context=".MainActivity" /> | ||
|
||
</LinearLayout> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.