aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils/UiUpdateHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/utils/UiUpdateHelper.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/UiUpdateHelper.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/UiUpdateHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/UiUpdateHelper.java
new file mode 100644
index 00000000..84ce200a
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/UiUpdateHelper.java
@@ -0,0 +1,52 @@
+package de.thedevstack.conversationsplus.utils;
+
+import de.thedevstack.android.logcat.Logging;
+import eu.siacs.conversations.services.XmppConnectionService;
+
+/**
+ * Helper class to avoid passing the xmppConnectionService to everywhere just to update the UI.
+ * TODO: Make even this helper class work without XmppConnectionService
+ */
+public class UiUpdateHelper {
+ private static XmppConnectionService xmppConnectionService;
+
+ public static void initXmppConnectionService(XmppConnectionService xmppConnectionService) {
+ if (null == UiUpdateHelper.xmppConnectionService) {
+ UiUpdateHelper.xmppConnectionService = xmppConnectionService;
+ } else {
+ Logging.e("UiUpdateHelper", "XMPP Connection Service already instantiated.");
+ }
+ }
+
+ public static void updateConversationUi() {
+ if (null != UiUpdateHelper.xmppConnectionService) {
+ UiUpdateHelper.xmppConnectionService.updateConversationUi();
+ } else {
+ Logging.e("UiUpdateHelper", "XMPP Connection Service not initialized. Conversation Ui not updated.");
+ }
+ }
+
+ public static void updateAccountUi() {
+ if (null != UiUpdateHelper.xmppConnectionService) {
+ UiUpdateHelper.xmppConnectionService.updateAccountUi();
+ } else {
+ Logging.e("UiUpdateHelper", "XMPP Connection Service not initialized. Account Ui not updated.");
+ }
+ }
+
+ public static void updateRosterUi() {
+ if (null != UiUpdateHelper.xmppConnectionService) {
+ UiUpdateHelper.xmppConnectionService.updateRosterUi();
+ } else {
+ Logging.e("UiUpdateHelper", "XMPP Connection Service not initialized. Roster Ui not updated.");
+ }
+ }
+
+ public static void updateMucRosterUi() {
+ if (null != UiUpdateHelper.xmppConnectionService) {
+ UiUpdateHelper.xmppConnectionService.updateMucRosterUi();
+ } else {
+ Logging.e("UiUpdateHelper", "XMPP Connection Service not initialized. MUC Roster Ui not updated.");
+ }
+ }
+}