- * 2、当然,你也可以配置webView所在Activity,
- * 在AndroidManifest中的进程为:android:process=":remote"
- * 避免泄漏影响主进程
- **/
- void addWebViewToLayout() {
- mRootLayout = (FrameLayout) findViewById(R.id.js_root_layout);
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
- mWebView = new WebView(getApplicationContext());
- mWebView.setLayoutParams(params);
- mRootLayout.addView(mWebView);
- }
-
-
- /**
- * 配置webView
- */
- void setWebView() {
- //声明WebSettings子类
- WebSettings webSettings = mWebView.getSettings();
-
- //支持Javascript交互
- webSettings.setJavaScriptEnabled(true);
-
-
- //设置自适应屏幕,两者合用
- webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
- webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
-
- //缩放操作
- webSettings.setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。
- webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放
- webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件
-
- //其他细节操作
- //webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存
- webSettings.setAllowFileAccess(true); //设置可以访问文件
-
- //对于不需要使用 file 协议的应用,禁用 file 协议;防止文件泄密,file协议即是file://
- //webSettings.setAllowFileAccess(false);
- //webSettings.setAllowFileAccessFromFileURLs(false);
- //webSettings.setAllowUniversalAccessFromFileURLs(false);
-
-
-
- webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
- webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片
- webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式
-
- mWebView.setDownloadListener(new DownloadListener() {
- @Override
- public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
- //网页中触发下载动作
- }
- });
-
- //增加js交互接口
- mWebView.addJavascriptInterface(new JsCallAndroidInterface(), "JSCallBackInterface");
- }
-
- /**
- * 设置webView的Client,如页面加载开始,错误,拦截请求,接受Error等
- */
- void setWebClient() {
- mWebView.setWebViewClient(new WebViewClient() {
-
- //拦截页面中的url加载,21以下的
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- if (resolveShouldLoadLogic(url)) {
- return true;
- }
- return super.shouldOverrideUrlLoading(view, url);
- }
-
- //拦截页面中的url加载,21以上的
- @TargetApi(21)
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
- if (resolveShouldLoadLogic(request.getUrl().toString())) {
- return true;
- }
- return super.shouldOverrideUrlLoading(view, request);
- }
-
- //页面开始加载
- @Override
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- super.onPageStarted(view, url, favicon);
- }
-
- //页面加载完成
- @Override
- public void onPageFinished(WebView view, String url) {
- super.onPageFinished(view, url);
- }
-
- //页面加载每一个资源,如图片
- @Override
- public void onLoadResource(WebView view, String url) {
- super.onLoadResource(view, url);
- }
-
- //监听WebView发出的请求并做相应的处理
- //浏览器的渲染以及资源加载都是在一个线程中,如果在shouldInterceptRequest处理时间过长,WebView界面就会阻塞
- //21以下的
- @Override
- public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
- return super.shouldInterceptRequest(view, url);
- }
-
- //监听WebView发出的请求并做相应的处理
- //浏览器的渲染以及资源加载都是在一个线程中,如果在shouldInterceptRequest处理时间过长,WebView界面就会阻塞
- //21以上的
- @Override
- public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
- return super.shouldInterceptRequest(view, request);
- }
-
- //页面加载出现错误,23以下的
- @Override
- public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
- super.onReceivedError(view, errorCode, description, failingUrl);
- switch (errorCode) {
- case 404:
- //view.loadUrl("加载一个错误页面提示,优化体验");
- break;
- }
- }
-
- //页面加载出现错误,23以上的
- @TargetApi(23)
- @Override
- public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
- super.onReceivedError(view, request, error);
- switch (error.getErrorCode()) {
- case 404:
- //view.loadUrl("加载一个错误页面提示,优化体验");
- break;
- }
-
- }
-
- //https错误
- @Override
- public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
- super.onReceivedSslError(view, handler, error);
- }
- });
- }
-
- /**
- * 设置webView的辅助功能,如页面加载进度,title,图标,js弹框等
- */
- void setWebViewChromeClient() {
- mWebView.setWebChromeClient(new WebChromeClient() {
-
- //页面加载进度
- @Override
- public void onProgressChanged(WebView view, int newProgress) {
- super.onProgressChanged(view, newProgress);
- }
-
- //获取标题
- @Override
- public void onReceivedTitle(WebView view, String title) {
- super.onReceivedTitle(view, title);
- }
-
- //获取图标
- @Override
- public void onReceivedIcon(WebView view, Bitmap icon) {
- super.onReceivedIcon(view, icon);
- }
-
- //是否支持页面中的js警告弹出框
- @Override
- public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
-
- Toast.makeText(APIWebViewActivity.this, message, Toast.LENGTH_SHORT).show();
-
- return super.onJsAlert(view, url, message, result);
- }
-
- //是否支持页面中的js确定弹出框
- @Override
- public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
- return super.onJsConfirm(view, url, message, result);
- }
-
- //是否支持页面中的js输入弹出框
- @Override
- public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
- /**
- * 有时候,为了安全考虑,js的参数回调,会通过这类地方回调回来,然后不弹出框。
- */
- if(resolveJSPrompt(message)) {
- return true;
- }
- return super.onJsPrompt(view, url, message, defaultValue, result);
-
- }
- });
- }
-
- /**
- * 加载url
- */
- void loadUrl() {
- // 格式规定为:file:///android_asset/文件名.html
- mWebView.loadUrl("file:///android_asset/localHtml.html");
- //方式1. 加载远程网页:
- //mWebView.loadUrl("http://www.baidu.com/");
- //方式2:加载asset的html页面
- //mWebView.loadUrl("file:///android_asset/localHtml.html");
- //方式3:加载手机SD的html页面
- //mWebView.loadUrl("file:///mnt/sdcard/database/taobao.html");
- }
-
- /**
- * 执行网页中的js方法
- */
- void callJsFunction() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- mWebView.evaluateJavascript("javascript:callJS()", new ValueCallback
- * 在这个基础上解决了原作者的问题:Adapter无法使用ViewHolder优化的问题,优化了手势识别率,并添加了trashView功能,
- * 优化自定义控件对外扩展性,解决在上下拉环境下手势冲突问题
- *
+ * 跨屏滑动
*
*/
public class HTQDragGridView extends GridView {
@@ -110,9 +107,7 @@ public class HTQDragGridView extends GridView {
/**
* 获取状态栏的高度
- *
- * @param context
- * @return
+ *
*/
private static int getStatusHeight(Context context) {
int statusHeight = 0;
@@ -175,7 +170,6 @@ public class HTQDragGridView extends GridView {
/**
* 若设置为AUTO_FIT,计算有多少列
*/
- @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mNumColumns == AUTO_FIT) {
int numFittedColumns = 1; // 可用列
@@ -202,7 +196,7 @@ public class HTQDragGridView extends GridView {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
- @Override
+
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
initRecord();
@@ -226,7 +220,6 @@ public class HTQDragGridView extends GridView {
/******************** preference method ********************/
- @Override
public void setAdapter(ListAdapter adapter) {
super.setAdapter(adapter);
@@ -238,20 +231,20 @@ public class HTQDragGridView extends GridView {
}
}
- @Override
+
public void setNumColumns(int numColumns) {
super.setNumColumns(numColumns);
mNumColumnsSet = true;
this.mNumColumns = numColumns;
}
- @Override
+
public void setColumnWidth(int columnWidth) {
super.setColumnWidth(columnWidth);
mColumnWidth = columnWidth;
}
- @Override
+
public void setHorizontalSpacing(int horizontalSpacing) {
super.setHorizontalSpacing(horizontalSpacing);
this.mHorizontalSpacing = horizontalSpacing;
@@ -283,7 +276,7 @@ public class HTQDragGridView extends GridView {
/******************** touch method ********************/
- @Override
+
public boolean dispatchTouchEvent(MotionEvent ev) {
if (canDrag) {
switch (ev.getAction()) {
@@ -349,7 +342,7 @@ public class HTQDragGridView extends GridView {
return super.dispatchTouchEvent(ev);
}
- @Override
+
public boolean onTouchEvent(MotionEvent ev) {
if (isDrag && canDrag && mDragImageView != null) {
switch (ev.getAction()) {
@@ -445,7 +438,7 @@ public class HTQDragGridView extends GridView {
/**
* 拖动item,在里面实现了item镜像的位置更新,item的相互交换以及GridView的自行滚动
- *
+ *
* @param moveX
* @param moveY
*/
@@ -461,7 +454,7 @@ public class HTQDragGridView extends GridView {
/**
* 手指当前处于垃圾桶图标上
- *
+ *
* @param x
* @param y
* @return
@@ -519,7 +512,7 @@ public class HTQDragGridView extends GridView {
/**
* 交换item,并且控制item之间的显示与隐藏效果
- *
+ *
* @param moveX
* @param moveY
*/
@@ -553,7 +546,7 @@ public class HTQDragGridView extends GridView {
/**
* 创建移动动画
- *
+ *
* @param view
* @param startX
* @param endX
@@ -574,7 +567,7 @@ public class HTQDragGridView extends GridView {
/**
* item的交换动画效果
- *
+ *
* @param oldPosition
* @param newPosition
*/
diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/NoteItemCircleView.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/NoteItemCircleView.java
index f1cb526..9e13f7e 100644
--- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/NoteItemCircleView.java
+++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/NoteItemCircleView.java
@@ -6,8 +6,7 @@ import android.view.MotionEvent;
/**
* 圆形ImageView组件 点击事件不会穿透
- *
- * @author kymjs(kymjs123@gmail.com)
+
*/
public class NoteItemCircleView extends CircleImageView {
diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/ToggleButton.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/ToggleButton.java
index ba43744..a0ec663 100644
--- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/ToggleButton.java
+++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/ToggleButton.java
@@ -21,7 +21,7 @@ import com.example.administrator.myapplication.R;
/**
- * @author Qiujuer
+ * 开关按钮
*/
public class ToggleButton extends View {
/** */
@@ -320,7 +320,6 @@ public class ToggleButton extends View {
/**
- * @author ThinkPad
*/
public interface OnToggleChanged {
/**
diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/patternlock/LockPatternView.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/patternlock/LockPatternView.java
index e0524ad..7d5365c 100644
--- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/patternlock/LockPatternView.java
+++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/patternlock/LockPatternView.java
@@ -122,7 +122,6 @@ public class LockPatternView extends View {
/**
- * @author htq
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
diff --git a/src/MyApplication/app/src/main/res/layout/activity_api_webview.xml b/src/MyApplication/app/src/main/res/layout/activity_api_webview.xml
deleted file mode 100644
index 05df427..0000000
--- a/src/MyApplication/app/src/main/res/layout/activity_api_webview.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-