Assalmaualaikum
Since I work as a Software engineer,So I think I should talk a little bit more about my job in this blog.
Previously In Android apps development I create HttpClient class,exception,Lost connection handling , create callback all by myself .
This pass few days I found one library that catches my eyes which is Ion Library.It handle everything for us.We just need to import it into our app gradle.
compile 'com.koushikdutta.ion:ion:2.+'
Example:
JsonObject json = new JsonObject(); json.addProperty(Constants.FULLNAME, fullName); json.addProperty(Constants.EMAIL, email); json.addProperty(Constants.FIRST_NAME, firstName); json.addProperty(Constants.LAST_NAME, lastName); json.addProperty(Constants.GENDER, ""); json.addProperty(Constants.DOB, ""); json.addProperty(Constants.FIREBASE_UID, firebaseId); Ion.with(getApplicationContext()) .load("API url") .setJsonObjectBody(json) .asJsonObject() .setCallback(new FutureCallback<JsonObject>() { @Override public void onCompleted(Exception e, JsonObject result) { runOnUiThread(new Runnable() { @Override public void run() { progress.dismiss(); } }); if (e != null) { Toast.makeText(getBaseContext(), "Data : " + e.getStackTrace(),
Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplicationContext(), "Registered successfully",
Toast.LENGTH_LONG).show();
}
}
});
Easy peasy huh?
Anyway Thanks Koush for this wonderful library!
No comments:
Post a Comment