Skip to content

Commit

Permalink
SDCardUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
SiberiaDante committed Sep 14, 2017
1 parent 57e433f commit 5048ba4
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 2 deletions.
1 change: 1 addition & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ dependencies {
compile 'com.github.clans:fab:1.6.0'
testCompile 'junit:junit:4.12'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
compile 'com.just.agentweb:agentweb:2.0.1'
}
7 changes: 6 additions & 1 deletion sample/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@
# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
<init>(java.lang.Throwable);
}
}
#agentWeb
-keep class com.just.library.** {
*;
}
-dontwarn com.just.library.**
3 changes: 2 additions & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
<activity
android:name=".ui.activity.view.KeyBoardActivity"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".ui.activity.util.SDCardUtilActivity"></activity>
<activity android:name=".ui.activity.util.SDCardUtilActivity" />
<activity android:name=".ui.activity.WebActivity"></activity>
</application>

</manifest>
74 changes: 74 additions & 0 deletions sample/src/main/java/com/sample/ui/activity/WebActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.sample.ui.activity;

import android.content.Intent;
import android.net.http.SslError;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.RelativeLayout;

import com.just.library.AgentWeb;
import com.sample.R;
import com.siberiadante.lib.util.LogUtil;

public class WebActivity extends BaseActivity {

private RelativeLayout mRLLayout;
private String url;
private String title;
private AgentWeb mAgentWeb;
private WebViewClient mWebViewClient = new WebViewClient() {
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
super.onReceivedSslError(view, handler, error);
LogUtil.e("----error----" + error);
handler.proceed();
}

@Override
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
super.onReceivedHttpError(view, request, errorResponse);
}

@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
super.onReceivedError(view, request, error);
LogUtil.e("----error----" + error);
}
};

private WebChromeClient mWebChromeClient=new WebChromeClient(){
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
mRLLayout = (RelativeLayout) findViewById(R.id.activity_web);
initIntent();
initWebView();
}

private void initIntent() {
final Intent intent = getIntent();
url = intent.getStringExtra("url");
title = intent.getStringExtra("title");
}

private void initWebView() {
mAgentWeb = AgentWeb.with(this)//传入Activity or Fragment
.setAgentWebParent(mRLLayout, new RelativeLayout.LayoutParams(-1, -1))//传入AgentWeb 的父控件 ,如果父控件为 RelativeLayout , 那么第二参数需要传入 RelativeLayout.LayoutParams ,第一个参数和第二个参数应该对应。
.useDefaultIndicator()// 使用默认进度条
.defaultProgressBarColor() // 使用默认进度条颜色
.setWebViewClient(mWebViewClient)
.setSecutityType(AgentWeb.SecurityType.strict)
.createAgentWeb()//
.ready()
.go("http://www.chinichi.cn/activity/index/app_detail.html?id=5");
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.sample.ui.activity;

import android.content.Intent;
import android.net.http.SslError;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.SslErrorHandler;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
Expand Down Expand Up @@ -32,6 +34,7 @@ private void initIntent() {
final Intent intent = getIntent();
url = intent.getStringExtra("url");
title = intent.getStringExtra("title");
url="http://www.chinichi.cn/activity/index/app_detail.html?id=5";
}

private void initView() {
Expand All @@ -47,6 +50,12 @@ private void setWebView() {
settings.setJavaScriptEnabled(true);
mWebView.loadUrl(url);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
super.onReceivedSslError(view, handler, error);
handler.proceed();
}

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
mWebView.loadUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.sample.R;
import com.sample.constants.Constants;
import com.sample.ui.BaseFragment;
import com.sample.ui.activity.WebActivity;
import com.sample.ui.activity.WebViewActivity;
import com.siberiadante.lib.util.ScreenUtil;
import com.siberiadante.lib.view.TitleBar;
Expand Down
9 changes: 9 additions & 0 deletions sample/src/main/res/layout/activity_web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_web"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.sample.ui.activity.WebActivity">

</RelativeLayout>

0 comments on commit 5048ba4

Please sign in to comment.