diff --git a/Base.iml b/Base.iml index 8a53fed..2984945 100644 --- a/Base.iml +++ b/Base.iml @@ -33,12 +33,14 @@ + + @@ -81,28 +83,21 @@ - - - - - - + - - diff --git a/README.md b/README.md index 66ab9f7..77f1229 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ Base是针对于Android开发封装好一些常用的基类,主要包括通用的Adapter、Activity、Fragment、Dialog等、和一些常用的Util类,只为更简单。 -##引入 +## 引入 -###Maven: +### Maven: ```maven com.king.base @@ -18,18 +18,18 @@ Base是针对于Android开发封装好一些常用的基类,主要包括通用 pom ``` -###Gradle: +### Gradle: ```gradle compile 'com.king.base:base:2.0' ``` -###Lvy: +### Lvy: ```lvy ``` -###引入的库: +### 引入的库: ```gradle provided 'com.android.support:recyclerview-v7:24.0.+' ``` @@ -42,12 +42,12 @@ compile 'org.greenrobot:eventbus:3.0.0' compile 'com.android.support:appcompat-v7:24.0.+' ``` -##简要说明: +## 简要说明: Base主要实用地方体现在:出统一的代码风格,实用的各种基类,BaseActivity和BaseFragment里面还有许多实用的代码封装,只要用了Base,使用Fragment就感觉跟使用Activtiy基本是一样的。 -##代码示例: +## 代码示例: -###通用的Adapter +### 通用的Adapter ```Java /** * @@ -73,7 +73,7 @@ public class TestAdapter extends ViewHolderAdapter { ``` -###基类BaseActivity +### 基类BaseActivity ```Java public class TestActivity extends BaseActivity { @@ -105,7 +105,7 @@ public class TestActivity extends BaseActivity { } } ``` -###GestureActivity +### GestureActivity ```Java public class TestGestureActivity extends GestureActivity { @@ -148,7 +148,7 @@ public class TestGestureActivity extends GestureActivity { } } ``` -###SplashActivity +### SplashActivity ```Java public class TestSplashActivity extends SplashActivity { @Override @@ -178,7 +178,7 @@ public class TestSplashActivity extends SplashActivity { } ``` -###BaseFragment +### BaseFragment ```Java public class TestFragment extends BaseFragment { @Override @@ -207,7 +207,7 @@ public class TestFragment extends BaseFragment { } } ``` -###BaseDialogFragment +### BaseDialogFragment ```Java public class TestDialogFragment extends BaseDialogFragment { @Override @@ -237,11 +237,11 @@ public class TestDialogFragment extends BaseDialogFragment { } ``` -###WebFragment +### WebFragment ```Java WebFragment实现基本webView功能 ``` -###其他小功能 +### 其他小功能 使用Log: 统一控制管理Log @@ -298,6 +298,18 @@ public class TestDialogFragment extends BaseDialogFragment { 更多实用黑科技,请速速使用Base体会吧。 +## 关于我 + Name: Jenly + + Email: jenly1314@gmail.com / jenly1314@vip.qq.com + + CSDN: http://www.csdn.net/jenly121 + + Github: https://github.com/jenly1314 + + 微信公众号: + + ![公众号](http://olambmg9j.bkt.clouddn.com/jenly666.jpg) ## License diff --git a/build.gradle b/build.gradle index f5e8fa2..e2b9e9b 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ publish { userOrg = 'jenly'//bintray.com用户名 groupId = 'com.king.base'//jcenter上的路径 artifactId = 'base'//项目名称 - publishVersion = '2.0'//版本号 + publishVersion = '2.0.1'//版本号 desc = 'Base for Android'//描述 website = 'https://github.com/jenly1314/Base'//网站 } diff --git a/src/main/java/com/king/base/fragment/WebFragment.java b/src/main/java/com/king/base/fragment/WebFragment.java index db0cb93..9490203 100644 --- a/src/main/java/com/king/base/fragment/WebFragment.java +++ b/src/main/java/com/king/base/fragment/WebFragment.java @@ -26,7 +26,7 @@ /** * @author Jenly Jenly */ -public class WebFragment extends BaseFragment{ +public class WebFragment extends BaseFragment{ public static final int OPR_WEBVIEW_BACK = 0x01; @@ -42,16 +42,16 @@ public class WebFragment extends BaseFragment{ private boolean isShowError; - public static WebFragment newInstance(String url) { + public static WebFragment newInstance() { Bundle args = new Bundle(); - args.putString(KEY_URL,url); + WebFragment fragment = new WebFragment(); - fragment.url = url; fragment.setArguments(args); return fragment; } + @Override public int inflaterRootView() { return R.layout.fragment_web; @@ -74,23 +74,7 @@ public void initUI() { @Override public void addListeners() { - rootView.setOnKeyListener(new View.OnKeyListener() { - @Override - public boolean onKey(View view, int i, KeyEvent keyEvent) { - - if(keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK){ - if(isGoBack()){ - webView.goBack(); - }else{ - finish(); - } - return true; - } - - return false; - } - }); } @Override @@ -98,15 +82,10 @@ public void initData() { WebSettings ws = webView.getSettings(); //是否允许脚本支持 ws.setJavaScriptEnabled(true); - + ws.setDomStorageEnabled(true); ws.setJavaScriptCanOpenWindowsAutomatically(true); - ws.setSaveFormData(false); -// ws.setAppCacheEnabled(false); - ws.setCacheMode(WebSettings.LOAD_NO_CACHE); - - webView.setHorizontalScrollBarEnabled(false); // webView.addJavascriptInterface(new WebJavascriptInterface(),"android"); @@ -128,6 +107,9 @@ public void onProgressChanged(WebView view, int newProgress) { load(webView,url); } + public WebView getWebView(){ + return webView; + } public WebViewClient getWebViewClient(){ return new WebViewClient(){ @@ -136,6 +118,7 @@ public WebViewClient getWebViewClient(){ public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); LogUtils.d("startUrl:" + url); + webView.setVisibility(View.VISIBLE); isError = false; } @@ -183,10 +166,9 @@ public void onPageFinished(WebView view, String url) { * @param group * @return true表示已添加ErrorView并显示ErrorView/false表示不处理 */ - public boolean addErrorView(ViewGroup group){ - + public boolean addErrorView(ViewGroup group){ return false; - } + }; private void showReceiveError(){ isError = true; @@ -198,6 +180,7 @@ private void showReceiveError(){ if(isShowError){ vError.setVisibility(View.VISIBLE); + webView.setVisibility(View.GONE); } @@ -207,6 +190,7 @@ private void hideReceiveError(){ if(isError){ showReceiveError(); }else{ + webView.setVisibility(View.VISIBLE); vError.setVisibility(View.GONE); } @@ -244,19 +228,7 @@ private void updateProgressBar(boolean isVisibility,int progress){ @Override public void onEventMessage(EventMessage em) { - if(isStop){ - return; - } - switch (em.what){ - case OPR_WEBVIEW_BACK: - if(isGoBack()){ - webView.goBack(); - }else{ - finish(); - } - break; - } } }