Skip to content

Instantly share code, notes, and snippets.

@fauzisho
Created November 21, 2017 07:10
Show Gist options
  • Select an option

  • Save fauzisho/b49e35f85c739a8788b6c28810128d0a to your computer and use it in GitHub Desktop.

Select an option

Save fauzisho/b49e35f85c739a8788b6c28810128d0a to your computer and use it in GitHub Desktop.
openchatroom from notif
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