|
52 | 52 | import java.util.Timer;
|
53 | 53 | import java.util.TimerTask;
|
54 | 54 |
|
| 55 | +import rx.android.schedulers.AndroidSchedulers; |
| 56 | +import rx.schedulers.Schedulers; |
| 57 | + |
55 | 58 | public enum QiscusPusherApi implements MqttCallback, IMqttActionListener {
|
56 | 59 |
|
57 | 60 | INSTANCE;
|
@@ -272,35 +275,19 @@ public void setUserTyping(int roomId, int topicId, boolean typing) {
|
272 | 275 |
|
273 | 276 |
|
274 | 277 | public void setUserRead(int roomId, int topicId, int commentId, String commentUniqueId) {
|
275 |
| - if (!mqttAndroidClient.isConnected()) { |
276 |
| - connect(); |
277 |
| - } |
278 |
| - try { |
279 |
| - MqttMessage message = new MqttMessage(); |
280 |
| - message.setPayload((commentId + ":" + commentUniqueId).getBytes()); |
281 |
| - message.setQos(1); |
282 |
| - message.setRetained(true); |
283 |
| - pendingTokens.add(mqttAndroidClient.publish("r/" + roomId + "/" + topicId + "/" |
284 |
| - + qiscusAccount.getEmail() + "/r", message)); |
285 |
| - } catch (MqttException | NullPointerException e) { |
286 |
| - e.printStackTrace(); |
287 |
| - } |
| 278 | + QiscusApi.getInstance().updateCommentStatus(roomId, commentId, 0) |
| 279 | + .subscribeOn(Schedulers.io()) |
| 280 | + .observeOn(AndroidSchedulers.mainThread()) |
| 281 | + .subscribe(aVoid -> { |
| 282 | + }, Throwable::printStackTrace); |
288 | 283 | }
|
289 | 284 |
|
290 | 285 | public void setUserDelivery(int roomId, int topicId, int commentId, String commentUniqueId) {
|
291 |
| - if (!mqttAndroidClient.isConnected()) { |
292 |
| - connect(); |
293 |
| - } |
294 |
| - try { |
295 |
| - MqttMessage message = new MqttMessage(); |
296 |
| - message.setPayload((commentId + ":" + commentUniqueId).getBytes()); |
297 |
| - message.setQos(1); |
298 |
| - message.setRetained(true); |
299 |
| - pendingTokens.add(mqttAndroidClient.publish("r/" + roomId + "/" + topicId + "/" |
300 |
| - + qiscusAccount.getEmail() + "/d", message)); |
301 |
| - } catch (MqttException | NullPointerException e) { |
302 |
| - e.printStackTrace(); |
303 |
| - } |
| 286 | + QiscusApi.getInstance().updateCommentStatus(roomId, 0, commentId) |
| 287 | + .subscribeOn(Schedulers.io()) |
| 288 | + .observeOn(AndroidSchedulers.mainThread()) |
| 289 | + .subscribe(aVoid -> { |
| 290 | + }, Throwable::printStackTrace); |
304 | 291 | }
|
305 | 292 |
|
306 | 293 | @Override
|
|
0 commit comments