Beispiel #1
0
  public void onSendClicked(View v) {
    String content = etChatWindowMessage.getText().toString();

    Message message = new Message(content, HushApp.getCurrentUser().getFacebookId());
    message.saveToParse();

    chat.addMessage(message);
    chat.saveToParse();

    // Save to parse and send a push notification
    chat.saveToParseWithPush(
        this,
        HushPushNotifReceiver.PushType.NEW_MESSAGE.toString(),
        chat.getTopic() + "|" + message.getContent(),
        getChatterFacebookIds());

    adapterMessages.add(message);

    etChatWindowMessage.setText("");
  }
Beispiel #2
0
  private void updateMessagesAdapterFromDisk() {
    // Read the unread items from disk
    ArrayList<String> notifs = HushUtils.readFromFile(ChatWindowActivity.this);

    // There is no file to process, everything has been processed already
    if (notifs.size() == 0) {
      return;
    }

    HushUtils.deleteFile(ChatWindowActivity.this);

    for (String notifMsg : notifs) {
      if (notifMsg.startsWith(HushPushNotifReceiver.PushType.NEW_MESSAGE.toString())) {
        String[] notifParts = notifMsg.split("\\|");
        if (notifParts[2].equals(chat.getObjectId())) {
          adapterMessages.add(new Message(notifParts[3], "-1"));
        } else {
          HushUtils.writeToFile(ChatWindowActivity.this, notifMsg);
        }
      } else {
        HushUtils.writeToFile(ChatWindowActivity.this, notifMsg);
      }
    }
  }