コード例 #1
0
  /** Changes the group name in all copies of the current group */
  protected void doGroupEdit() {
    final String inputGroupName = mEditTextForGroup.getText().toString();

    /** Set input text to be the current group name if it is not empty */
    if (!inputGroupName.equals("")) {

      if (mGroupName != null && mGroupId != null) {

        /** If editText input is not equal to the previous name */
        if (!inputGroupName.equals(mGroupName)) {
          Firebase activeGroupRef =
              new Firebase(Constants.FIREBASE_URL_ACTIVE_GROUPS).child(mGroupId);

          // Make a HashMap for the specific properties you are changing
          HashMap<String, Object> updatedProperties = new HashMap<String, Object>();
          updatedProperties.put(Constants.FIREBASE_PROPERTY_GROUP_NAME, inputGroupName);

          // Add the timestamp for last changed to the updatedProperties HashMap
          HashMap<String, Object> changedTimestampMap = new HashMap<>();
          changedTimestampMap.put(Constants.FIREBASE_PROPERTY_TIMESTAMP, ServerValue.TIMESTAMP);

          // Add the updated timestamp
          updatedProperties.put(
              Constants.FIREBASE_PROPERTY_TIMESTAMP_LAST_CHANGED, changedTimestampMap);

          // Do the update
          activeGroupRef.updateChildren(updatedProperties);
        }
      }
    }
  }
コード例 #2
0
 @Override
 public void onFinishEditQuoteDialog(String quote_Input, String id) {
   Map<String, Object> quote = new HashMap<String, Object>();
   quote.put(id, quote_Input);
   quoteRef.updateChildren(quote);
   Toast.makeText(this, quote_Input + " was edited", Toast.LENGTH_SHORT).show();
 }
コード例 #3
0
  private boolean updateUrl() {
    if (UserHelper.userStillLoggedIn(userCreds.getExpireDate())) {
      try {
        Firebase ref =
            new Firebase(
                "https://yeah-url-extension.firebaseio.com/"
                    + userCreds.getUserId()
                    + "/urlcollector/"
                    + objId
                    + "/"
                    + id);

        Map<String, Object> updateNote = new HashMap<>(2);
        updateNote.put("keywords", etKeywordsUrl.getText().toString());
        updateNote.put("value", tvUrl.getText().toString());

        ref.updateChildren(
            updateNote,
            new Firebase.CompletionListener() {
              @Override
              public void onComplete(FirebaseError firebaseError, Firebase firebase) {
                if (firebaseError != null) {
                  Utilities.buildToast(
                      AddUrlActivity.this,
                      "Url updating failed: " + firebaseError.getMessage(),
                      Toast.LENGTH_LONG);
                } else {
                  Utilities.buildToast(
                      AddUrlActivity.this, "Url updated successfully!", Toast.LENGTH_LONG);
                }
              }
            });
      } catch (Exception e) {
        Utilities.buildToast(
            this, "Update Url failed! Error: " + e.getMessage(), Toast.LENGTH_LONG);
        return false;
      }

    } else {
      Utilities.buildToast(this, "User is not logged in!", Toast.LENGTH_LONG);
      startActivity(new Intent(AddUrlActivity.this, MainActivity.class));
    }
    return true;
  }