Handle exceptions in Palette's async generation

As we run in an AsyncTask it's hard for developers to be
able to recover from the crash. We now catch all exceptions
and log them.

BUG: 22914873
Change-Id: I3674148c56a463e06c99c7585181ea2df7bb49ae
diff --git a/v7/palette/src/main/java/android/support/v7/graphics/Palette.java b/v7/palette/src/main/java/android/support/v7/graphics/Palette.java
index eec60e2..55bd1ca 100644
--- a/v7/palette/src/main/java/android/support/v7/graphics/Palette.java
+++ b/v7/palette/src/main/java/android/support/v7/graphics/Palette.java
@@ -24,6 +24,7 @@
 import android.support.annotation.Nullable;
 import android.support.v4.graphics.ColorUtils;
 import android.support.v4.os.AsyncTaskCompat;
+import android.util.Log;
 import android.util.TimingLogger;
 
 import java.util.ArrayList;
@@ -659,7 +660,12 @@
                     new AsyncTask<Bitmap, Void, Palette>() {
                         @Override
                         protected Palette doInBackground(Bitmap... params) {
-                            return generate();
+                            try {
+                                return generate();
+                            } catch (Exception e) {
+                                Log.e(LOG_TAG, "Exception thrown during async generate", e);
+                                return null;
+                            }
                         }
 
                         @Override