Search in sources :

Example 1 with ChatSessionInitTask

use of org.awesomeapp.messenger.tasks.ChatSessionInitTask in project Zom-Android by zom.

the class ImUrlActivity method startChat.

public void startChat(long providerId, long accountId, String username, final boolean openChat) {
    if (username != null)
        new ChatSessionInitTask(((ImApp) getApplication()), providerId, accountId, Imps.Contacts.TYPE_NORMAL, true) {

            @Override
            protected void onPostExecute(Long chatId) {
                if (chatId != -1 && openChat) {
                    Intent intent = new Intent(ImUrlActivity.this, ConversationDetailActivity.class);
                    intent.putExtra("id", chatId);
                    startActivity(intent);
                }
                finish();
                super.onPostExecute(chatId);
            }
        }.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(username)));
}
Also used : ChatSessionInitTask(org.awesomeapp.messenger.tasks.ChatSessionInitTask) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) Intent(android.content.Intent) Contact(org.awesomeapp.messenger.model.Contact)

Example 2 with ChatSessionInitTask

use of org.awesomeapp.messenger.tasks.ChatSessionInitTask in project Zom-Android by zom.

the class ConversationView method startChat.

private void startChat(String username) {
    if (username != null) {
        new ChatSessionInitTask(((ImApp) mActivity.getApplication()), mProviderId, mAccountId, Imps.Contacts.TYPE_NORMAL, true) {

            @Override
            protected void onPostExecute(Long chatId) {
                if (chatId != -1 && true) {
                    Intent intent = new Intent(mActivity, ConversationDetailActivity.class);
                    intent.putExtra("id", chatId);
                    mActivity.startActivity(intent);
                }
                super.onPostExecute(chatId);
            }
        }.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(username)));
        mActivity.finish();
    }
}
Also used : ChatSessionInitTask(org.awesomeapp.messenger.tasks.ChatSessionInitTask) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) Intent(android.content.Intent) Contact(org.awesomeapp.messenger.model.Contact)

Example 3 with ChatSessionInitTask

use of org.awesomeapp.messenger.tasks.ChatSessionInitTask in project Zom-Android by zom.

the class ContactDisplayActivity method startChat.

public void startChat() {
    if (mConn == null)
        return;
    try {
        IChatSessionManager manager = mConn.getChatSessionManager();
        if (manager != null) {
            IChatSession session = manager.getChatSession(mUsername);
            if (session == null) {
                new ChatSessionInitTask(((ImApp) getApplication()), mProviderId, mAccountId, Imps.Contacts.TYPE_NORMAL, false) {

                    @Override
                    protected void onPostExecute(Long chatId) {
                        super.onPostExecute(chatId);
                        if (mContactId == -1) {
                            Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
                            intent.putExtra("id", chatId);
                            startActivity(intent);
                            finish();
                        }
                    }
                }.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(mUsername)));
            // Toast.makeText(this, getString(R.string.message_waiting_for_friend), Toast.LENGTH_LONG).show();
            } else {
                Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
                intent.putExtra("id", session.getId());
                startActivity(intent);
                finish();
            }
        }
    } catch (RemoteException re) {
    }
    if (mContactId != -1) {
        Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
        intent.putExtra("id", mContactId);
        startActivity(intent);
        finish();
    }
}
Also used : IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) ChatSessionInitTask(org.awesomeapp.messenger.tasks.ChatSessionInitTask) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) Intent(android.content.Intent) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession) Contact(org.awesomeapp.messenger.model.Contact)

Example 4 with ChatSessionInitTask

use of org.awesomeapp.messenger.tasks.ChatSessionInitTask in project Zom-Android by zom.

the class MainActivity method startChat.

public void startChat(long providerId, long accountId, String username, final boolean openChat) {
    if (username != null)
        new ChatSessionInitTask(((ImApp) getApplication()), providerId, accountId, Imps.Contacts.TYPE_NORMAL, true) {

            @Override
            protected void onPostExecute(Long chatId) {
                if (chatId != -1 && openChat) {
                    Intent intent = new Intent(MainActivity.this, ConversationDetailActivity.class);
                    intent.putExtra("id", chatId);
                    startActivity(intent);
                }
                super.onPostExecute(chatId);
            }
        }.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(username)));
}
Also used : ChatSessionInitTask(org.awesomeapp.messenger.tasks.ChatSessionInitTask) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) Intent(android.content.Intent) Contact(org.awesomeapp.messenger.model.Contact)

Aggregations

Intent (android.content.Intent)4 Contact (org.awesomeapp.messenger.model.Contact)4 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)4 ChatSessionInitTask (org.awesomeapp.messenger.tasks.ChatSessionInitTask)4 RemoteException (android.os.RemoteException)1 IChatSession (org.awesomeapp.messenger.service.IChatSession)1 IChatSessionManager (org.awesomeapp.messenger.service.IChatSessionManager)1