From f3c8c3dee60153f471312e21acac8b3a3cddd7dc Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Thu, 22 May 2014 11:30:11 -0700 Subject: [PATCH] Fix scheduled-swap crash It turns out that, with the right timing, onItemSelected() can be called while the activity is paused. --- src/com/android/grafika/ScheduledSwapActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/grafika/ScheduledSwapActivity.java b/src/com/android/grafika/ScheduledSwapActivity.java index 18d40204..b801533f 100644 --- a/src/com/android/grafika/ScheduledSwapActivity.java +++ b/src/com/android/grafika/ScheduledSwapActivity.java @@ -262,7 +262,10 @@ public void onItemSelected(AdapterView parent, View view, int pos, long id) { throw new RuntimeException("Unknown spinner"); } - if (updated) { + if (mRenderThread == null) { + // huh + Log.d(TAG, "In onItemSelected while the activity is paused"); + } else if (updated) { RenderHandler rh = mRenderThread.getHandler(); if (rh != null) { rh.sendSetParameters(mUpdatePatternIndex, mFramesAheadIndex);