From 172d2493696894cb4cd5192b0e5042cb321ed9f2 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 8 Dec 2017 18:43:58 +0100 Subject: [PATCH] initialize emoji helper in StartConversationActivity --- .../conversations/ui/StartConversationActivity.java | 10 +++++----- .../eu/siacs/conversations/utils/EmojiWrapper.java | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index b24613079..914ed6358 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -75,6 +75,7 @@ import eu.siacs.conversations.entities.Presence; import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.ui.adapter.KnownHostsAdapter; import eu.siacs.conversations.ui.adapter.ListItemAdapter; +import eu.siacs.conversations.ui.service.EmojiService; import eu.siacs.conversations.utils.XmppUri; import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.XmppConnection; @@ -257,8 +258,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + new EmojiService(this).init(); setContentView(R.layout.activity_start_conversation); - mViewPager = (ViewPager) findViewById(R.id.start_conversation_view_pager); + mViewPager = findViewById(R.id.start_conversation_view_pager); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); @@ -275,7 +277,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU mConferenceAdapter = new ListItemAdapter(this, conferences); mContactsAdapter = new ListItemAdapter(this, contacts); - ((ListItemAdapter) mContactsAdapter).setOnTagClickedListener(this.mOnTagClickedListener); + mContactsAdapter.setOnTagClickedListener(this.mOnTagClickedListener); this.mHideOfflineContacts = getPreferences().getBoolean("hide_offline", false); } @@ -316,9 +318,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } protected void openConversationForContact(Contact contact) { - Conversation conversation = xmppConnectionService - .findOrCreateConversation(contact.getAccount(), - contact.getJid(), false, true); + Conversation conversation = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), false, true); switchToConversation(conversation); } diff --git a/src/main/java/eu/siacs/conversations/utils/EmojiWrapper.java b/src/main/java/eu/siacs/conversations/utils/EmojiWrapper.java index 32a36f59b..9466531a3 100644 --- a/src/main/java/eu/siacs/conversations/utils/EmojiWrapper.java +++ b/src/main/java/eu/siacs/conversations/utils/EmojiWrapper.java @@ -34,11 +34,14 @@ import android.support.text.emoji.EmojiCompat; public class EmojiWrapper { public static CharSequence transform(CharSequence input) { - final CharSequence charSequence; + try { if (EmojiCompat.get().getLoadState() == EmojiCompat.LOAD_STATE_SUCCEEDED) { return EmojiCompat.get().process(input); } else { return input; } + } catch (IllegalStateException e) { + return input; + } } }