Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2021-01-02 18:29:59 +0300
committerStefan Niedermann <info@niedermann.it>2021-01-02 18:29:59 +0300
commit02e9b71a4cdbc7f026a4fa984aea2dbfafa14f70 (patch)
treec87859b66b0a56d91bdd8eb5c6ee82e80efb6cd3 /app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote
parentc77c85368ce3d07ae3d0fa0e060d8cbf8a5b2276 (diff)
Move more database queries away from the main thread
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java39
1 files changed, 20 insertions, 19 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java
index 797cc908..3b43ab2f 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java
@@ -52,24 +52,25 @@ public class SingleNoteWidgetConfigurationActivity extends MainActivity {
int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
- try {
- mainViewModel.createOrUpdateSingleNoteWidgetData(
- new SingleNoteWidgetData(
- appWidgetId,
- note.getAccountId(),
- note.getId(),
- NotesApplication.getAppTheme(this).getModeId()
- )
- );
- final Intent updateIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null,
- getApplicationContext(), SingleNoteWidget.class)
- .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- setResult(RESULT_OK, updateIntent);
- getApplicationContext().sendBroadcast(updateIntent);
- } catch (SQLException e) {
- Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
- }
-
- finish();
+ new Thread(() -> {
+ try {
+ mainViewModel.createOrUpdateSingleNoteWidgetData(
+ new SingleNoteWidgetData(
+ appWidgetId,
+ note.getAccountId(),
+ note.getId(),
+ NotesApplication.getAppTheme(this).getModeId()
+ )
+ );
+ final Intent updateIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null,
+ getApplicationContext(), SingleNoteWidget.class)
+ .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+ setResult(RESULT_OK, updateIntent);
+ getApplicationContext().sendBroadcast(updateIntent);
+ finish();
+ } catch (SQLException e) {
+ Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
+ }
+ });
}
}