aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils/UiUpdateHelper.java
blob: 7638caadf3332dca7f38a128bba41fc96373bdd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package de.thedevstack.conversationsplus.utils;

import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.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.");
        }
    }
}