use of Model.User in project aplicativo by InCasa.
the class HomeActivity method getRele2.
public void getRele2(String URLGETRELE2) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLGETRELE2, null, new Response.Listener<JSONObject>() {
//Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
try {
Rele2.setIdRele(response.getInt("id"));
Rele2.setNome(response.getString("nome"));
Rele2.setDescricao(response.getString("descricao"));
Rele2.setPorta(response.getInt("porta"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
//Em caso de erro
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@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 Model.User in project aplicativo by InCasa.
the class HomeActivity method getRele3.
public void getRele3(String URLGETRELE3) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLGETRELE3, null, new Response.Listener<JSONObject>() {
//Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
try {
Rele3.setIdRele(response.getInt("id"));
Rele3.setNome(response.getString("nome"));
Rele3.setDescricao(response.getString("descricao"));
Rele3.setPorta(response.getInt("porta"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
//Em caso de erro
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@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 Model.User in project aplicativo by InCasa.
the class HomeActivity method getCelular.
public void getCelular(String URLGETCELULAR) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLGETCELULAR, null, new Response.Listener<JSONObject>() {
//Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
try {
Aplicativo app = Aplicativo.getInstancia();
app.setIdAplicativo(response.getInt("id"));
app.setNome(response.getString("nome"));
app.setMac(response.getString("mac"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
//Em caso de erro
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@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 Model.User in project aplicativo by InCasa.
the class HomeActivity method getSensorUmidade.
public void getSensorUmidade(String URLGETUMIDADE) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLGETUMIDADE, null, new Response.Listener<JSONObject>() {
//Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
try {
Umidade umi = Umidade.getInstancia();
umi.setIdUmidade(response.getInt("id"));
umi.setNome(response.getString("nome"));
umi.setDescricao(response.getString("descricao"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
//Em caso de erro
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@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 Model.User in project aplicativo by InCasa.
the class SensorActivity method getTemperatura.
public void getTemperatura(String URLTEMPERATURA) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLTEMPERATURA, null, new Response.Listener<JSONObject>() {
//Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
String temp = "";
try {
TextView txtTemp = (TextView) findViewById(R.id.txtTemp);
temp = response.getString("valor");
if (temp.equals("null")) {
txtTemp.setText("N/A");
} else {
temp = temp + " ºC";
txtTemp.setText(temp);
}
} 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);
}
Aggregations