diff --git a/app/build.gradle b/app/build.gradle index dd55497..8f6c0be 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,11 +1,11 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 29 + compileSdkVersion 30 defaultConfig { applicationId "com.donkingliang.imageselectdemo" minSdkVersion 14 - targetSdkVersion 29 + targetSdkVersion 30 versionCode 1 versionName "1.0" } @@ -21,7 +21,7 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.12' implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.recyclerview:recyclerview:1.0.0' + implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'com.github.bumptech.glide:glide:4.9.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0' implementation project(':imageselector') diff --git a/build.gradle b/build.gradle index 3ba51d7..f582dac 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ allprojects { repositories { jcenter() maven { url "https://jitpack.io" } - maven { url 'https://maven.google.com' } +// maven { url 'https://maven.google.com' } google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1be472a..6c5af95 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Dec 28 10:00:20 PST 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/imageselector/build.gradle b/imageselector/build.gradle index 07c287d..f99ff0b 100644 --- a/imageselector/build.gradle +++ b/imageselector/build.gradle @@ -3,10 +3,10 @@ apply plugin: 'com.android.library' group='com.github.donkingliang' // 指定group,com.github.<用户名> android { - compileSdkVersion 29 + compileSdkVersion 30 defaultConfig { minSdkVersion 14 - targetSdkVersion 29 + targetSdkVersion 30 versionCode 1 versionName "1.0" } diff --git a/imageselector/src/main/java/com/donkingliang/imageselector/model/ImageModel.java b/imageselector/src/main/java/com/donkingliang/imageselector/model/ImageModel.java index ba467ee..5f07e2b 100644 --- a/imageselector/src/main/java/com/donkingliang/imageselector/model/ImageModel.java +++ b/imageselector/src/main/java/com/donkingliang/imageselector/model/ImageModel.java @@ -43,7 +43,7 @@ public static void preloadAndRegisterContentObserver(final Context context) { if (observer == null) { observer = new PhotoContentObserver(context.getApplicationContext()); context.getApplicationContext().getContentResolver().registerContentObserver( - MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, observer); + MediaStore.Images.Media.EXTERNAL_CONTENT_URI, true, observer); } preload(context); } diff --git a/imageselector/src/main/java/com/donkingliang/imageselector/utils/ImageUtil.java b/imageselector/src/main/java/com/donkingliang/imageselector/utils/ImageUtil.java index d67115c..1c6b0ac 100644 --- a/imageselector/src/main/java/com/donkingliang/imageselector/utils/ImageUtil.java +++ b/imageselector/src/main/java/com/donkingliang/imageselector/utils/ImageUtil.java @@ -319,6 +319,7 @@ public static void savePicture(final Context context, final Uri uri, final long @Override public void run() { if (isNeedSavePicture(context, takeTime)) { + Log.e("eee","-----"); context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri)); } } @@ -333,7 +334,8 @@ public void run() { */ private static boolean isNeedSavePicture(Context context, long takeTime) { //扫描图片 - Uri mImageUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; + Uri mImageUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI + .buildUpon().appendQueryParameter("limit","1").build(); ContentResolver mContentResolver = context.getContentResolver(); Cursor mCursor = mContentResolver.query(mImageUri, new String[]{ MediaStore.Images.Media.DATE_ADDED, @@ -341,7 +343,7 @@ private static boolean isNeedSavePicture(Context context, long takeTime) { MediaStore.Images.Media.SIZE}, MediaStore.MediaColumns.SIZE + ">0", null, - MediaStore.Files.FileColumns._ID + " DESC limit 1 offset 0"); + MediaStore.Files.FileColumns._ID + " DESC"); //读取扫描到的图片 if (mCursor != null && mCursor.getCount() > 0 && mCursor.moveToFirst()) { @@ -352,6 +354,7 @@ private static boolean isNeedSavePicture(Context context, long takeTime) { time *= 1000; } mCursor.close(); + // 如果照片的插入时间大于相机的拍照时间,就认为是拍照图片已插入 return time + 1000 < takeTime; }