Closed tgirard12 closed 9 years ago
Both bugs are due to poor GAsyncTask
and async()
method documentation, @eugene-kamenev was trying to fix both docs and code to have a better behavior.
@Arasthel why it is a bug? :) @tgirard12 Thanks for feedback, I am sorry, yes I forgot to explain the right usage of it. You can try to use it like this, sorry I just copy-pasted it "as is":
final Closure asyncTask = { context, GAsyncTask task ->
task.error {
// here we catch the error
this.progressBar.visible false
this.refreshLayout.refreshing = false
}
task.after {
// here we catch after event
if (this.tempApartments) {
this.offset += 1
def recyclerAdapter = ((AnimationRecyclerViewAdapter) this.recyclerView.adapter)
((ApartmentAdapter) recyclerAdapter.decoratedAdapter).add this.tempApartments
}
this.recyclerView.visible true
this.progressBar.visible false
this.refreshLayout.refreshing = false
}
// and here you can place the actual long running task
this.tempApartments = DatabaseService.instance.getApartments(this.offset).apartments
}
...
// then you can call a closure as a param of extension async method
async(asyncTask)
@Arasthel @tgirard12 I updated docs: https://github.com/Arasthel/SwissKnife/blob/master/docs/dsl-methods.adoc#objectasyncclosure-closure
Thanks for feedback.
Thanks for your response. I have tried the @eugene-kamenev right usage but the before
Closure is never called, it is null in the onPreExecute
function.
The other Closure work fine.
@tgirard12 Ok, I see, yeap it will never work, is there a really need for "before" closure? I can delete it
You're right, there is no really need for before
. If there is no possible quick fix , delete it could be the best solution.
Hi,
I have try to use the
GAsyncTask
but I have trouble when i use it. First I try the dsl but none ofafter
,before
orerror
method is know (at compile or at runtime) :In secondary place, I tried to use the
GAsyncTask
directly like this :The
before
task is executed and theerror
give me that stackTrace for thedoInBackground
task :Thank you guys for this library Thomas