Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialVikzilla III
Courses Plus Student 4,365 PointsUsing runOnUIThread() within toggleRefresh() more clean?
Would implementing runOnUIThread() within the toggleRefresh() helper be more DRY? Because otherwise we have to call runOnUIThread() in multiple places and call our toggleRefresh() within it.
Here's how I'm doing it:
private void toggleRefresh() {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mProgressBar.getVisibility() == View.INVISIBLE) {
mProgressBar.setVisibility(View.VISIBLE);
mRefreshImageView.setVisibility(View.INVISIBLE);
}
else {
mProgressBar.setVisibility(View.INVISIBLE);
mRefreshImageView.setVisibility(View.VISIBLE);
}
}
});
}
Or, is there a disadvantage to calling runOnUIThread() when it isn't necessary--such as the first time we call it in getForecast().
Sean Wilson
3,791 PointsThis is much cleaner! Any ideas yet if there is an issue with this?
Boban Talevski
24,793 PointsInteresting question, just adding my comment here in hope that someone could clear it up two years later :)
Philip G
14,600 PointsPhilip G
14,600 PointsWould be very interesting Craig Dennis Ben Jakuben Ben Deitch