I have an AsyncTask that loads a bitmap from url and uses a Palette to change the background of my Floating Action Button. With most images it works fine but on some it makes the button transparent. Screenshot 1 shows the button color working with the blue color from the image but in Screenshot 2 the color of the button is transparent (even though the image doesnt contain any transparent pixels as it's a jpeg).
    public class ColoredFabTask extends AsyncTask<String , String , String> {
    Context mContext;
    View view;
    private View rootView;
    URL myFileUrl;
    Bitmap imageBitmap = null;
    public ColoredFabTask(Context context, View view) {
        this.mContext = context;
        this.view = view;
    }
    @Override
    protected void onPreExecute() {
    }
    @Override
    protected String doInBackground(String... args) {
        try {
            myFileUrl = new URL(args[0]);
            HttpURLConnection conn = (HttpURLConnection) 
            myFileUrl.openConnection();
            conn.setDoInput(true);
            conn.connect();
            InputStream is = conn.getInputStream();
            imageBitmap = BitmapFactory.decodeStream(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    @Override
    protected void onPostExecute(String args) {
        Palette palette  = Palette.from(imageBitmap).generate();
        int vibrant = palette.getVibrantColor(0);
        FloatingActionButton applyButton = (FloatingActionButton) view.findViewById(R.id.applyButton);
        applyButton.setBackgroundTintList(ColorStateList.valueOf(vibrant));
        applyButton.setVisibility(View.VISIBLE);
    }
}
Screenshots:


                        
Fixed the problem for myself if anyone wants to know how. Just check if the swatch is null.