Thursday, November 3, 2016

Android Request Library

It is been a year since my last post, and  today I gonna share a code that related to Network Request.

Before I already share a tutorial how to Retrieve Data from Server and Local by using UrlConnection since the HttpGet & HttpPost already deprecated.

But for today, I gonna share how to use third party network request, like Ion and OkHttp.

Let's start from URLConnection, the class that added since API 1.

Snippet Code :



to using URLConnection you need to know the protocol of the url either it is 'HTTP' or 'HTTPS' because each protocol handle by different class (HttpURLConnection / HttpsURLConnection).
Below is the result using URLConnection,



Then we move to third-party library,

Ion, overall is a good library but if you open the issue tab on github, this library face many issue with SSL (HTTPS) protocol [Even I facing with that issue].

Snippet Code :



As you can see, by using ion library the code are shortest than previous code and you didn't need to handle the url like URLConnection does. This library integrate with GSON that allow you to set raw data and get the result in POJO and also have progress for download and upload file, cool right!

Now, the last library be discuss in this post is OkHttp.
I just started using this library last month, after I facing SSL issue with Ion library.
This library created by Square

Snippet Code :




the code still shortest than using URLConnection but not short as by using Ion. This library will throw exception if there have a body but using method such get that actually doesn't have body. But overall it also a good library.

To view full project code on github, please click on this link, RequestLibrary | GitHub
And below is the sample output for each technique I explained above.

URLConnection :




Ion :




 OkHttp :




Tuesday, February 9, 2016

Android Button Style like Bootstrap

Updated:



Now the library already available on JCenter and can be include this library into app.gradle dependencies

Gradle :
compile 'com.app.infideap.stylishwidget:stylish-widget:1.3.3'

Maven :
<dependency>
  <groupId>com.app.infideap.stylishwidget</groupId>
  <artifactId>stylish-widget</artifactId>
  <version>1.3.3</version>
  <type>pom</type>
</dependency>



Also can clone the code from Github.



Here I come,

It's be a long time since last time I wrote a post. Okay, for this post, I would like to share the Android resource file was I created during my previous project. This resource file I use as a style in Android interface and the UI look like bootstrap button. Here the example UI,



The available style in this resource file is :
  • Button.Default
  • Button.Primary
  • Button.Info
  • Button.Success
  • Button.Warning
  • Button.Danger
  • Button.Accent

How to use it :

Firstly, what you need to do is download this compress file,

After download it, extract the file and transfer it to your project /res folder.
Then, you already can use it.


let's say you have a button tag like this,
<Button 
android:width:"match_parent"
android:height:"wrap_content"
android:text:"Click Me" />

To use the style, just need add this line of code (android:style:"@style/<Style>") in the button tag like this,
<Button 
android:width:"match_parent"
android:height:"wrap_content"
android:text:"Click Me"
android:style:"@style/Button.Success" />

After adding the style, you can view it at the XML layout design or just run it. The button will look same like the success button below.



Before the end of the post, here I share the project code for above application, "Stylish Button" :
download




If you wanna discuss it, you may start post it at below comment box, and
If you have problem or something to ask that related to java...
you can email or comment on this post...
I will try to find the solution and share it with you..

Created By : Z-man, 2015

Thursday, December 10, 2015

Material Design : Coordinator Layout and Snackbar

Hi, this post only to say hello to CoordinatorLayout and Snackbar.

Whoever already upgrade or install Android Studio version 1.5, then you already aware that in generated Activity class and XML layout there have new thing like Coordinator layout and Snackbar.
The number of XML file generated also increased.