diff --git a/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeLists/AddListDialogFragment.java b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeLists/AddListDialogFragment.java index 8a02fc7..35f28e8 100644 --- a/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeLists/AddListDialogFragment.java +++ b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeLists/AddListDialogFragment.java @@ -13,7 +13,9 @@ import android.widget.EditText; import android.widget.TextView; +import com.firebase.client.Firebase; import com.udacity.firebase.shoppinglistplusplus.R; +import com.udacity.firebase.shoppinglistplusplus.utils.Constants; /** * Adds a new shopping list @@ -89,9 +91,14 @@ public void onClick(DialogInterface dialog, int id) { * Add new active list */ public void addShoppingList() { - // TODO Add code here to create or overwrite a node in Firebase called "listName" - // with the text that the user entered in the EditText mEditTextListName. - // This EditText is the one found in dialog_add_list with the id edit_text_list_name + // Get the reference to the root node in Firebase + Firebase ref = new Firebase(Constants.FIREBASE_URL); + // Get the string that the user entered into the EditText + String userEnteredName = mEditTextListName.getText().toString(); + // Go to the "listName" child node of the root node. + // This will create the node for you if it doesn't already exist. + // Then using the setValue menu it will set value the node to userEnteredName. + ref.child("listName").setValue(userEnteredName); } }