Create a gist now

Instantly share code, notes, and snippets.

@JosephRoskopfOPI /sendData.kt Secret
Last active Aug 31, 2017

What would you like to do?
/**
* OnClick action for the send button
*/
private fun setupSendButton() {
mainActivitySendButton.setOnClickListener {
if (!mainActivityEditText.text.toString().isEmpty()){
sendData()
}else{
Toast.makeText(this, "Please enter a message", Toast.LENGTH_SHORT).show()
}
}
}
/**
* Send data to firebase
*/
private fun sendData(){
databaseReference?.
child("messages")?.
child(java.lang.String.valueOf(System.currentTimeMillis()))?.
setValue(Message(mainActivityEditText.text.toString()))
//clear the text
mainActivityEditText.setText("")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment