提交 01376d72 编写于 作者: B Blankj

Merge branch 'master' into 1.24.0

* `19/02/28` [fix] ImageUtils#calculateInSampleSize. Publish v1.23.6.
* `19/02/26` [fix] UriUtils#uri2File. Publish v1.23.5.
* `19/01/31` [add] HttpUtils.
* `19/01/30` [add] RomUtils. Publish v1.23.4.
* `19/01/29` [fix] LogUtils format json when json not start with '{'. Publish v1.23.3.
......
......@@ -41,7 +41,7 @@
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.23.5-brightgreen.svg
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.23.6-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode
[apiSvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
......
......@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.23.5-brightgreen.svg
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.23.6-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode
[apiSvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
......
......@@ -5,8 +5,8 @@ ext {
compileSdkVersion = 27
minSdkVersion = 14
targetSdkVersion = 27
versionCode = 1_023_005
versionName = '1.23.5'// E.g. 1.9.72 => 1,009,072
versionCode = 1_023_006
versionName = '1.23.6'// E.g. 1.9.72 => 1,009,072
bus = [
isDebug: false,
......
......@@ -15,5 +15,5 @@ dependencies {
api dep.free_proguard
api 'com.r0adkll:slidableactivity:2.0.5'
compileOnly dep.leakcanary.android_no_op
// api 'com.blankj:utilcode:1.23.5'
// api 'com.blankj:utilcode:1.23.6'
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
Gradle:
```groovy
implementation 'com.blankj:utilcode:1.23.5'
implementation 'com.blankj:utilcode:1.23.6'
```
......
......@@ -27,7 +27,7 @@ apply plugin: "com.blankj.bus"
给 base 模块添加 [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode) 依赖:
```groovy
api "com.blankj:utilcode:1.23.5"
api "com.blankj:utilcode:1.23.6"
```
比如 module0 中存在的 `Module0Activity.java`,我们通常都是在它内部写一个 `start` 函数来启动它,现在我们给它添加 `@BusUtils.Subscribe` 注解,并给注解的 `name` 赋唯一值,要注意,函数务必要 `public static` 哦:
......
......@@ -2,7 +2,7 @@
Gradle:
```groovy
implementation 'com.blankj:utilcode:1.23.5'
implementation 'com.blankj:utilcode:1.23.6'
```
......
......@@ -1919,7 +1919,9 @@ public final class ImageUtils {
int height = options.outHeight;
int width = options.outWidth;
int inSampleSize = 1;
while ((width >>= 1) >= maxWidth && (height >>= 1) >= maxHeight) {
while (height > maxHeight || width > maxWidth) {
height >>= 1;
width >>= 1;
inSampleSize <<= 1;
}
return inSampleSize;
......
......@@ -2,7 +2,6 @@ package com.blankj.utilcode.util;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.CursorLoader;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
......@@ -59,8 +58,6 @@ public final class UriUtils {
if (path != null) return new File(path);
Log.d("UriUtils", uri.toString() + " parse failed. -> 0");
return null;
} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
return getFileFromUri(uri, 1);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
&& DocumentsContract.isDocumentUri(Utils.getApp(), uri)) {
if ("com.android.externalstorage.documents".equals(authority)) {
......@@ -70,7 +67,7 @@ public final class UriUtils {
if ("primary".equalsIgnoreCase(type)) {
return new File(Environment.getExternalStorageDirectory() + "/" + split[1]);
}
Log.d("UriUtils", uri.toString() + " parse failed. -> 2");
Log.d("UriUtils", uri.toString() + " parse failed. -> 1");
return null;
} else if ("com.android.providers.downloads.documents".equals(authority)) {
final String id = DocumentsContract.getDocumentId(uri);
......@@ -78,7 +75,7 @@ public final class UriUtils {
Uri.parse("content://downloads/public_downloads"),
Long.valueOf(id)
);
return getFileFromUri(contentUri, 3);
return getFileFromUri(contentUri, 2);
} else if ("com.android.providers.media.documents".equals(authority)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
......@@ -91,18 +88,22 @@ public final class UriUtils {
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
} else {
Log.d("UriUtils", uri.toString() + " parse failed. -> 4");
Log.d("UriUtils", uri.toString() + " parse failed. -> 3");
return null;
}
final String selection = "_id=?";
final String[] selectionArgs = new String[]{split[1]};
return getFileFromUri(contentUri, selection, selectionArgs, 5);
return getFileFromUri(contentUri, selection, selectionArgs, 4);
} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
return getFileFromUri(uri, 5);
} else {
Log.d("UriUtils", uri.toString() + " parse failed. -> 6");
return null;
}
} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
return getFileFromUri(uri, 7);
} else {
Log.d("UriUtils", uri.toString() + " parse failed. -> 7");
Log.d("UriUtils", uri.toString() + " parse failed. -> 8");
return null;
}
}
......@@ -115,22 +116,30 @@ public final class UriUtils {
final String selection,
final String[] selectionArgs,
final int code) {
CursorLoader cl = new CursorLoader(Utils.getApp());
cl.setUri(uri);
cl.setProjection(new String[]{"_data"});
Cursor cursor = null;
final Cursor cursor = Utils.getApp().getContentResolver().query(
uri, new String[]{"_data"}, selection, selectionArgs, null);
if (cursor == null) {
Log.d("UriUtils", uri.toString() + " parse failed(cursor is null). -> " + code);
return null;
}
try {
cursor = cl.loadInBackground();
int columnIndex = cursor.getColumnIndexOrThrow("_data");
cursor.moveToFirst();
return new File(cursor.getString(columnIndex));
if (cursor.moveToFirst()) {
final int columnIndex = cursor.getColumnIndex("_data");
if (columnIndex > -1) {
return new File(cursor.getString(columnIndex));
} else {
Log.d("UriUtils", uri.toString() + " parse failed(columnIndex: " + columnIndex + " is wrong). -> " + code);
return null;
}
} else {
Log.d("UriUtils", uri.toString() + " parse failed(moveToFirst return false). -> " + code);
return null;
}
} catch (Exception e) {
Log.d("UriUtils", uri.toString() + " parse failed. -> " + code);
return null;
} finally {
if (cursor != null) {
cursor.close();
}
cursor.close();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册