java - Android: dismissing dialogs containing listeners -
i'm working 2 classes, , model class , dialog class in android. model class keeps list of listeners, dialog adds to.
public class smartchannelmodel { private list<onresultschanged> monresultschanged public interface onresultschanged { void onresultschanged(int changed); } public smartchannelmodel() { monresultschanged = new list<onresultschanged>(); } public void addresultlistener(onresultschanged listener) { monresultschanged.add(listener); } }
and dialog class:
public class infodialog extends appcompatdialog { private smartchannelmodel model; public infodialog(context context, smartchannelmodel model) { super(context); this.model = model; } public void update() { //do stuff } @override protected void onstart() { super.onstart(); model.addonresultschanged(new onresultschanged() { @override void onresultschanged(int changed) { update(); } }); } }
when create , dismiss dialog, garbage collection ever performed on since dialog added listener model class? need remove listeners i've added?
thank help!
as far know yes if there no other reference anywhere in class.
Comments
Post a Comment