Picasso


 

  1. Local Image
  2. Remote Image
  3. Extras
  4. CallBack
  5. Transformation
  6. Priority
  7. Saving Image
  8. LazyLoading using Picasso

 

Steps to do before:

  1. Download the latest version of Picasso library ( jar file ) from here.
  2. For Eclipse: Copy the downloaded library file to “libs” directory of the project. Right click on jar file -> Build Path -> Add to Build path.
    For Android Studio: Copy the downloaded library file to “libs” directory of the project structure and add compile files(‘libs/your lib name here’) is in your build.gradle or
    compile 'com.squareup.picasso:picasso:2.5.2'
  3. you can also download from here.

 

1. Local Image

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

picasso_localimage

Download SourceCode

 

2. Remote Image

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

picasso_remoteimage picasso_remoteimage2

Download SourceCode

 

3. Extras

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

picasso_extras picasso_extras2 picasso_extras3

Download SourceCode

 

4. CallBack

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

picasso_callback picasso_callback2

Download SourceCode

 

5. Transformation

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

picasso_transform picasso_transform2

Download SourceCode

 

6. Priority

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

picasso_priority picasso_priority2 picasso_priority3

Download SourceCode

 

 

7. Saving Image

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

picasso_saveimage picasso_saveimage2 picasso_saveimage3 picasso_saveimage4

Download SourceCode

 

 

8. LazyLoading using Picasso

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml, list_item.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open src -> package -> Create new class MyCustomAdapter.java and add following code :

Step 6 : Open src -> package -> Create new class MyJsonParser.java and add following code :

Step 7 : Open src -> package -> Create new class NumberHelper.java and add following code :

Step 8 : Open src -> package -> Create new class MyHttpURLConnection.java and add following code :

Step 9 : Open AndroidManifest.xml and add following code :

ScreenShot:

picasso_adapter picasso_adapter2 picasso_adapter3

Download SourceCode