Esempio n. 1
1
  private void displayFriendCount() {
    Collection<GraphUser> selectedFriends = HushApp.getSelectedUsers();

    if (selectedFriends == null || selectedFriends.size() == 0) {
      return;
    }
    numFriendsSelected = selectedFriends.size();

    Chatter chatter;
    final ArrayList<String> fbChatterIds = new ArrayList<String>();
    Collection<GraphUser> selection = HushApp.getSelectedUsers();
    for (GraphUser user : selection) {
      chatter = new Chatter(user.getId(), user.getName());
      fbChatterIds.add(user.getId());
      chatter.saveToParse();
      chat.addChatter(chatter);
    }

    // Send a push notification
    chat.saveToParseWithPush(
        this,
        HushPushNotifReceiver.PushType.NEW_CHAT.toString(),
        getString(R.string.new_chat_push_notif_message),
        fbChatterIds);
  }
Esempio n. 2
0
  private void setChatterFacebookIds() {
    if (chatterFacebookIds == null) {
      chatterFacebookIds = new ArrayList<String>();
    }

    for (Chatter chatter : chatters) {
      // Send the notif to everyone except yourself
      if (!chatter.getFacebookId().equals(HushApp.getCurrentUser().getFacebookId())) {
        chatterFacebookIds.add(chatter.getFacebookId());
      }
    }
  }
Esempio n. 3
0
  @Override
  protected void onResume() {
    super.onResume();

    chat = HushApp.getCurrentUser().getCurrentChat();
    chat.fetchChattersFromParse(this);
    chat.fetchMessagesFromParse(maxMessages, this);

    tvChatTopic.setText(chat.getTopic());

    // Register as broadcast receiver
    LocalBroadcastManager.getInstance(this)
        .registerReceiver(
            pushNotifReceiver, new IntentFilter(Constants.broadcastLocalMessageAction));

    updateMessagesAdapterFromDisk();
  }
Esempio n. 4
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("");
  }