0

I have on vertical Recyclerview and inside each row one horizontal Recyclerview. I am using this structure for category product listing.

now there is one API (Lets say API-1) which is giving me list of category, and i am getting category id in that api (API-1),

From that categoryid i have to call another API (Lets say API-2) which will give me product list, and that product list will be displayed in horizontal ListView.

Now this API-2 is having pagination, so after displaying 10 product i have to call api again for more products.

and for that i m gonna need category id once again. so im not able to find the category id when i'm scrolling horizontal Recyclerview, the position of vertical Recyclerviewis have the category id i want to use.

so is there any solution?

Ajeet Choudhary
  • 1,969
  • 1
  • 17
  • 41
  • Store variable in the horizontal array data, that will indicate current category id. You can setup this after loading category list. Also it will be nice to see part of your code – A.Grz Jun 29 '17 at 13:32

1 Answers1

0

One way to achieve this is to hold a map of Integer -> String and store each category with it's position when the view is being created inside the adapter.

Later, query the map to get the right CategoryId by position.

Yossi Segev
  • 607
  • 5
  • 12