From 91b876589a38a0a8d6d7c3b88bbfefac5633940f Mon Sep 17 00:00:00 2001 From: Harris Date: Tue, 5 Oct 2021 10:58:02 +1100 Subject: [PATCH] refactor: move db module init before injection and replace ApplicationContext db component access to static function to get the component --- .../java/org/thoughtcrime/securesms/ApplicationContext.java | 2 +- .../main/java/org/thoughtcrime/securesms/ShareActivity.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java b/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java index ab7c4eda10..da8b2934b1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java +++ b/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java @@ -148,10 +148,10 @@ public class ApplicationContext extends Application implements DefaultLifecycleO @Override public void onCreate() { + DatabaseModule.init(this); super.onCreate(); Log.i(TAG, "onCreate()"); startKovenant(); - DatabaseModule.init(this); initializeSecurityProvider(); initializeLogging(); initializeCrashHandling(); diff --git a/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java b/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java index ed0ce4a37c..f03840c1ab 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java @@ -44,6 +44,7 @@ import org.thoughtcrime.securesms.components.SearchToolbar; import org.thoughtcrime.securesms.contacts.ContactSelectionListFragment; import org.thoughtcrime.securesms.contacts.ContactSelectionListLoader.DisplayMode; import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2; +import org.thoughtcrime.securesms.dependencies.DatabaseComponent; import org.thoughtcrime.securesms.mms.PartAuthority; import org.thoughtcrime.securesms.providers.BlobProvider; import org.thoughtcrime.securesms.util.MediaUtil; @@ -249,7 +250,7 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity @Override public void onContactSelected(String number) { Recipient recipient = Recipient.from(this, Address.fromExternal(this, number), true); - long existingThread = ApplicationContext.getInstance(this).getDatabaseComponent().threadDatabase().getThreadIdIfExistsFor(recipient); + long existingThread = DatabaseComponent.get(this).threadDatabase().getThreadIdIfExistsFor(recipient); createConversation(existingThread, recipient.getAddress(), DistributionTypes.DEFAULT); }