Use Of Esty Android Staggered Grid View with Picasso Image Loader.

USE OF ESTY ANDROID STAGGERED 

GRID VIEW


Here I've written the solution for Esty Android Staggered Grid View.

WARNING: FIRST TRY THIS SOLUTION ON DEMO PROJECT THEN ONLY IMPLEMENT ON YOUR OWN PROJECT.
-------------------------------------------------------------------------------------------
  > I found this solution to achieve Etsy StaggeredGridView in my project.

When You try to implement Etsy library into your project, you'll get errors like,

Error 1> "item_margin" cannot find the resources...
Error 2> "column_count" cannot find the resources...
Error 3> Class not Found Exception ...
Error 4> R. file not Found
Error 1> xlmns:app: -------/res-auto error
Error 5> error importing Etsy..
Error 6> while working with Universal image loader 
Error 7> Picasso ..
ERROR 8> unable to resolve resources file 
Error 9> HTTP proxy......

and many more errors....


OMGGGGGGG!!!! I'm Just frustrated.... But Give Up is not in my dictionary...

and Finally The solution is here ...


>First Checkout My working configuration and if it matches with yours then u can think to use this solution.

I'm Using Android Studio 1.3.1
JRE 1.7.0
and Gradle Files.

For Eclipse people and Dont really know the solution you can search it over the internet.



>>Refer following articles

 a. "Techno Talkative: Be a lazy but a productive android developer – Part 6 – Staggered GridView" 

b. Or Rahul Jiresal:Pinterest Style Layout on Android


 > Although there are no errors in above two article,

   just some steps are missing.but it has worked for some people 
   not for me so I'm here with this solution.


======================THE SOLUTION =========

---------------------------------Importing and SetUP Esty--------------


 There Are Three Ways to import Esty lib,First and Second You'll find here,
 and extreme solution when nothing is working then you can try this one.


 NOTE: REMEMBER YOU DONT NEED TO ADD ANYTHING IN YOUR GRADLE FILES FOR THE FOLLOWING SOLUTION.


 EXTREME SOLUTION:

 ----------------
 1. Copying Esty files into your project.
There are 6 java files and 1 attr.xml in esty library.
A. Copy grid folder inside your app folder. for example 

AndroidStaggeredGrid-master is the name of the esty project for StaggeredGridView                   when you download it as zip.
Copy > F:\Softwares\MySupportedLiabrary\AndroidStaggeredGrid-master\library\src\main\java\com\etsy\android\grid
Paste> F:\Users\VJ007\AndroidStudioProjects\MyExample2\app\src\main\java\example\myexample2\grid

so you'll see all these files inside your project.


 2. Now Move DynamicIMageView.java and DynamicTextView.java in same grid folder and Delete util folder.

 3. open all these java file indide grid folder.
Rename Package name of Esty with Your Project's package name on the header of all the java file.
for example. 
older package Name: com.etsy.android.grid.library;
newer package name: package example.myexample2;

 4. Move attr.xml from "AndroidStaggeredGrid-master\library\src\main\res\values" 
inside your values folder.

 5. To remove errors that you are getting in your java files in grid folder,
go to each line and press alt+Enter and it will fix it.

 6. R not found:One More Error At StaggeredGridView.Java for this, import R file 

example: "import example.myexample3.R;"




 7. YOU HAVE SUCCESSFULLY IMPORTED ESTY LIBRARY***


------------------------------------------------------------------------------------------
IMPLEMENTATION OF ESTY LIBRARY:
------------------------------------------------------------------------------------------

 1. Follow the steps in one of these tutorial. DO as it is written there we will correct it later.

a. "TechnoTalkative: Be a lazy but a productive android developer – Part 6 – Staggered GridView" 

OR

b."Rahul Jiresal Pinterest Style Layout on Android


 2.Do not Add mevanCentral() or Compile dependencies in your gradle file system.

 -------------------------------Correction For TechnoTalkative-------------------------------

 1. In step 2 of Techno talkative tutorial you included 

 <com.etsy.android.grid.StaggeredGridView....> in your main layout file.
 change it with <example.myexample3.grid.StaggeredGridView ...> which is your package name 
 and  also change app:column_count="2" .





 2. In step 3 of Techno talkative tutorial You are creating Custom row 
<com.etsy.android.grid.util.DynamicHeightImageView...>
change it with <example.myexample3.grid.DynamicHeightImageView ...>




 3. In step 4 of Techno talkative tutorial You are creating 

SampleAdapter.java simply just copying the code 


 4. In step 5 of Techno talkative tutorial you will create StaggeredGridview Activity 

which is MainActivity in my case. just copy all code and extend it with AppCompat,
u'll get errors but dont worry we'll fix it..

a. First remove "import com.etsy.android.grid.StaggeredGridView;"
b. Go to other errors and press alt+enter to import classes.
c. change setContentView(R.layout.activity_sgv); To setContentView(R.layout.activity_main);
d. In SampleAdpter.java class change "convertView = mLayoutInflater.inflate(R.layout.row_grid_item,..)"
with convertView = mLayoutInflater.inflate(R.layout.custom_row,..)" because my layout name is custom_row nothing else.
f. Still It May be showing error at "ImageLoader", this is "UniversalImageLoader" Part, 
it is not working properly for me so i decided to use "picasso".you can use it if it works for you.





 5. ALL THE SETUP RELATED TO STAGGERED GRID VIEW IS COMPLETE BUT NOW YOU NEED TO SETUP IMAGE LOADER AND SO FOR THAT HAVE TO CHANGE "UniversalImageLoader" To "Picasso.jar"




------------------------------------------ESTY SETUP COMPLETED----------------------------------------

==================SETTING IMAGE LOADER(Picasso.jar)========================


 Note: Do not Edit Anything in your gradle file.

 1. simply copy picasso.jar into libs folder and so it should look like this 
F:\Users\VJ007\AndroidStudioProjects\MyExample3\app\libs\picasso-2.5.2.jar

 2. syncgradle files: Tools>Android >Sync gradle file

 3. In SampleAdapter class Remove This code,
ImageLoader.getInstance().displayImage(getItem(position), vh.imgView);
insted add this,
Picasso.with(getContext()).load(R.drawable.img).into(vh.imgView);
here R.Drawable.img is simplly a resources drawable.




 4. Rounded corners for images(Rahul Jiresal):Copy and paste this code into your DynamicImageView.java

public static float radius = 2.0f;
Path clipPath = new Path();
RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight());
 
@Override
protected void onDraw(Canvas canvas) {
rect.left = 0;
rect.top = 0;
rect.right = this.getWidth();
rect.bottom = this.getHeight();
clipPath.addRoundRect(rect, radius, radius, Path.Direction.CW);
canvas.clipPath(clipPath);
super.onDraw(canvas);


 5. Now You can Run the app. And it will work ...





 =====================Rahul Jiresal=================

 1. Follow all the steps he has given in his article.

 2. SetUp For Etsy AndroidStaggeredGrid library is same as i'VE given above.

 3. In Step 2 of Rahul's article you copied MainActivity.java and activity_main.xml
Change in your main.xml <com.etsy.android.grid.StaggeredGridView> to 
<example.myexample4.grid.StaggeredGridView...> AND Column_count = 2

 4. In step 3 Rahul's article you created Data and DataAdapter Class. In that Change 
Activity to AppCompatActivity and press alt + enter for each error line to import classes.

 5. In step 3 second part of Rahul's article, adding method to mainActivity make change at 

<example.myexample4.grid.DynamicHeightImageView..> and 
SAMPLE_DATA_ITEM_COUNT as much you want i kept it as 20;


 6. In Step 4 of Rahul's article, need same change as we did in above step 3(our).

7. step 6 and 7 of Rahul's article are simple.

 8. In step 8 of Rahul's article, adding picasso.jar is given above.

 9. Import R file in StaggeredGridView.java like in my project it is like this,

"import example.myexample4.R;"


 10.And Thats it. it is working. If This one is not working for you tell me or try solution no. One for TechnoTalkative.





Comments

Popular posts from this blog

Failed to sync Gradle project 'MyApp' Error:Unknown host 'services.gradle.org'.

Using Roboto font android

Windows 10 Slow Performance issue fixed !!!