mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Simplify MediaScannerNotifier
This commit is contained in:
parent
c3f1420ef6
commit
e64ca84f1b
@ -1,28 +1,15 @@
|
||||
package com.fsck.k9.helper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.MediaScannerConnection;
|
||||
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
|
||||
import android.net.Uri;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.MediaScannerConnection;
|
||||
|
||||
public class MediaScannerNotifier implements MediaScannerConnectionClient {
|
||||
private MediaScannerConnection mConnection;
|
||||
private File mFile;
|
||||
|
||||
public MediaScannerNotifier(Context context, File file) {
|
||||
mFile = file;
|
||||
mConnection = new MediaScannerConnection(context, this);
|
||||
mConnection.connect();
|
||||
}
|
||||
|
||||
public void onMediaScannerConnected() {
|
||||
mConnection.scanFile(mFile.getAbsolutePath(), null);
|
||||
}
|
||||
|
||||
public void onScanCompleted(String path, Uri uri) {
|
||||
mConnection.disconnect();
|
||||
public class MediaScannerNotifier {
|
||||
public static void notify(Context context, File file) {
|
||||
String[] paths = { file.getAbsolutePath() };
|
||||
MediaScannerConnection.scanFile(context, paths, null, null);
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
|
||||
|
||||
displayAttachmentSavedMessage(file.toString());
|
||||
|
||||
new MediaScannerNotifier(context, file);
|
||||
MediaScannerNotifier.notify(context, file);
|
||||
} catch (IOException ioe) {
|
||||
if (K9.DEBUG) {
|
||||
Log.e(K9.LOG_TAG, "Error saving attachment", ioe);
|
||||
|
Loading…
Reference in New Issue
Block a user