Social Share

Android Libraries - GSON,Picasso,Crouton,Butterknife,OkHttp,Dagger,slf4j,Joda-time,leanback,Otto,nine old android

Android Libraries to make Life easy


Android Libraries - GSON,Picasso,Crouton,Butterknife,OkHttp,Dagger,slf4j,Joda-time,leanback,Otto,nine old android


In android we have lot of libraries that are approved and recommended by the google and being the part of the android. In this document lets us walk through those libraries their uses, usage and benefits of using them.

Libraries:
The following are some of the libraries that are given in the Android Studio by default,

  1.        Mediarouter-v7
  2.         Leanback-v17      
  3.       GSON      
  4.       Joda-time      
  5.       Picasso      
  6.       Otto      
  7.       Slf4j      
  8.       Crouton      
  9.       Nine old Android  
  10.       Butterknife  
  11.       okHttp  
  12.       Dagger


Mediarouter-v7

Mediarouter-v7 supports for the casting the screen to the wireless displays like chrome cast and other supported wireless displays.

Example program link : 


Leanback-v17:

Leanback is provided by the android to support the development of the android apps for TV. Developing the apps for TV cannot be done as same as tablet apps. It has its own special elements like display fragments etc.. All support for that elements are provided by the Leanback.

Example program link:



GSON:

In this age, the data sent from the server are all sent in the form of the JSON. To parse the JSON we normally used to write the JSON parser and parse the response. Instead of writing pages of lines for parsing we have the simplified process by GSON library. Just create the models with fields same as the JSON string and the object will be parsed automatically by the GSON.

Example link:


Joda-Time:

To handle date and time calculations in java is little bit complicated. Also maintaining the local time of each and every region has to be maintained in the java. This is made easier in the Joda-time library. Just create the DateTime type and call the respective methods to add the days, hours, months...etc. or to  subtract and can find lot of interesting features in this with date and time.

DateTime today = new DateTime();
DateTime tomorrow = today.plusDays(1);
System.out.println(today.toString(“yyyy-MMM-dd”));     System.out.println(tomorrow.toString(“yyyy-MMM-dd”));

Gives
2013-Jul-14
2013-Jul-15

DateTime firstOfTheMonth = today.withDayOfMonth(1); System.out.println(today.toString(“yyyy-MMM-dd”)); System.out.println(firstOfTheMonth.toString(“yyyy-MMM-dd”));
Gives
2013-Jul-14
2013-Jul-01

Find more at 


Picasso:
Picasso library is used for managing the images. It automatically loads the image from the url either its is a http or ftp or file uri into the view directly. It automatically takes care of the cache and loads from the cache until the images url changes for the particular view. It asynchronously fetch the image from the internet if any http ftp url is provided. We don’t need to provide the aynctask to load the image separately.
The usage syntax is like.
Picasso.with(context).load(“URI”).into(View);

Additional links for the Picasso


Otto:
Otto is library is a provision for data transfer or communication by raising the events. In this framework the common bus is maintained and the classes will be registered to the bus. The methods that are annotated with the @publish will generate the event and the methods of the classes that are annotated with @subscribe will receive the event with the expected parameter that re sent on raising the events and the rest of the event handling will be done by the subscribed methods.
Links for the Otto
Slf4j:

Slf4j replaces the boring Log component of the android. Just create the instance of the slf4j in each class and call that instance and provide the message. The tag for the message and writing to the SD card will be automatically handled by the library.

// SLF4J
Logger LOG = LoggerFactory.getLogger(MainActivity.class);
LOG.info("hello world");


Links for slf4j:



Crouton:

We know that we usually show the information to the user with the help of the dialog or the toast. The toast may be sometimes annoying and will be of only of predefined time. Also even if the view is closed then also it will be displayed. The better way is to use the crouton. The best example for the crouton is that the Facebook messenger app shows the error connecting to network in the red ribbon on top of the button or connected in green. These are the croutons. Crouton by default comes with the green for success message, red for error and the orange for the warning.

Links to explore.


Nine Old Android:

The nine old android is the complete library to provide the set of animations for the older version android OS like honey comb.

ButterKnife:

The butternife library is used for injecting the views at the run time. Just by giving the annotations the fields and the views are mapped at the runtime easily.

Example:

@inject(R.id.imageView)
ImageView mImageView;

@onclickListener(R.id.button)
Public void setAction()
{
}

Links to explore:


  

okHttp:

OkHttp is recommended library by the android to handle the http request response along with the get post and ssl support in the android kitkat and above.

Links to explore:


Dagger:

Same as Butterknife but this is used for binding the dependency for modules and other classes.

Links to explore:





Hope you enjoyed..... Happy reading..!!!!

Comments

Latest Technology Videos

Popular posts