Created
November 21, 2017 07:10
-
-
Save fauzisho/b49e35f85c739a8788b6c28810128d0a to your computer and use it in GitHub Desktop.
openchatroom from notif
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Qiscus.getChatConfig().setNotificationClickListener(new NotificationClickListener() { | |
| @Override | |
| public void onClick(final Context context, QiscusComment qiscusComment) { | |
| QiscusChatRoom savedRoom = Qiscus.getDataStore().getChatRoom(qiscusComment.getRoomId()); | |
| if (savedRoom != null) { | |
| openChatroom(context, savedRoom); | |
| } else { | |
| QiscusApi.getInstance() | |
| .getChatRoom(qiscusComment.getRoomId()) | |
| .subscribeOn(Schedulers.io()) | |
| .observeOn(AndroidSchedulers.mainThread()) | |
| .subscribe(new Action1<QiscusChatRoom>() { | |
| @Override | |
| public void call(QiscusChatRoom qiscusChatRoom) { | |
| openChatroom(context, qiscusChatRoom); | |
| } | |
| }); | |
| } | |
| } | |
| }); | |
| private void openChatroom(Context context, QiscusChatRoom qiscusChatRoom) { | |
| Intent chatIntent = QiscusChatActivity.generateIntent(context, qiscusChatRoom); | |
| Intent parentIntent = new Intent(context, MainActivity.class); | |
| parentIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); | |
| TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); | |
| stackBuilder.addNextIntent(parentIntent); | |
| stackBuilder.addNextIntent(chatIntent); | |
| stackBuilder.startActivities(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment