From c6ed89e4109a3db25d9cae8ad1426a3294e721c3 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Tue, 23 Aug 2016 12:00:50 +0200 Subject: Javadoc added and access to xmppConnectionService moved --- .../conversationsplus/persistance/FileBackend.java | 5 +++-- .../conversationsplus/ui/listeners/DeleteFileCallback.java | 14 +++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java b/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java index 9f7e473e..e5597c3c 100644 --- a/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java +++ b/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java @@ -28,6 +28,7 @@ import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.DownloadableFile; import de.thedevstack.conversationsplus.entities.Message; import de.thedevstack.conversationsplus.services.XmppConnectionService; +import de.thedevstack.conversationsplus.utils.XmppConnectionServiceAccessor; public class FileBackend { private static final SimpleDateFormat imageDateFormat = new SimpleDateFormat("yyyyMMdd_HHmmssSSS", Locale.US); @@ -90,10 +91,10 @@ public class FileBackend { } } - public static boolean deleteFile(Message message, XmppConnectionService xmppConnectionService) { + public static boolean deleteFile(Message message) { File file = getFile(message); if (file.delete()) { - updateMediaScanner(file, xmppConnectionService); + updateMediaScanner(file, XmppConnectionServiceAccessor.xmppConnectionService); return true; } else { return false; diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/DeleteFileCallback.java b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/DeleteFileCallback.java index 3ff7f367..f855a90d 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/DeleteFileCallback.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/DeleteFileCallback.java @@ -5,10 +5,9 @@ import de.thedevstack.conversationsplus.entities.Transferable; import de.thedevstack.conversationsplus.entities.TransferablePlaceholder; import de.thedevstack.conversationsplus.persistance.FileBackend; import de.thedevstack.conversationsplus.utils.UiUpdateHelper; -import de.thedevstack.conversationsplus.utils.XmppConnectionServiceAccessor; /** - * Created by steckbrief on 23.08.2016. + * Callback for the user decision if a file should be deleted or not. */ public class DeleteFileCallback implements SimpleUserDecisionCallback { private final Message message; @@ -17,18 +16,27 @@ public class DeleteFileCallback implements SimpleUserDecisionCallback { this.message = message; } + /** + * Deletes the file and updates the UI. + */ private void deleteFile() { - if (FileBackend.deleteFile(this.message, XmppConnectionServiceAccessor.xmppConnectionService)) { + if (FileBackend.deleteFile(this.message)) { this.message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED)); UiUpdateHelper.updateConversationUi(); } } + /** + * Deletes the file. + */ @Override public void onYes() { this.deleteFile(); } + /** + * Nothing to do in this case. + */ @Override public void onNo() { // Nothing to do -- cgit v1.2.3