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


Java Palette.getDominantSwatch方法代码示例

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


在下文中一共展示了Palette.getDominantSwatch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getSwatch

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public static Palette.Swatch getSwatch(Context context, Palette palette) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    if (palette == null)
        return new Palette.Swatch(prefs.getInt(PreferenceUtils.PREF_CUSTOM_COLOR, Color.WHITE), 1);

    Palette.Swatch swatch = null;
    switch (prefs.getInt(PreferenceUtils.PREF_COLOR_METHOD, PreferenceUtils.COLOR_METHOD_DOMINANT)) {
        case PreferenceUtils.COLOR_METHOD_DOMINANT:
            swatch = palette.getDominantSwatch();
            break;
        case PreferenceUtils.COLOR_METHOD_PRIMARY:
            swatch = getBestPaletteSwatchFrom(palette);
            break;
        case PreferenceUtils.COLOR_METHOD_VIBRANT:
            swatch = palette.getVibrantSwatch();
            break;
        case PreferenceUtils.COLOR_METHOD_MUTED:
            swatch = palette.getMutedSwatch();
            break;
    }

    if (swatch == null)
        swatch = new Palette.Swatch(prefs.getInt(PreferenceUtils.PREF_CUSTOM_COLOR, Color.WHITE), 1);

    return swatch;
}
 
开发者ID:TheAndroidMaster,项目名称:MediaNotification,代码行数:28,代码来源:PaletteUtils.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: getDominantColor

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
 * Get dominant color of bitmap
 * @param bitmap Bitmap
 * @return int
 */
public static int getDominantColor(Bitmap bitmap){
    Palette palette = Palette.from(bitmap).generate();
    Palette.Swatch dominantSwatch = palette.getDominantSwatch();
    if(dominantSwatch != null){
        return dominantSwatch.getRgb();
    }
    return 0;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:14,代码来源:Utils.java

示例8: 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

示例9: getDominantPaletteSwatch

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
private static Palette.Swatch getDominantPaletteSwatch(@NonNull final Bitmap bitmap) {
    Palette palette = Palette.from(bitmap).generate();
    return palette.getDominantSwatch();
}
 
开发者ID:lekaha,项目名称:TwitterizedPhotoView,代码行数:5,代码来源:PaletteUtil.java


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