Skip to content

Instantly share code, notes, and snippets.

@sidishere
Created December 24, 2019 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidishere/52dff6533ddc544fa2fff3af36789274 to your computer and use it in GitHub Desktop.
Save sidishere/52dff6533ddc544fa2fff3af36789274 to your computer and use it in GitHub Desktop.
smartAC.addValueEventListener(new ValueEventListener() {
boolean firstTime=true;
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
String value = dataSnapshot.getValue(String.class);
textView1.setText("smartAC " + value);
if(firstTime) {
if (value.equals( "ON")) {
s4.setChecked(true);               
s1.setChecked(true);
firstTime = false;
} else {
s1.setChecked(false);
firstTime = false;
    }
   }
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w("file", "Failed to read value.", error.toException());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment