package com.linseykate.findingfido; /** * Activity that records saved settings * for logged in user */ import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.CompoundButton; import android.widget.Switch; import com.firebase.client.Firebase; public class SettingsActivity extends AppCompatActivity { Firebase ref = new Firebase("https://findingfido.firebaseio.com/"); //determine if switch is on or not boolean matchOn = false; boolean locationOn = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Button btnSave = (Button)findViewById(R.id.btnSave); Button btnCancel = (Button)findViewById(R.id.btnCancel); Switch switchMatch = (Switch)findViewById(R.id.switchDog); Switch switchLocation = (Switch)findViewById(R.id.switchLocation); btnSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //Update user record Firebase userRef = ref.child(ref.getAuth().getUid()); userRef.child("dogMatched").setValue(matchOn); userRef.child("locationCheck").setValue(locationOn); //userRef.child("notifications").setValue(((GlobalVariables) getApplication()).getNotifications()); finish(); //Return to MainActivity } }); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); //Return to MainActivity } }); switchMatch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { matchOn = b; } }); switchLocation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { locationOn = b; } }); } }