当前位置: 首页>>代码示例>>Java>>正文


Java Palette.getDarkVibrantSwatch方法代码示例

本文整理汇总了Java中android.support.v7.graphics.Palette.getDarkVibrantSwatch方法的典型用法代码示例。如果您正苦于以下问题:Java Palette.getDarkVibrantSwatch方法的具体用法?Java Palette.getDarkVibrantSwatch怎么用?Java Palette.getDarkVibrantSwatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.graphics.Palette的用法示例。


在下文中一共展示了Palette.getDarkVibrantSwatch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getColor

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public static int getColor (Palette p){
    Palette.Swatch s1 = p.getVibrantSwatch();
    Palette.Swatch s3 = p.getDarkVibrantSwatch();
    Palette.Swatch s2 = p.getMutedSwatch();
    Palette.Swatch s6 = p.getDarkMutedSwatch();
    Palette.Swatch s4 = p.getLightVibrantSwatch();
    Palette.Swatch s5 = p.getLightMutedSwatch();
    Palette.Swatch s7 = p.getDominantSwatch();
    if (s1 != null) {
        return s1.getRgb();
    } else if (s2 != null) {
        return s2.getRgb();
    } else if (s3 != null) {
        return s3.getRgb();
    } else if (s4 != null) {
        return s4.getRgb();
    } else if (s5 != null) {
        return s5.getRgb();
    } else if (s6 != null) {
        return s6.getRgb();
    } else if (s7 != null) {
        return s7.getRgb();
    } else {
        return Color.parseColor("#009688");
    }
}
 
开发者ID:htqqdd,项目名称:music_player,代码行数:27,代码来源:ColorUtil.java

