// Path: library/src/main/java/de/mrapp/android/preference/AbstractColorPickerPreference.java
// public enum PreviewShape {
// 
//     /**
//      * If the preview is shaped as a circle.
//      */
//     CIRCLE(0),
// 
//     /**
//      * If the preview is shaped as a square.
//      */
//     SQUARE(1);
// 
//     /**
//      * The value of the shape.
//      */
//     private final int value;
// 
//     /**
//      * Creates a new shape.
//      *
//      * @param value
//      *         The value of the shape as an {@link Integer} value
//      */
//     PreviewShape(final int value) {
//         this.value = value;
//     }
// 
//     /**
//      * Returns the value of the shape.
//      *
//      * @return The value of the shape as an {@link Integer} value
//      */
//     public final int getValue() {
//         return value;
//     }
// 
//     /**
//      * Returns the shape, which corresponds to a specific value.
//      *
//      * @param value
//      *         The value of the shape, which should be returned, as an {@link Integer} value
//      * @return The shape, which corresponds to the given value, as an instance of the enum
//      * {@link PreviewShape}
//      */
//     public static PreviewShape fromValue(final int value) {
//         for (PreviewShape shape : values()) {
//             if (shape.getValue() == value) {
//                 return shape;
//             }
//         }
// 
//         throw new IllegalArgumentException("Invalid enum value");
//     }
// 
// }


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import de.mrapp.android.preference.AbstractColorPickerPreference.PreviewShape;
import de.mrapp.android.util.multithreading.AbstractDataBinder;
import de.mrapp.util.Condition;
import static de.mrapp.android.util.BitmapUtil.clipCircle;
import static de.mrapp.android.util.BitmapUtil.clipSquare;
import static de.mrapp.android.util.BitmapUtil.drawableToBitmap;
import static de.mrapp.android.util.BitmapUtil.tile;
import static de.mrapp.android.util.BitmapUtil.tint;
/*
 * Copyright 2014 - 2020 Michael Rapp
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package de.mrapp.android.preference.multithreading;




/**
 * A data loader, which allows to load the previews of colors.
 *
 * @author Michael Rapp
 * @since 1.7.0
 */
public class ColorPreviewDataBinder extends AbstractDataBinder<Bitmap, Integer, ImageView, Void> {

    /**
     * The background of the preview.
     */
    private Drawable background;

    /**
     * The shape of the preview.
     */
// Path: library/src/main/java/de/mrapp/android/preference/AbstractColorPickerPreference.java
// public enum PreviewShape {
// 
//     /**
//      * If the preview is shaped as a circle.
//      */
//     CIRCLE(0),
// 
//     /**
//      * If the preview is shaped as a square.
//      */
//     SQUARE(1);
// 
//     /**
//      * The value of the shape.
//      */
//     private final int value;
// 
//     /**
//      * Creates a new shape.
//      *
//      * @param value
//      *         The value of the shape as an {@link Integer} value
//      */
//     PreviewShape(final int value) {
//         this.value = value;
//     }
// 
//     /**
//      * Returns the value of the shape.
//      *
//      * @return The value of the shape as an {@link Integer} value
//      */
//     public final int getValue() {
//         return value;
//     }
// 
//     /**
//      * Returns the shape, which corresponds to a specific value.
//      *
//      * @param value
//      *         The value of the shape, which should be returned, as an {@link Integer} value
//      * @return The shape, which corresponds to the given value, as an instance of the enum
//      * {@link PreviewShape}
//      */
//     public static PreviewShape fromValue(final int value) {
//         for (PreviewShape shape : values()) {
//             if (shape.getValue() == value) {
//                 return shape;
//             }
//         }
// 
//         throw new IllegalArgumentException("Invalid enum value");
//     }
// 
// }


// Path: library/src/main/java/de/mrapp/android/preference/multithreading/ColorPreviewDataBinder.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import de.mrapp.android.preference.AbstractColorPickerPreference.PreviewShape;
import de.mrapp.android.util.multithreading.AbstractDataBinder;
import de.mrapp.util.Condition;
import static de.mrapp.android.util.BitmapUtil.clipCircle;
import static de.mrapp.android.util.BitmapUtil.clipSquare;
import static de.mrapp.android.util.BitmapUtil.drawableToBitmap;
import static de.mrapp.android.util.BitmapUtil.tile;
import static de.mrapp.android.util.BitmapUtil.tint;

/*
 * Copyright 2014 - 2020 Michael Rapp
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package de.mrapp.android.preference.multithreading;




/**
 * A data loader, which allows to load the previews of colors.
 *
 * @author Michael Rapp
 * @since 1.7.0
 */
public class ColorPreviewDataBinder extends AbstractDataBinder<Bitmap, Integer, ImageView, Void> {

    /**
     * The background of the preview.
     */
    private Drawable background;

    /**
     * The shape of the preview.
     */
    private PreviewShape shape;