Created
November 10, 2013 18:31
-
-
Save sberan/7401942 to your computer and use it in GitHub Desktop.
Firebase Wrapper Test Activity using Butterknife
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.FireBaseTest; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.text.TextUtils; | |
import android.widget.EditText; | |
import android.widget.TextView; | |
import butterknife.InjectView; | |
import butterknife.OnClick; | |
import butterknife.Views; | |
import com.thirdiron.firebasewrapper.FireBaseWrapper; | |
public class MyActivity extends Activity { | |
@InjectView(R.id.key) EditText key; | |
@InjectView(R.id.value) EditText value; | |
@InjectView(R.id.valuesAdded) TextView output; | |
private FireBaseWrapper fireBaseWrapper; | |
@Override public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
Views.inject(this); | |
fireBaseWrapper = new FireBaseWrapper(this, "http://browzine.firebaseio.com/testing"); | |
fireBaseWrapper.init(); | |
printNodeData(); | |
} | |
@OnClick(R.id.addButton) public void addValue() { | |
String key = this.key.getText().toString(); | |
String value = this.value.getText().toString(); | |
if(TextUtils.isEmpty(value)) { | |
return; | |
} | |
if(TextUtils.isEmpty(key)) { | |
fireBaseWrapper.push().setValue(value); | |
} else { | |
fireBaseWrapper.child(key).setValue(value); | |
} | |
this.key.setText(""); | |
this.value.setText(""); | |
printNodeData(); | |
} | |
@OnClick(R.id.reloadButton) public void printNodeData() { | |
output.setText(fireBaseWrapper.getNode().toString()); | |
} | |
@OnClick(R.id.clearAll) public void clearAllData() { | |
fireBaseWrapper.clearAllData(); | |
printNodeData(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment