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."); } } }