forked from zhihu/Matisse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#feature: After the photo is taken, notify the system to update the m…
…edia library. 拍照后通知系统扫描更新媒体库,解决目前拍照后在相册里找不到的问题。 (zhihu#511) * #feature: After the photo is taken, notify the system to update the media library * checkStyle: #feature: After the photo is taken, notify the system to update the media library * Delete meaningless code Delete meaningless code
- Loading branch information
1 parent
3ddaf23
commit 8de3344
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
matisse/src/main/java/com/zhihu/matisse/internal/utils/SingleMediaScanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.zhihu.matisse.internal.utils; | ||
|
||
import android.content.Context; | ||
import android.media.MediaScannerConnection; | ||
import android.net.Uri; | ||
|
||
/** | ||
* @author 工藤 | ||
* @email gougou@16fan.com | ||
* create at 2018年10月23日12:17:59 | ||
* description:媒体扫描 | ||
*/ | ||
public class SingleMediaScanner implements MediaScannerConnection.MediaScannerConnectionClient { | ||
|
||
private MediaScannerConnection mMsc; | ||
private String mPath; | ||
private ScanListener mListener; | ||
|
||
public interface ScanListener { | ||
|
||
/** | ||
* scan finish | ||
*/ | ||
void onScanFinish(); | ||
} | ||
|
||
public SingleMediaScanner(Context context, String mPath, ScanListener mListener) { | ||
this.mPath = mPath; | ||
this.mListener = mListener; | ||
this.mMsc = new MediaScannerConnection(context, this); | ||
this.mMsc.connect(); | ||
} | ||
|
||
@Override public void onMediaScannerConnected() { | ||
mMsc.scanFile(mPath, null); | ||
} | ||
|
||
@Override public void onScanCompleted(String mPath, Uri mUri) { | ||
mMsc.disconnect(); | ||
if (mListener != null) { | ||
mListener.onScanFinish(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters