Skip to main content

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

Popular posts from this blog

How to access the each view of item by position in Recycler View in android ?

How to access the each view of item by position in Recycler View in android ? There are some methods to access the view of each item view to change or update the view during the run time. To access the view of the item view , consider the Recycler view as below, RecyclerView mainRecyclerView = (RecyclerView)view.findViewById(R.id.main_recycler_view); RecyclerAdapter adapter = new RecyclerAdapter(mContext); mainRecyclerView.setAdapter(adapter); main.setLayoutManager(new LinearLayoutManager(mContext));  To access the itemView of each position the following functions can be used,  1. View itemView = mainRecyclerView.getChildAt(positionOfItem);  2. View itemView = mainRecyclerView.findViewHolderForAdapterPosition(Position).itemView;  3. View itemView = mainRecyclerView.findViewHolderForPosition(Position).itemView;  4. Long itemId = mainRecyclerView.getAdapter().getItemId(position);       View itemView = mainRecyclerView....

A.P.I call or async await not working in Array forEach ?

H ello Readers, Welcome back. You would have wondered why does forEach function on the array does not wait for any asynchronous function even if we provide the async await in the node js. If you are the person, wondered about this ever, this post is right for you. Non working example : Lets consider the below snippet, this will not wait for the asynchronous process to wait. I am making a setTimeout to mock the API call async process. This will result the count as, Output : count = 0 OMG !! Why it doesn't work ? Answer probably might be lying inside the Array prototype from JavaScript. Lets take a look inside the "Array.prototype.forEach" function. From the snippet its clear that, the for loop in which they call the callback function does not wait for the asynchronous process to run in the callback. So this forEach is not build for asynchronous process itself. So can't I use forEach any more for running a asynchronous function ? Answer g...

How Machine Learning Works ? - Data Rules the Kingdom

W elcome Back Readers !, For those who have not read the previous post on How Machine Learning works ? Please do read previous one before continuing this so that it would be more easy to understand. You can find the previous post here How Machine Learning Works ? - Mathematics Every Where . For other who are ready to join with me in this journey to understand the Machine Learning, Thank you for being with this post. Till now we are discussing on the the title "How Machine Learning works? " and to understand that we have seen in the first post that there exist the patterns or trends in the data and we try to find that in terms of a mathematical equation called a model and try to fit to the new data that we have not came across for predicting the values. Wow may be we got the entire process complete with this. But there are few thinks that needs to be cared while training the model or creating the model or while processing the data for the model creation. ...