Notifiy my RecyclerView that data has changed

94
May 30, 2021, at 08:40 AM

I am developing an shop app in android and got a question about transfering data between two adapterclasses. This is the scenario:

I have two AdapterClasses to handle two separate RecyclerViews in two separate Activities. In the first Acticity I got a RecyclerView which shows items of a shop. You can click on an item. If so, the items are added to the basket. The items in the basket are saved in an arraylist.

In the second RecyclerView the items in the basket should be shown. This recyclerView is handeled by the basketAdapterClass. From the basketAdapterClass I have to get access to the arraylist, which is implemented in the ShopAdapterClass.

How can I access the arraylist from the ShopAdapterClass in the BasketAdapterClass?

I read about the observerpattern, about passing objects from one class to another but I am not sure what the best way would be? Can you give me some tipps how to solve this problem? Do you need further information to solve the problem?

Thanks for answers!

READ ALSO
Add animation to React Slider

Add animation to React Slider

I have a very simple react sliderThere's an option to navigation between the slides

77
Mysql like query suggest best indexes for fast response

Mysql like query suggest best indexes for fast response

My query takes 90sec for return only 20 rowsQuery has some join and like query for searching keywords

54
SendGrid API is grouping tables together

SendGrid API is grouping tables together

When trying to send an email using sendgrid it is grouping tables togetherThis is how I want the email to look

29
My application icons are intertwined with phone icons

My application icons are intertwined with phone icons

My application icons are intertwined with phone iconsWhat is the solution?

55