Exemple #1
0
  private void fetchDiscussionInformation(View v, Discussion currentDiscussion) {
    // Get the creation date of the current discussion
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm", Locale.getDefault());

    // Get the expiration and creation date of the current discussion
    TextView creationDate = (TextView) v.findViewById(R.id.about_discussion_value_creation);
    TextView expirationDate = (TextView) v.findViewById(R.id.about_discussion_value_expiration);
    TextView lastUpdateDate = (TextView) v.findViewById(R.id.about_discussion_value_update);
    creationDate.setText(sdf.format(currentDiscussion.getCreationDate()));
    expirationDate.setText(sdf.format(currentDiscussion.getExpirationDate()));
    if (lastMsgDate != null) {
      lastUpdateDate.setText(sdf.format(lastMsgDate));
    }

    // Get the owner of the current discussion
    final TextView owner = (TextView) v.findViewById(R.id.about_discussion_value_owner);
    String ownerID = currentDiscussion.getOwnerParseID();
    if (ownerID != null) {
      ParseQuery<ReliUser> userQuery = ReliUser.getReliQuery();
      userQuery.getInBackground(
          ownerID,
          new GetCallback<ReliUser>() {
            public void done(ReliUser reliUser, ParseException e) {
              if (e == null) {
                owner.setText(reliUser.getFullName());
              } else {
                owner.setText(Const.UNKNOWN_USER);
              }
            }
          });
    } else {
      owner.setText(Const.UNKNOWN_USER);
    }

    // Get the radius of the current discussion
    TextView radius = (TextView) v.findViewById(R.id.about_discussion_value_radius);
    radius.setText(Integer.toString(currentDiscussion.getRadius()) + " meters");

    // Get the tags of the current discussion
    TextView tags = (TextView) v.findViewById(R.id.about_discussion_value_tags);
    ArrayList<String> tagsIDs = currentDiscussion.getTagIDsForDiscussion();
    String tagsListAsString = "";
    String currentTagName;
    for (String tagID : tagsIDs) {
      if (MainActivity.tagsIdToTag.containsKey(tagID)) {
        currentTagName = MainActivity.tagsIdToTag.get(tagID).getTagName();
        if (currentTagName != null) {
          tagsListAsString += currentTagName + ", ";
        }
      }
    }

    // Write the tags on screen
    if (tagsListAsString.equals("")) {
      tagsListAsString = getString(R.string.no_tags);
    } else {
      tagsListAsString = tagsListAsString.substring(0, tagsListAsString.length() - 2);
    }
    tags.setText(tagsListAsString);
  }
Exemple #2
0
  private boolean displayDiscussionInfo() {

    final AlertDialog.Builder builder = new AlertDialog.Builder(DiscussionActivity.this);
    LayoutInflater inflater = DiscussionActivity.this.getLayoutInflater();
    final View v = inflater.inflate(R.layout.about_discussion, null);

    final ProgressDialog dia =
        ProgressDialog.show(DiscussionActivity.this, null, getString(R.string.alert_loading));
    dia.setCanceledOnTouchOutside(false);
    ParseQuery<Discussion> discussionQuery = Discussion.getDiscussionQuery();
    discussionQuery.getInBackground(
        discussionTableName,
        new GetCallback<Discussion>() {
          public void done(Discussion currentDiscussion, ParseException e) {
            if ((e == null) && (currentDiscussion != null)) {
              fetchDiscussionInformation(v, currentDiscussion);
            }

            dia.dismiss();
          }
        });

    builder
        .setView(v)
        .setTitle(discussionTopic + " (" + messagesList.size() + " messages)")
        .setPositiveButton(R.string.ok, null)
        .create()
        .show();

    return true;
  }
Exemple #3
0
  private void handleNotifications() {
    // Make sure that we have instance of the Discussion object
    if (discussionObject == null) {
      return;
    }

    /**
     * ************ A new message was added to an existing discussion - we want to send notification
     * according to discussionsImIn **********
     */
    ParseQuery pushQuery = ParseInstallation.getQuery();

    // Get queries of devices that should get the notification
    pushQuery = ReliNotifications.getQueryAccordingToDiscussion(pushQuery, discussionTableName);

    // Get the list of devices that should be excluded
    pushQuery = ReliNotifications.getQueryExcludedCurrentUser(pushQuery);

    // Send push notification
    ReliNotifications.sendNotifications(
        pushQuery,
        MainActivity.user.getFullName()
            + " "
            + getString(R.string.notification_new_message_part_1)
            + " "
            + discussionObject.getDiscussionName()
            + " "
            + getString(R.string.notification_new_message_part_2));
  }
Exemple #4
0
 private void saveDiscussionObject() {
   if (discussionTableName != null) {
     ParseQuery<Discussion> discussionQuery = Discussion.getDiscussionQuery();
     discussionQuery.getInBackground(
         discussionTableName,
         new GetCallback<Discussion>() {
           public void done(Discussion returnedDiscussion, ParseException e) {
             if (e == null) {
               discussionObject = returnedDiscussion;
             }
           }
         });
   }
 }