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 trial

Android Android Lists and Adapters (2015) Updating the Data Model Introducing the Project

Unfortunately, Stormy has stopped.

When I comment out the following line, Stormy runs OK but of course without the progress bar. If I uncomment the line it crashes???

private void toggleRefresh() {
        if (mProgressBar.getVisibility() == View.INVISIBLE) {
            //mProgressBar.setVisibility(View.VISIBLE);
            mRefreshImageView.setVisibility(View.INVISIBLE);
        }
        else {
            mProgressBar.setVisibility(View.INVISIBLE);
            mRefreshImageView.setVisibility(View.VISIBLE);
        }
    }

2 Answers

That's very strange ... what error are you getting in Logcat? Can you post that?

Is it just that one line within toggleRefresh() that's causing the issue? Where are you calling toggleRefresh() from?

The Logcat error might help us further with that else let's get your project into Github so we can see all the files. My, slightly modyfied, version is there: https://github.com/OnlySteveH/Stormy2

Steve.

Steve, I emailed you the logcats, I see the error. One of the calls to toggleRefresh did not have the "runOnUiThread".

Thanks, Dan

Where did you send the email? I've not received anything.

Steve.

Steve, Your response came to me by Email, I just replied to it?? Anyway, here it is.

Logcat with line uncommented:

03-18 10:52:52.099 1990-1990/projects.wellsjava.stormy D/dalvikvm﹕ Late-enabling CheckJNI 03-18 10:52:52.167 1990-1990/projects.wellsjava.stormy D/dalvikvm﹕ GC_FOR_ALLOC freed 126K, 6% free 3894K/4108K, paused 5ms, total 6ms 03-18 10:52:52.279 1990-1990/projects.wellsjava.stormy D/libEGL﹕ loaded /system/lib/egl/libEGL_genymotion.so 03-18 10:52:52.279 1990-1990/projects.wellsjava.stormy D/﹕ HostConnection::get() New Host Connection established 0xb96fb768, tid 1990 03-18 10:52:52.359 1990-1990/projects.wellsjava.stormy D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_genymotion.so 03-18 10:52:52.363 1990-1990/projects.wellsjava.stormy D/libEGL﹕ loaded /system/lib/egl/libGLESv2_genymotion.so 03-18 10:52:52.371 1990-2003/projects.wellsjava.stormy W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljava/nio/file/Path;) 03-18 10:52:52.371 1990-2003/projects.wellsjava.stormy W/dalvikvm﹕ VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;) 03-18 10:52:52.371 1990-2003/projects.wellsjava.stormy I/dalvikvm﹕ Could not find method java.nio.file.Files.newOutputStream, referenced from method okio.Okio.sink 03-18 10:52:52.371 1990-2003/projects.wellsjava.stormy W/dalvikvm﹕ VFY: unable to resolve static method 13982: Ljava/nio/file/Files;.newOutputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/OutputStream; 03-18 10:52:52.371 1990-2003/projects.wellsjava.stormy D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x000a 03-18 10:52:52.371 1990-2003/projects.wellsjava.stormy W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljava/nio/file/Path;) 03-18 10:52:52.371 1990-2003/projects.wellsjava.stormy W/dalvikvm﹕ VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;) 03-18 10:52:52.371 1990-2003/projects.wellsjava.stormy I/dalvikvm﹕ Could not find method java.nio.file.Files.newInputStream, referenced from method okio.Okio.source 03-18 10:52:52.371 1990-2003/projects.wellsjava.stormy W/dalvikvm﹕ VFY: unable to resolve static method 13981: Ljava/nio/file/Files;.newInputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream; 03-18 10:52:52.371 1990-2003/projects.wellsjava.stormy D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x000a 03-18 10:52:52.435 1990-1990/projects.wellsjava.stormy W/EGL_genymotion﹕ eglSurfaceAttrib not implemented 03-18 10:52:52.439 1990-1990/projects.wellsjava.stormy E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache 03-18 10:52:52.439 1990-1990/projects.wellsjava.stormy E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192 03-18 10:52:52.451 1990-1990/projects.wellsjava.stormy E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints() 03-18 10:52:52.451 1990-1990/projects.wellsjava.stormy E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192 03-18 10:52:52.451 1990-1990/projects.wellsjava.stormy D/OpenGLRenderer﹕ Enabling debug mode 0 03-18 10:52:52.627 1990-2003/projects.wellsjava.stormy W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0xa4d84b20) 03-18 10:52:52.627 1990-2003/projects.wellsjava.stormy E/AndroidRuntime﹕ FATAL EXCEPTION: OkHttp Dispatcher Process: projects.wellsjava.stormy, PID: 1990 android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6024) at android.view.ViewRootImpl.focusableViewAvailable(ViewRootImpl.java:2796) at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:650) at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:650) at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:650) at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:650) at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:650) at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:650) at android.view.View.setFlags(View.java:8900) at android.view.View.setVisibility(View.java:6036) at android.widget.ImageView.setVisibility(ImageView.java:1226) at projects.wellsjava.stormy.ui.MainActivity.toggleRefresh(MainActivity.java:148) at projects.wellsjava.stormy.ui.MainActivity.access$100(MainActivity.java:37) at projects.wellsjava.stormy.ui.MainActivity$3.onResponse(MainActivity.java:109) at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162) at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) 03-18 10:52:52.631 1990-2003/projects.wellsjava.stormy D/dalvikvm﹕ GC_FOR_ALLOC freed 403K, 11% free 4003K/4496K, paused 2ms, total 2ms

I see the FATAL EXCEPTION, it looks like I had one call to toggleRefresh without the “runOnUiThread”. It’s working now.

Thanks for looking, Dan

Chris Casey
Chris Casey
11,656 Points

Are you calling getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);? Also it could have to do with the Theme you have set. I vaguely remember having this issue and having to change the theme to Holo.dark or something.