Android LWP, How to refresh RenderScript objects after Setting Preferences Changes? -
i have developed android lwp using renderscript. want add setting page , use preferences save option values.
eg. initial objects quantity 10. user can change objects quantity 20.
i cannot update/refresh/reset/recall renderscript regenerate new setting. how it?
i have managed onsharedpreferencechanged, how call in order regenerate lwp new setting after user click?
public void onsharedpreferencechanged(sharedpreferences sharedpreferences, string key) { //how force renderscript update here }
in fact, need know "how refresh/clear drawn object on renderscript?" because when setting has been changed, need redraw objects again....
the best things have managed go far set quantity of objects on listener this
private class splistener implements sharedpreferences.onsharedpreferencechangelistener {
@override public void onsharedpreferencechanged( sharedpreferences sharedpreferences, string key) { // todo auto-generated method stub obj_count = integer.parseint(utility.getnoofobjects(mcontext)); mscript.set_gobjectscount(obj_count); mscript.invoke_updateobjects(); }
}
but got "double" drawn objects. need clear existing objects first before set new quantity of objects.
eg. initial objects quantity 10. user can change objects quantity 5.
what got still 10 objects....with 5 objects drawn twice/duplicated on top of it. 5 objects have darker color due overlay drawn.
i don't use renderscript, in live wallpapers, keep class of static variables settings, , onpreferencechangedlistener transfers settings class. in draw method of live wallpaper, pull current values of static variables. also, when live wallpaper first starts, need tell settings class update of variables current values.
Comments
Post a Comment