-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update code in chatUI for fix PN not working
- Loading branch information
Arief Nur Putranto
committed
Nov 6, 2024
1 parent
255d079
commit ac78b0d
Showing
3 changed files
with
65 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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
41 changes: 40 additions & 1 deletion
41
chat/src/main/java/com/qiscus/sdk/util/NotificationClickReceiver.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,41 @@ | ||
package com.qiscus.sdk.util;public class NotificationClickReceiver { | ||
package com.qiscus.sdk.util; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.widget.Toast; | ||
|
||
import com.qiscus.sdk.chat.core.QiscusCore; | ||
import com.qiscus.sdk.chat.core.data.model.QiscusChatRoom; | ||
import com.qiscus.sdk.chat.core.data.model.QiscusComment; | ||
import com.qiscus.sdk.chat.core.data.remote.QiscusApi; | ||
import com.qiscus.sdk.ui.QiscusChatActivity; | ||
import com.qiscus.sdk.ui.QiscusGroupChatActivity; | ||
|
||
import rx.android.schedulers.AndroidSchedulers; | ||
import rx.schedulers.Schedulers; | ||
|
||
public class NotificationClickReceiver extends BroadcastReceiver { | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
QiscusComment qiscusComment = intent.getParcelableExtra("data"); | ||
QiscusApi.getInstance() | ||
.getChatRoom(qiscusComment.getRoomId()) | ||
.subscribeOn(Schedulers.io()) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.doOnNext(qiscusChatRoom -> QiscusCore.getDataStore().addOrUpdate(qiscusChatRoom)) | ||
.map(qiscusChatRoom -> getChatRoomActivity(context, qiscusChatRoom)) | ||
.subscribe(newIntent -> start(context, newIntent), throwable -> | ||
Toast.makeText(context, throwable.getLocalizedMessage(), Toast.LENGTH_SHORT).show()); | ||
} | ||
|
||
private Intent getChatRoomActivity(Context context, QiscusChatRoom qiscusChatRoom) { | ||
return qiscusChatRoom.isGroup() ? QiscusGroupChatActivity.generateIntent(context, qiscusChatRoom) : | ||
QiscusChatActivity.generateIntent(context, qiscusChatRoom); | ||
} | ||
|
||
private void start(Context context, Intent newIntent) { | ||
context.startActivity(newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)); | ||
} | ||
} |
This file contains 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