posted 6 years ago
Hi all,
I would like to bounce something off you guys.
In my Mobile App, I have a lot of Activity and Fragment classes and many of them contain a method or two with code for uploading images to a WebAPI 2.0 web service etc. etc. Sorry, just for info.
Now, I thought about creating a new class (e.g. ServiceController) and then move all the Service Calls to this new class. The problem is, each one for the methods contain code for displaying a ProgressBar and hiding a ProgressBar, and let the activity continue to a next one, etc. etc.
Now, is it good practice to pass an instance of the Activity that is calling the method in the ServiceController to the method in the ServiceController and then for instance do this:
public static void uploadImages(Activity activity) { new BaseAsyncTask() { ... ... activity.hideProgressBar(); ... }
PS: Specifically the "activity.hideProgressBar();" above.
Thanks and have fun,
Pieter