I'm developing an Android app. I have this domain class:
public class Film implements Parcelable {
private List<FavChangesListener> listeners;
//more members
}
I'm showing a films list and each item has a button to mark/unmark a film as favorite. Another components in the app listen to this fav status change.
public interface FavChangesListener {
void onFavChanged(Film film);
}
When you tap on a film, another activity is shown with that film's detail. Once inside the detail activity, you also can mark/unmark the film as favorite and the listeners have to be notified, same as before.
So far, so good. Problem is that I'm passing the film between the list activity and the detail activity using an extra: my Film
class implements Parcelable
. So the listeners list is null (or empty) when the film is deserialized in detail activity.
-
Should I use another way to pass the film between activities instead of extra+Parcelable solution? Like using a third component to set/get the film.
-
Should I make the listener implements Parcelable and serialize the list inside the extra? (I'm sure not)
-
Is it a good idea in this case to have listeners inside the domain class?
Advices and suggestions will be appreciated.
Aucun commentaire:
Enregistrer un commentaire