use of android.widget.Switch in project aplicativo by InCasa.
the class AlarmeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarme);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
final Switch AlarmeSwitch = (Switch) findViewById(R.id.switchAlarme);
SharedPreferences mSharedPreferences = getSharedPreferences("ServerAdress", 0);
this.ip = mSharedPreferences.getString("servidor", " ");
if (getAlarme() != false) {
AlarmeSwitch.setChecked(true);
}
final String URLPRESENCA = "http://" + ip + "/backend/presencaValorNow";
// Thread para checar se o modo alarme esta ativo a cada 3seg
timer = new Timer();
AlarmeThread = new TimerTask() {
public void run() {
getPresenca(URLPRESENCA);
// checa se há presença e se o modo alarme esta ativo.
if (ativo == true && getAlarme() == true) {
// chama a notificação
Notificacao();
}
}
};
timer.schedule(AlarmeThread, 0, 3000);
Alerta = new NotificationCompat.Builder(this);
AlarmeSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (getAlarme() == true) {
saveAlarme(false);
} else {
saveAlarme(true);
}
}
});
}
use of android.widget.Switch in project aplicativo by InCasa.
the class ReleActivity method getRele1.
public void getRele1(String URLRELE1) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLRELE1, null, new Response.Listener<JSONObject>() {
// Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
String temp = "";
try {
Switch rele1 = (Switch) findViewById(R.id.switch1);
temp = response.getString("valor");
if (temp.equals("0")) {
rele1.setChecked(false);
estado1 = false;
} else {
rele1.setChecked(true);
estado1 = true;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
// Em caso de erro
@Override
public void onErrorResponse(VolleyError error) {
Context context = getApplicationContext();
CharSequence text = "Erro na requisição";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<String, String>();
// add headers <key,value>
User user = User.getInstancia();
String auth = new String(Base64.encode((user.getLogin() + ":" + user.getSenha()).getBytes(), Base64.DEFAULT));
headers.put("Authorization ", " Basic " + auth);
return headers;
}
};
// fila de requisições
RequestQueue fila = Volley.newRequestQueue(this);
// Adiciona a requisição á fila de requisições
fila.add(req);
}
use of android.widget.Switch in project aplicativo by InCasa.
the class ReleActivity method getRele4.
public void getRele4(String URLRELE4) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLRELE4, null, new Response.Listener<JSONObject>() {
// Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
String temp = "";
try {
Switch rele4 = (Switch) findViewById(R.id.switch4);
temp = response.getString("valor");
if (temp.equals("0")) {
rele4.setChecked(false);
estado4 = false;
} else {
rele4.setChecked(true);
estado4 = true;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
// Em caso de erro
@Override
public void onErrorResponse(VolleyError error) {
Context context = getApplicationContext();
CharSequence text = "Erro na requisição";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<String, String>();
// add headers <key,value>
User user = User.getInstancia();
String auth = new String(Base64.encode((user.getLogin() + ":" + user.getSenha()).getBytes(), Base64.DEFAULT));
headers.put("Authorization ", " Basic " + auth);
return headers;
}
};
// fila de requisições
RequestQueue fila = Volley.newRequestQueue(this);
// Adiciona a requisição á fila de requisições
fila.add(req);
}
use of android.widget.Switch in project aplicativo by InCasa.
the class ReleActivity method getRele3.
public void getRele3(String URLRELE3) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLRELE3, null, new Response.Listener<JSONObject>() {
// Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
String temp = "";
try {
Switch rele3 = (Switch) findViewById(R.id.switch3);
temp = response.getString("valor");
if (temp.equals("0")) {
rele3.setChecked(false);
estado3 = false;
} else {
rele3.setChecked(true);
estado3 = true;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
// Em caso de erro
@Override
public void onErrorResponse(VolleyError error) {
Context context = getApplicationContext();
CharSequence text = "Erro na requisição";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<String, String>();
// add headers <key,value>
User user = User.getInstancia();
String auth = new String(Base64.encode((user.getLogin() + ":" + user.getSenha()).getBytes(), Base64.DEFAULT));
headers.put("Authorization ", " Basic " + auth);
return headers;
}
};
// fila de requisições
RequestQueue fila = Volley.newRequestQueue(this);
// Adiciona a requisição á fila de requisições
fila.add(req);
}
use of android.widget.Switch in project facebook-android-sdk by facebook.
the class AccountKitLoginActivity method createAccountKitConfiguration.
private AccountKitConfiguration.AccountKitConfigurationBuilder createAccountKitConfiguration(final LoginType loginType) {
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = new AccountKitConfiguration.AccountKitConfigurationBuilder(loginType, getResponseType());
final Switch titleTypeSwitch = (Switch) findViewById(R.id.title_type_switch);
final Switch stateParamSwitch = (Switch) findViewById(R.id.state_param_switch);
final Switch facebookNotificationsSwitch = (Switch) findViewById(R.id.facebook_notification_switch);
final Switch useManualWhiteListBlacklist = (Switch) findViewById(R.id.whitelist_blacklist_switch);
final Switch readPhoneStateSwitch = (Switch) findViewById(R.id.read_phone_state_switch);
final Switch receiveSMS = (Switch) findViewById(R.id.receive_sms_switch);
if (titleTypeSwitch != null && titleTypeSwitch.isChecked()) {
configurationBuilder.setTitleType(AccountKitActivity.TitleType.APP_NAME);
}
final UIManager uiManager;
if (advancedUISwitch != null && advancedUISwitch.isChecked()) {
if (isReverbThemeSelected()) {
if (switchLoginTypeReceiver == null) {
switchLoginTypeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
final String loginTypeString = intent.getStringExtra(ReverbUIManager.LOGIN_TYPE_EXTRA);
if (loginTypeString == null) {
return;
}
final LoginType loginType = LoginType.valueOf(loginTypeString);
onLogin(loginType);
}
};
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(switchLoginTypeReceiver, new IntentFilter(ReverbUIManager.SWITCH_LOGIN_TYPE_EVENT));
}
uiManager = new ReverbUIManager(confirmButton, entryButton, loginType, textPosition, selectedThemeId);
} else {
uiManager = new AccountKitSampleAdvancedUIManager(confirmButton, entryButton, textPosition, loginType);
}
} else if (isSkinSelected()) {
@ColorInt final int primaryColor = ContextCompat.getColor(this, R.color.default_color);
if (getBackgroundImage() >= 0) {
uiManager = new SkinManager(loginType, skin, primaryColor, getBackgroundImage(), getSkinTintOption(), getSkinBackgroundTintIntensity());
} else {
uiManager = new SkinManager(loginType, skin, primaryColor);
}
} else {
uiManager = new ThemeUIManager(loginType, selectedThemeId);
}
configurationBuilder.setUIManager(uiManager);
if (stateParamSwitch != null && stateParamSwitch.isChecked()) {
initialStateParam = UUID.randomUUID().toString();
configurationBuilder.setInitialAuthState(initialStateParam);
}
if (facebookNotificationsSwitch != null && !facebookNotificationsSwitch.isChecked()) {
configurationBuilder.setFacebookNotificationsEnabled(false);
}
if (useManualWhiteListBlacklist != null && useManualWhiteListBlacklist.isChecked()) {
final String[] blackList = getResources().getStringArray(R.array.blacklistedSmsCountryCodes);
final String[] whiteList = getResources().getStringArray(R.array.whitelistedSmsCountryCodes);
configurationBuilder.setSMSBlacklist(blackList);
configurationBuilder.setSMSWhitelist(whiteList);
}
if (readPhoneStateSwitch != null && !(readPhoneStateSwitch.isChecked())) {
configurationBuilder.setReadPhoneStateEnabled(false);
}
if (receiveSMS != null && !receiveSMS.isChecked()) {
configurationBuilder.setReceiveSMS(false);
}
return configurationBuilder;
}
Aggregations