initialize emoji helper in StartConversationActivity

This commit is contained in:
Daniel Gultsch 2017-12-08 18:43:58 +01:00
parent cdee6523e4
commit 172d249369
2 changed files with 9 additions and 6 deletions

View File

@ -75,6 +75,7 @@ import eu.siacs.conversations.entities.Presence;
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
import eu.siacs.conversations.ui.adapter.KnownHostsAdapter; import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
import eu.siacs.conversations.ui.adapter.ListItemAdapter; import eu.siacs.conversations.ui.adapter.ListItemAdapter;
import eu.siacs.conversations.ui.service.EmojiService;
import eu.siacs.conversations.utils.XmppUri; import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.XmppConnection;
@ -257,8 +258,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
new EmojiService(this).init();
setContentView(R.layout.activity_start_conversation); 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 actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
@ -275,7 +277,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
mConferenceAdapter = new ListItemAdapter(this, conferences); mConferenceAdapter = new ListItemAdapter(this, conferences);
mContactsAdapter = new ListItemAdapter(this, contacts); mContactsAdapter = new ListItemAdapter(this, contacts);
((ListItemAdapter) mContactsAdapter).setOnTagClickedListener(this.mOnTagClickedListener); mContactsAdapter.setOnTagClickedListener(this.mOnTagClickedListener);
this.mHideOfflineContacts = getPreferences().getBoolean("hide_offline", false); this.mHideOfflineContacts = getPreferences().getBoolean("hide_offline", false);
} }
@ -316,9 +318,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
} }
protected void openConversationForContact(Contact contact) { protected void openConversationForContact(Contact contact) {
Conversation conversation = xmppConnectionService Conversation conversation = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), false, true);
.findOrCreateConversation(contact.getAccount(),
contact.getJid(), false, true);
switchToConversation(conversation); switchToConversation(conversation);
} }

View File

@ -34,11 +34,14 @@ import android.support.text.emoji.EmojiCompat;
public class EmojiWrapper { public class EmojiWrapper {
public static CharSequence transform(CharSequence input) { public static CharSequence transform(CharSequence input) {
final CharSequence charSequence; try {
if (EmojiCompat.get().getLoadState() == EmojiCompat.LOAD_STATE_SUCCEEDED) { if (EmojiCompat.get().getLoadState() == EmojiCompat.LOAD_STATE_SUCCEEDED) {
return EmojiCompat.get().process(input); return EmojiCompat.get().process(input);
} else { } else {
return input; return input;
} }
} catch (IllegalStateException e) {
return input;
}
} }
} }