android - AsyncTaskLoader doesn't run -
i want implement asynctaskloader in project using compatibility package, followed loader manual in android docs.
the problem loader nothing, seems loadinbackground()
never called
any idea of what's wrong in code? (expandablelistfragment
extends fragment
,but doesn't override critical method )
thank :-)
/**edit:
i realized (late, i'm moron) asynctaskloader abstract class need subclass it... m(__)m leave question in case comes here behind me, knows...
public class agendalistfragment extends expandablelistfragment implements loadermanager.loadercallbacks<jsonarray> { private treemap<integer, arraylist<evento>> mitems = new treemap<integer, arraylist<evento>>(); private agendalistadapter madapter; private progressbar mprogressbar; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view root = inflater.inflate(r.layout.fragment_agenda, container); mprogressbar = (progressbar) root.findviewbyid(r.id.loading); return root; } @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); madapter = new agendalistadapter(getactivity()); setlistadapter(madapter); getloadermanager().initloader(0, null, this); } @override public loader<jsonarray> oncreateloader(int arg0, bundle arg1) { mprogressbar.setvisibility(view.visible); return new asynctaskloader<jsonarray>(getactivity()) { @override public jsonarray loadinbackground() { return getdatafromservice(agendaservices.listado_mes); } }; } @override public void onloadfinished(loader<jsonarray> loader, jsonarray data) { // stuff turn jsonarray treemap mprogressbar.setvisibility(view.gone); madapter.setitems(mitems); } @override public void onloaderreset(loader<jsonarray> arg0) { madapter.setitems(null); mprogressbar.setvisibility(view.visible); } }
i think best solution compatibility package override asynctaskloader.onstartloading method.
e.g.
@override protected void onstartloading() { if(dataisready) { deliverresult(data); } else { forceload(); } }
Comments
Post a Comment