use of com.android.volley.Response in project easy by MehdiBenmesa.
the class AbsenceService method getSeanceByTeacher.
public void getSeanceByTeacher(final IAbsence callBack) throws JSONException {
CustomRequest jsonReq = new CustomRequest(Request.Method.GET, GET_TIME_TABLE_TEACHER + "/" + App.getInstance().getUser().getString("_id"), null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
callBack.onDataReceived(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
App.getInstance().addToRequestQueue(jsonReq);
}
use of com.android.volley.Response in project easy by MehdiBenmesa.
the class TimeLineActivity method setDataListItemsStudent.
public void setDataListItemsStudent(final Itimeline callback) {
try {
CustomRequest jsonReq = new CustomRequest(Request.Method.GET, GET_TIME_TABLE_STUDENT + "/" + user.getString("section") + "/" + user.getString("groupe"), null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
callback.onDataRecieved(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
App.getInstance().addToRequestQueue(jsonReq);
} catch (JSONException e) {
e.printStackTrace();
}
}
use of com.android.volley.Response in project easy by MehdiBenmesa.
the class StartActivity method handleSignInResult.
// [END onActivityResult]
//1D:80:89:02:65:1A:38:03:60:08:D1:38:24:EA:CA:C0:F9:59:48:AC
// [START handleSignInResult]
private void handleSignInResult(GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
GoogleSignInAccount acct = result.getSignInAccount();
updateUI(true);
App.getInstance().setAccessToken(acct.getIdToken());
App.getInstance().setEmail(acct.getEmail());
if (acct.getEmail().substring(acct.getEmail().length() - 6, acct.getEmail().length()).equals("esi.dz")) {
CustomRequest jsonReq = new CustomRequest(Request.Method.POST, APP_LOGIN, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONObject user = response.getJSONObject("user");
Log.i(TAG, "Signed in as: " + user.getString("name"));
//JSONArray resp = responseBody.to;
if (user.getString("mail").equals(App.getInstance().getEmail())) {
startUserActivity(user);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
hidepDialog();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("email", App.getInstance().getEmail());
params.put("idToken", App.getInstance().getAccessToken());
return params;
}
};
App.getInstance().addToRequestQueue(jsonReq);
} else {
String msg = "c'est pas un compte ESI ";
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}
} else {
// Signed out, show unauthenticated UI.
updateUI(false);
}
}
use of com.android.volley.Response in project saga-android by AnandChowdhary.
the class Updater method checkForUpdates.
public static void checkForUpdates(final Context context, boolean visibility) {
final int versionCode = getVersionCode(context);
final ProgressDialog progressDialog = new ProgressDialog(context);
String updateUrl = "https://www.dropbox.com/s/bka9o3p43oki217/saga.json?raw=1";
if (visibility) {
progressDialog.setTitle(context.getString(R.string.update));
progressDialog.setMessage(context.getString(R.string.update_checking));
progressDialog.setCancelable(true);
progressDialog.show();
}
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, updateUrl, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
int updateVersionCode = response.getInt("versionCode");
if (updateVersionCode > versionCode && versionCode != 0) {
if (progressDialog.isShowing()) {
progressDialog.cancel();
}
final String apkUrl = response.getString("apkUrl");
String changelog = response.getString("changelog");
AlertDialog dialog = new AlertDialog.Builder(context).setTitle(context.getString(R.string.new_update)).setMessage(changelog).setPositiveButton(context.getString(R.string.update_now), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
File myFile = new File(Utils.getStoragePath(context), "update.apk");
if (myFile.exists())
myFile.delete();
Uri uri = Uri.parse(apkUrl);
DownloadManager dMgr = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request dr = new DownloadManager.Request(uri);
String filename = "update.apk";
dr.setTitle(context.getString(R.string.app_name) + " " + context.getString(R.string.update));
dr.setDestinationUri(Uri.fromFile(new File(Utils.getStoragePath(context) + "/" + filename)));
// dr.setDestinationInExternalPublicDir("/Saga/", filename);
dMgr.enqueue(dr);
}
}).setNegativeButton(context.getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).setCancelable(false).create();
dialog.show();
} else {
if (progressDialog.isShowing()) {
progressDialog.cancel();
Toast.makeText(context, context.getString(R.string.no_update), Toast.LENGTH_SHORT).show();
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (progressDialog.isShowing()) {
progressDialog.cancel();
Toast.makeText(context, context.getString(R.string.error_connect), Toast.LENGTH_SHORT).show();
}
}
});
request.setShouldCache(false);
VolleySingleton.getInstance(context).getRequestQueue().add(request);
}
use of com.android.volley.Response in project saga-android by AnandChowdhary.
the class MusicDownloader method getSongInfo.
private static void getSongInfo(final Context context, final String filename, final String songName, final String artistName) {
String url = "http://162.243.144.151/everything.php?q=";
url += artistName == null ? filename.replace(" ", "%20") : songName.replace(" ", "%20");
StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
if (artistName != null) {
try {
JSONObject jsonObject = new JSONObject(response);
jsonObject.put("track", songName);
jsonObject.put("artist", artistName);
Utils.saveSongInfo(context, filename, jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Utils.saveSongInfo(context, filename, response);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("Music download", "Error: " + error.toString());
if (artistName != null) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("track", songName);
jsonObject.put("artist", artistName);
Utils.saveSongInfo(context, filename, jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
request.setShouldCache(false);
VolleySingleton.getInstance(context).getRequestQueue().add(request);
}
Aggregations