示例2: getColor

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
@ColorInt
public static int getColor(@Nullable Palette palette, int fallback) {
    if (palette != null) {
        if (palette.getVibrantSwatch() != null) {
            return palette.getVibrantSwatch().getRgb();
        } else if (palette.getMutedSwatch() != null) {
            return palette.getMutedSwatch().getRgb();
        } else if (palette.getDarkVibrantSwatch() != null) {
            return palette.getDarkVibrantSwatch().getRgb();
        } else if (palette.getDarkMutedSwatch() != null) {
            return palette.getDarkMutedSwatch().getRgb();
        } else if (palette.getLightVibrantSwatch() != null) {
            return palette.getLightVibrantSwatch().getRgb();
        } else if (palette.getLightMutedSwatch() != null) {
            return palette.getLightMutedSwatch().getRgb();
        } else if (!palette.getSwatches().isEmpty()) {
            return Collections.max(palette.getSwatches(), SwatchComparator.getInstance()).getRgb();
        }
    }
    return fallback;
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:22,代码来源:PhonographColorUtil.java

示例3: getBestPaletteSwatchFrom

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
private static Palette.Swatch getBestPaletteSwatchFrom(Palette palette) {
    if (palette != null) {
        if (palette.getVibrantSwatch() != null)
            return palette.getVibrantSwatch();
        else if (palette.getMutedSwatch() != null)
            return palette.getMutedSwatch();
        else if (palette.getDarkVibrantSwatch() != null)
            return palette.getDarkVibrantSwatch();
        else if (palette.getDarkMutedSwatch() != null)
            return palette.getDarkMutedSwatch();
        else if (palette.getLightVibrantSwatch() != null)
            return palette.getLightVibrantSwatch();
        else if (palette.getLightMutedSwatch() != null)
            return palette.getLightMutedSwatch();
        else if (!palette.getSwatches().isEmpty())
            return getBestPaletteSwatchFrom(palette.getSwatches());
    }
    return null;
}
 
开发者ID:TheAndroidMaster,项目名称:MediaNotification,代码行数:20,代码来源:PaletteUtils.java

示例4: get4DarkColorWithTextFormBitmap

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
 * 获得图片中出现最多的颜色<br>
 * 0 暗的活力颜色<br>
 * 1 暗的活力颜色 对应适合的字体颜色<br>
 * 2 暗的柔和颜色<br>
 * 3 暗的柔和颜色 对应适合的字体颜色<br>
 */
public static void get4DarkColorWithTextFormBitmap(@NonNull Bitmap bitmap, int defaultColor, int defaultTextColor, int[] colors) {

    if (colors.length != 4)
        return;

    Palette palette;
    palette = new Palette.Builder(bitmap).generate();

    Palette.Swatch swatch;
    int color = defaultColor;
    int textColor = defaultTextColor;

    if ((swatch = palette.getDarkVibrantSwatch()) != null) {
        color = swatch.getRgb();
        textColor = swatch.getTitleTextColor();
    }
    colors[0] = color;
    colors[1] = textColor;

    color = defaultColor;
    textColor = defaultTextColor;

    if ((swatch = palette.getDarkMutedSwatch()) != null) {
        color = swatch.getRgb();
        textColor = swatch.getTitleTextColor();
    }
    colors[2] = color;
    colors[3] = textColor;

}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:38,代码来源:ColorUtils.java

示例5: createRipple

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public static RippleDrawable createRipple(@NonNull Palette palette,
        @FloatRange(from = 0f, to = 1f) float darkAlpha,
        @FloatRange(from = 0f, to = 1f) float lightAlpha,
        @ColorInt int fallbackColor,
        boolean bounded) {
    int rippleColor = fallbackColor;
    if (palette != null) {
        // try the named swatches in preference order
        if (palette.getVibrantSwatch() != null) {
            rippleColor =
                    ColorUtils.modifyAlpha(palette.getVibrantSwatch().getRgb(), darkAlpha);

        } else if (palette.getLightVibrantSwatch() != null) {
            rippleColor = ColorUtils.modifyAlpha(palette.getLightVibrantSwatch().getRgb(),
                    lightAlpha);
        } else if (palette.getDarkVibrantSwatch() != null) {
            rippleColor = ColorUtils.modifyAlpha(palette.getDarkVibrantSwatch().getRgb(),
                    darkAlpha);
        } else if (palette.getMutedSwatch() != null) {
            rippleColor = ColorUtils.modifyAlpha(palette.getMutedSwatch().getRgb(), darkAlpha);
        } else if (palette.getLightMutedSwatch() != null) {
            rippleColor = ColorUtils.modifyAlpha(palette.getLightMutedSwatch().getRgb(),
                    lightAlpha);
        } else if (palette.getDarkMutedSwatch() != null) {
            rippleColor =
                    ColorUtils.modifyAlpha(palette.getDarkMutedSwatch().getRgb(), darkAlpha);
        }
    }
    return new RippleDrawable(ColorStateList.valueOf(rippleColor), null,
            bounded ? new ColorDrawable(Color.WHITE) : null);
}
 
开发者ID:gejiaheng,项目名称:Protein,代码行数:32,代码来源:ViewUtils.java

示例6: definePaletteAsyncListener

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
 * Defines a palette listener.
 * @param title title
 * @param textRating text rating
 * @param rating rating
 * @param starRating star rating
 * @return palette
 */
public static PaletteAsyncListener definePaletteAsyncListener(final Context context,
                                                              final TextView title,
                                                              final TextView textRating,
                                                              final LinearLayout rating,
                                                              final ImageView starRating) {
    return new PaletteAsyncListener() {
        @SuppressLint("NewApi")
        @Override
        public void onGenerated(Palette palette) {
            if (LOG) {
                Log.v(TAG, "textSwatch.PaletteAsyncListener");
            }
            Palette.Swatch textSwatch = palette.getMutedSwatch();
            Palette.Swatch bgSwatch = palette.getDarkVibrantSwatch();

            if (textSwatch != null && bgSwatch != null) {
                title.setTextColor(textSwatch.getTitleTextColor());
                title.setBackgroundColor(textSwatch.getRgb());
                textRating.setTextColor(bgSwatch.getTitleTextColor());
                rating.setBackgroundColor(bgSwatch.getRgb());
                starRating.setBackgroundColor(bgSwatch.getTitleTextColor());
            } else if (bgSwatch != null) {
                title.setBackgroundColor(bgSwatch.getRgb());
                title.setTextColor(bgSwatch.getBodyTextColor());
                rating.setBackgroundColor(bgSwatch.getBodyTextColor());
                textRating.setTextColor(bgSwatch.getRgb());
                starRating.setBackgroundColor(bgSwatch.getRgb());
            } else if (textSwatch != null) {
                title.setBackgroundColor(textSwatch.getRgb());
                title.setTextColor(textSwatch.getBodyTextColor());
                rating.setBackgroundColor(textSwatch.getBodyTextColor());
                textRating.setTextColor(textSwatch.getRgb());
                starRating.setBackgroundColor(textSwatch.getRgb());
            } else {
                title.setTextColor(
                        context.getResources().getColor(R.color.textcolorPrimary, null));
                title.setBackgroundColor(
                        context.getResources().getColor(R.color.colorPrimary, null));
                textRating.setTextColor(
                        context.getResources().getColor(R.color.textcolorSec, null));
                rating.setBackgroundColor(
                        context.getResources().getColor(R.color.colorBackground, null));
            }
        }
    };
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:55,代码来源:ActivityUtils.java

示例7: getColor

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
@ColorInt
   public static int getColor(@Nullable Palette palette, int defaultColor)
{
       if (palette != null) 
	{
           if (palette.getVibrantSwatch() != null)
		{
               return palette.getVibrantSwatch().getRgb();
           }
		else if (palette.getMutedSwatch() != null) 
		{
               return palette.getMutedSwatch().getRgb();
           } 
		else if (palette.getDarkVibrantSwatch() != null)
		{
               return palette.getDarkVibrantSwatch().getRgb();
           } 
		else if (palette.getDarkMutedSwatch() != null)
		{
               return palette.getDarkMutedSwatch().getRgb();
           } 
		else if (palette.getLightVibrantSwatch() != null) 
		{
               return palette.getLightVibrantSwatch().getRgb();
           } 
		else if (palette.getLightMutedSwatch() != null) 
		{
               return palette.getLightMutedSwatch().getRgb();
           } 
		else if (!palette.getSwatches().isEmpty()) 
		{
               return Collections.max(palette.getSwatches(), SwatchComparator.getInstance()).getRgb();
           }
       }
       return defaultColor;
   }
 
开发者ID:MSay2,项目名称:Mire,代码行数:37,代码来源:PaletteUtils.java

示例8: setPalette

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public void setPalette(final Palette palette) {
    if (palette.getLightMutedSwatch() != null) {
        setSwatch(palette.getLightMutedSwatch());
    } else if (palette.getLightVibrantSwatch() != null) {
        setSwatch(palette.getLightVibrantSwatch());
    } else if (palette.getDarkMutedSwatch() != null) {
        setSwatch(palette.getDarkMutedSwatch());
    } else if (palette.getDarkVibrantSwatch() != null) {
        setSwatch(palette.getDarkVibrantSwatch());
    }
}
 
开发者ID:PacktPublishing,项目名称:Hands-On-Android-UI-Development,代码行数:12,代码来源:ColorizedCardView.java

示例9: fromBitmapGetRgb

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public int fromBitmapGetRgb(Bitmap bitmap) {
    //Bitmap bitmap= BitmapFactory.decodeResource(getResources(), R.mipmap.img_video);
    Palette palette = Palette.from(bitmap).generate();
    //Palette.from(bitmap).maximumColorCount(32).addFilter();
    if (palette.getVibrantSwatch() != null) {
        Log.e(TAG, "fromBitmapGetRgb: 1"+palette.getVibrantSwatch().getRgb() );
        return palette.getVibrantSwatch().getRgb();
    }
    if (palette.getLightMutedSwatch() != null) {
        Log.e(TAG, "fromBitmapGetRgb: 2"+palette.getLightMutedSwatch().getRgb() );
        return palette.getLightMutedSwatch().getRgb();
    }
    if (palette.getDarkVibrantSwatch() != null) {
        Log.e(TAG, "fromBitmapGetRgb: 3"+palette.getDarkVibrantSwatch().getRgb() );
        return palette.getDarkVibrantSwatch().getRgb();
    }
    if (palette.getDarkMutedSwatch() != null) {
        Log.e(TAG, "fromBitmapGetRgb: 4"+palette.getDarkMutedSwatch().getRgb() );
        return palette.getDarkMutedSwatch().getRgb();
    }
    if (palette.getDominantSwatch() != null) {
        Log.e(TAG, "fromBitmapGetRgb: 5"+palette.getDominantSwatch().getRgb() );
        return palette.getDominantSwatch().getRgb();
    }
    if (palette.getLightVibrantSwatch() != null) {
        Log.e(TAG, "fromBitmapGetRgb: 6"+palette.getLightVibrantSwatch().getRgb() );
        return palette.getLightVibrantSwatch().getRgb();
    }
    return Color.parseColor("#3F51B5");
}
 
开发者ID:xmlxin,项目名称:ReplyMessage,代码行数:31,代码来源:SystemUtil.java

示例10: applyPalette

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
private void applyPalette(Palette palette){
    Palette.Swatch swatch=palette.getDarkVibrantSwatch();
    if(swatch==null) swatch=palette.getDominantSwatch();
    if(swatch!=null){
        toggle.setBackgroundTintList(ColorStateList.valueOf(swatch.getRgb()));
    }
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:8,代码来源:PlaylistFragment.java

示例11: createRipple

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public static RippleDrawable createRipple(@NonNull Palette palette,
                                          @FloatRange(from = 0f, to = 1f) float darkAlpha,
                                          @FloatRange(from = 0f, to = 1f) float lightAlpha,
                                          @ColorInt int fallbackColor,
                                          boolean bounded) {
    int rippleColor = fallbackColor;
    if (palette != null) {
        // try the named swatches in preference order
        if (palette.getVibrantSwatch() != null) {
            rippleColor =
                    ColorUtil.modifyAlpha(palette.getVibrantSwatch().getRgb(), darkAlpha);

        } else if (palette.getLightVibrantSwatch() != null) {
            rippleColor = ColorUtil.modifyAlpha(palette.getLightVibrantSwatch().getRgb(),
                    lightAlpha);
        } else if (palette.getDarkVibrantSwatch() != null) {
            rippleColor = ColorUtil.modifyAlpha(palette.getDarkVibrantSwatch().getRgb(),
                    darkAlpha);
        } else if (palette.getMutedSwatch() != null) {
            rippleColor = ColorUtil.modifyAlpha(palette.getMutedSwatch().getRgb(), darkAlpha);
        } else if (palette.getLightMutedSwatch() != null) {
            rippleColor = ColorUtil.modifyAlpha(palette.getLightMutedSwatch().getRgb(),
                    lightAlpha);
        } else if (palette.getDarkMutedSwatch() != null) {
            rippleColor =
                    ColorUtil.modifyAlpha(palette.getDarkMutedSwatch().getRgb(), darkAlpha);
        }
    }
    return new RippleDrawable(ColorStateList.valueOf(rippleColor), null, bounded ? new ColorDrawable(Color.WHITE) : null);
}
 
开发者ID:haihaio,项目名称:AmenEye,代码行数:31,代码来源:ViewUtil.java

示例12: getAvailableColor

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
 * Return Array with palette color
 *
 * @param context
 * @param palette
 * @return
 */
public static int[] getAvailableColor(Context context, Palette palette) {
    int[] temp = new int[3]; //array with size 3
    if (palette.getVibrantSwatch() != null) {
        temp[0] = palette.getVibrantSwatch().getRgb();
        temp[1] = palette.getVibrantSwatch().getTitleTextColor();
        temp[2] = palette.getVibrantSwatch().getBodyTextColor();
    } else if (palette.getMutedSwatch() != null) {
        temp[0] = palette.getMutedSwatch().getRgb();
        temp[1] = palette.getMutedSwatch().getTitleTextColor();
        temp[2] = palette.getMutedSwatch().getBodyTextColor();
    } else if (palette.getDarkVibrantSwatch() != null) {
        temp[0] = palette.getDarkVibrantSwatch().getRgb();
        temp[1] = palette.getDarkVibrantSwatch().getTitleTextColor();
        temp[2] = palette.getDarkVibrantSwatch().getBodyTextColor();
    } else if (palette.getDarkMutedSwatch() != null) {
        temp[0] = palette.getDarkMutedSwatch().getRgb();
        temp[1] = palette.getDarkMutedSwatch().getTitleTextColor();
        temp[2] = palette.getDarkMutedSwatch().getBodyTextColor();
    } else if (palette.getDominantSwatch() != null) {
        temp[0] = palette.getDominantSwatch().getRgb();
        temp[1] = palette.getDominantSwatch().getTitleTextColor();
        temp[2] = palette.getDominantSwatch().getBodyTextColor();
    } else {
        String atkey = Helper.getATEKey(context);
        int accent = Config.accentColor(context, atkey);
        temp[0] = accent;
        temp[1] = 0xffe5e5e5;
        temp[2] = accent;
    }
    return temp;
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:39,代码来源:Helper.java

示例13: getAvailableColor

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public static int[] getAvailableColor(Context context, Palette palette) {
    int[] temp = new int[3]; //array with size 3
    if (palette.getDarkVibrantSwatch() != null) {
        temp[0] = palette.getDarkVibrantSwatch().getRgb();
        temp[1] = palette.getDarkVibrantSwatch().getTitleTextColor();
        temp[2] = palette.getDarkVibrantSwatch().getBodyTextColor();
    } else if (palette.getDarkMutedSwatch() != null) {
        temp[0] = palette.getDarkMutedSwatch().getRgb();
        temp[1] = palette.getDarkMutedSwatch().getTitleTextColor();
        temp[2] = palette.getDarkMutedSwatch().getBodyTextColor();
    } else if (palette.getVibrantSwatch() != null) {
        temp[0] = palette.getVibrantSwatch().getRgb();
        temp[1] = palette.getVibrantSwatch().getTitleTextColor();
        temp[2] = palette.getVibrantSwatch().getBodyTextColor();
    } else if (palette.getDominantSwatch() != null) {
        temp[0] = palette.getDominantSwatch().getRgb();
        temp[1] = palette.getDominantSwatch().getTitleTextColor();
        temp[2] = palette.getDominantSwatch().getBodyTextColor();
    } else if (palette.getMutedSwatch() != null) {
        temp[0] = palette.getMutedSwatch().getRgb();
        temp[1] = palette.getMutedSwatch().getTitleTextColor();
        temp[2] = palette.getMutedSwatch().getBodyTextColor();
    } else {
        temp[0] = ContextCompat.getColor(context, R.color.MaterialGrey);
        temp[1] = Color.WHITE;
        temp[2] = Color.WHITE;
    }
    return temp;
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:30,代码来源:NotificationHandler.java

示例14: get6ColorFormBitmap

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
 * 获得图片中出现最多的颜色
 * 0 活力颜色<br>
 * 1 亮的活力颜色<br>
 * 2 暗的活力颜色<br>
 * 3 柔和颜色<br>
 * 4 亮的柔和颜色<br>
 * 5 暗的柔和颜色<br>
 */
public static void get6ColorFormBitmap(@NonNull Bitmap bitmap, int defaultColor, int[] colors) {

    if (colors.length != 6)
        return;

    Palette palette;
    palette = new Palette.Builder(bitmap).generate();

    Palette.Swatch swatch;
    int color;

    if ((swatch = palette.getVibrantSwatch()) != null)
        color = swatch.getRgb();
    else color = defaultColor;
    colors[0] = color;

    if ((swatch = palette.getLightVibrantSwatch()) != null)
        color = swatch.getRgb();
    else color = defaultColor;
    colors[1] = color;

    if ((swatch = palette.getDarkVibrantSwatch()) != null)
        color = swatch.getRgb();
    else color = defaultColor;
    colors[2] = color;

    if ((swatch = palette.getMutedSwatch()) != null)
        color = swatch.getRgb();
    else color = defaultColor;
    colors[3] = color;

    if ((swatch = palette.getLightMutedSwatch()) != null)
        color = swatch.getRgb();
    else color = defaultColor;
    colors[4] = color;

    if ((swatch = palette.getDarkMutedSwatch()) != null)
        color = swatch.getRgb();
    else color = defaultColor;
    colors[5] = color;

}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:52,代码来源:ColorUtils.java

示例15: extractSwatches

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
@NonNull
@WorkerThread
private List<Swatch> extractSwatches() {
    final List<Swatch> colorSwatches = new ArrayList<>();
    final List<Palette.Swatch> generatedSwatches = new ArrayList<>();
    if (bitmap != null) {
        final Palette palette;
        if (noOfColors != 0) {
            palette = Palette.from(bitmap).maximumColorCount(noOfColors).generate();
        } else {
            palette = Palette.from(bitmap).generate();
        }
        Palette.Swatch dominantSwatch = palette.getDominantSwatch();
        Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
        Palette.Swatch vibrantDarkSwatch = palette.getDarkVibrantSwatch();
        Palette.Swatch vibrantLightSwatch = palette.getLightVibrantSwatch();
        Palette.Swatch mutedSwatch = palette.getMutedSwatch();
        Palette.Swatch mutedDarkSwatch = palette.getDarkMutedSwatch();
        Palette.Swatch mutedLightSwatch = palette.getLightMutedSwatch();

        if (vibrantSwatch != null && mutedSwatch == null) {
            mutedSwatch = vibrantSwatch;
        } else if (vibrantSwatch == null && mutedSwatch != null) {
            vibrantSwatch = mutedSwatch;
        }
        if (vibrantDarkSwatch != null && mutedDarkSwatch == null) {
            mutedDarkSwatch = vibrantDarkSwatch;
        } else if (vibrantDarkSwatch == null && mutedDarkSwatch != null) {
            vibrantDarkSwatch = mutedDarkSwatch;
        }
        if (vibrantLightSwatch != null && mutedLightSwatch == null) {
            mutedLightSwatch = vibrantLightSwatch;
        } else if (vibrantLightSwatch == null && mutedLightSwatch != null) {
            vibrantLightSwatch = mutedLightSwatch;
        }

        generatedSwatches.add(dominantSwatch);
        generatedSwatches.add(vibrantSwatch);
        generatedSwatches.add(vibrantDarkSwatch);
        generatedSwatches.add(vibrantLightSwatch);
        generatedSwatches.add(mutedSwatch);
        generatedSwatches.add(mutedDarkSwatch);
        generatedSwatches.add(mutedLightSwatch);

        for (final Palette.Swatch paletteSwatch : generatedSwatches) {
            colorSwatches.add(paletteSwatch != null ? new Swatch(paletteSwatch) : null);
        }
        recycleBitmap();
    }
    return colorSwatches;
}
 
开发者ID:arunkumar9t2,项目名称:chameleon-live-wallpaper,代码行数:52,代码来源:Extractor.java


注:本文中的android.support.v7.graphics.Palette.getDarkVibrantSwatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。