use of com.android.volley.Response in project aplicativo by InCasa.
the class HomeActivity method getRele4.
public void getRele4(String URLGETRELE4) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLGETRELE4, null, new Response.Listener<JSONObject>() {
// Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
try {
Rele4.setIdRele(response.getInt("id"));
Rele4.setNome(response.getString("nome"));
Rele4.setDescricao(response.getString("descricao"));
Rele4.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 com.android.volley.Response in project aplicativo by InCasa.
the class HomeActivity method getArduino.
public void getArduino(String URLGETARDUINO) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLGETARDUINO, null, new Response.Listener<JSONObject>() {
// Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
Arduino arduino = Arduino.getInstancia();
// adiciona as informações no objeto arduino
try {
arduino.setIdArduino(response.getInt("id"));
arduino.setIp(response.getString("ip"));
arduino.setMac(response.getString("mac"));
arduino.setMask(response.getString("mask"));
arduino.setGateway(response.getString("gateway"));
arduino.setPorta(response.getString("porta"));
arduino.setPinoRele1(response.getString("PinoRele1"));
arduino.setPinoRele2(response.getString("PinoRele2"));
arduino.setPinoRele3(response.getString("PinoRele3"));
arduino.setPinoRele4(response.getString("PinoRele4"));
arduino.setPinoDHT22(response.getString("PinoDHT"));
arduino.setPinoLDR(response.getString("PinoLDR"));
arduino.setPinoPresenca(response.getString("PinoPresenca"));
} 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 com.android.volley.Response in project aplicativo by InCasa.
the class HomeActivity method getUser.
public void getUser(JSONObject json, String URLUSER) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.POST, URLUSER, json, new Response.Listener<JSONObject>() {
// Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
User user = User.getInstancia();
try {
user.setNome(response.getString("nome"));
user.setId(response.getString("id"));
} 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 com.android.volley.Response in project aplicativo by InCasa.
the class HomeActivity method getSensorPresenca.
public void getSensorPresenca(String URLGETTEMPERATURA) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLGETTEMPERATURA, null, new Response.Listener<JSONObject>() {
// Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
try {
Presenca presenca = Presenca.getInstancia();
presenca.setIdPresenca(response.getInt("id"));
presenca.setNome(response.getString("nome"));
presenca.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 com.android.volley.Response in project aplicativo by InCasa.
the class HomeActivity method getRele1.
public void getRele1(String URLGETRELE1) {
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URLGETRELE1, null, new Response.Listener<JSONObject>() {
// Em caso de sucesso
@Override
public void onResponse(JSONObject response) {
try {
Rele1.setIdRele(response.getInt("id"));
Rele1.setNome(response.getString("nome"));
Rele1.setDescricao(response.getString("descricao"));
Rele1.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);
}
Aggregations