aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils/XmppConnectionServiceAccessor.java
blob: 1f1d7cf44e964beeee989946c1774962e2a8bcb5 (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
package de.thedevstack.conversationsplus.utils;

import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.services.XmppConnectionService;

/**
 * Accessor utility to access XmppConnectionService without having to pass the XmppConnectionService every time.
 */
public final class XmppConnectionServiceAccessor {
    public static XmppConnectionService xmppConnectionService;

    /**
     * Initializes the XmppConnectionService.
     * This method needs to be called once in XmppConnectionService#onCreate.
     * @param xmppConnectionService
     */
    public static void initXmppConnectionService(XmppConnectionService xmppConnectionService) {
        if (null == XmppConnectionServiceAccessor.xmppConnectionService) {
            XmppConnectionServiceAccessor.xmppConnectionService = xmppConnectionService;
        } else {
            Logging.e("XmppConnectionServiceAccessor", "XMPP Connection Service already instantiated.");
        }
    }

    /**
     * Avoid instantiation
     */
    private XmppConnectionServiceAccessor() {
        // avoid instantiation
    }
}