This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Blinker { | |
private float BLINK_TIME = 1f; | |
private int BLINKING_FRAMES = 4; | |
private boolean isBlinking; | |
private int blinkFrameCounter; | |
private float blinkTimer; | |
public Blinker() { | |
this.blinkTimer = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Scale function: | |
/** | |
* Creates new bitmap by scaling given one | |
* | |
* @param scaleFactor | |
* @param bitmap | |
* @return new bitmap | |
*/ | |
public static Bitmap createScaledBitmap(Bitmap bitmap, float scaleFactor) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Orginal http://stackoverflow.com/questions/23122088/colored-boxed-with-letters-a-la-gmail | |
* Used to create a {@link Bitmap} that contains a letter used in the English | |
* alphabet or digit, if there is no letter or digit available, a default image | |
* is shown instead. | |
* | |
* Only English language supported. | |
*/ | |
public class LetterBitmap { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Don't forget to add Palette library to your build.gradle | |
// compile 'com.android.support:palette-v7:+' | |
public static int getDominantColor(Bitmap bitmap) { | |
List<Palette.Swatch> swatchesTemp = Palette.from(bitmap).generate().getSwatches(); | |
List<Palette.Swatch> swatches = new ArrayList<Palette.Swatch>(swatchesTemp); | |
Collections.sort(swatches, new Comparator<Palette.Swatch>() { | |
@Override | |
public int compare(Palette.Swatch swatch1, Palette.Swatch swatch2) { | |
return swatch2.getPopulation() - swatch1.getPopulation(); |