From e64ca84f1bc9e7e09c0ba87735d0982f4a476d55 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 10 Nov 2014 06:43:26 +0100 Subject: [PATCH] Simplify MediaScannerNotifier --- .../fsck/k9/helper/MediaScannerNotifier.java | 25 +++++-------------- src/com/fsck/k9/view/AttachmentView.java | 2 +- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/com/fsck/k9/helper/MediaScannerNotifier.java b/src/com/fsck/k9/helper/MediaScannerNotifier.java index dd8bfcdff..9dbed11ce 100644 --- a/src/com/fsck/k9/helper/MediaScannerNotifier.java +++ b/src/com/fsck/k9/helper/MediaScannerNotifier.java @@ -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); } } diff --git a/src/com/fsck/k9/view/AttachmentView.java b/src/com/fsck/k9/view/AttachmentView.java index 8dcef251d..000cf2b87 100644 --- a/src/com/fsck/k9/view/AttachmentView.java +++ b/src/com/fsck/k9/view/AttachmentView.java @@ -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);