Skip to content

Commit

Permalink
修改bug
Browse files Browse the repository at this point in the history
  • Loading branch information
梁任彦 committed Apr 14, 2021
1 parent 00f7cd0 commit 29c67f4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions imageselector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand All @@ -333,15 +334,16 @@ 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,
MediaStore.Images.Media._ID,
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()) {
Expand All @@ -352,6 +354,7 @@ private static boolean isNeedSavePicture(Context context, long takeTime) {
time *= 1000;
}
mCursor.close();

// 如果照片的插入时间大于相机的拍照时间,就认为是拍照图片已插入
return time + 1000 < takeTime;
}
Expand Down

0 comments on commit 29c67f4

Please sign in to comment.