Merge "RS: Water Livewallpaper crashed after setting it to wallpaper several times."
diff --git a/src/com/android/wallpaper/RenderScriptWallpaper.java b/src/com/android/wallpaper/RenderScriptWallpaper.java
index 0016d33..fe1f21d 100644
--- a/src/com/android/wallpaper/RenderScriptWallpaper.java
+++ b/src/com/android/wallpaper/RenderScriptWallpaper.java
@@ -89,7 +89,7 @@
         @Override
         public void onOffsetsChanged(float xOffset, float yOffset,
                 float xStep, float yStep, int xPixels, int yPixels) {
-            mRenderer.setOffset(xOffset, yOffset, xPixels, yPixels);
+            if (mRenderer != null) mRenderer.setOffset(xOffset, yOffset, xPixels, yPixels);
         }
 
         @Override
@@ -110,7 +110,11 @@
         @Override
         public Bundle onCommand(String action, int x, int y, int z,
                 Bundle extras, boolean resultRequested) {
-            return mRenderer.onCommand(action, x, y, z, extras, resultRequested);
+            if (mRenderer != null) {
+                return mRenderer.onCommand(action, x, y, z, extras, resultRequested);
+            } else {
+                return null;
+            }
         }
 
     }