Example usage for android.graphics.drawable ColorDrawable getColor

List of usage examples for android.graphics.drawable ColorDrawable getColor

Introduction

In this page you can find the example usage for android.graphics.drawable ColorDrawable getColor.

Prototype

@ColorInt
public int getColor() 

Source Link

Document

Gets the drawable's color value.

Usage

From source file:com.github.colorchief.colorchief.MainActivity.java

public void hsvButtonClick(View view) {
    ImageView colourBlock22 = (ImageView) findViewById(R.id.colour22);
    ColorDrawable colourDrawable = (ColorDrawable) colourBlock22.getBackground();
    int setColour = colourDrawable.getColor();
    int newColour = 0;
    float hsvColour[] = new float[3];
    Color.colorToHSV(setColour, hsvColour);

    if (view.getId() == R.id.hueDownButton) {

        //Log.d(TAG, "Hue Down Button Clicked");

        hsvColour[0] = hsvColour[0] - H_ADJUST;
        if (hsvColour[0] < 0f)
            hsvColour[0] = 360f + hsvColour[0];

    }//w w w. j  a  v  a2  s  .  co  m
    if (view.getId() == R.id.hueUpButton) {
        //Log.d(TAG, "Hue Up Button Clicked");

        hsvColour[0] = hsvColour[0] + H_ADJUST;
        if (hsvColour[0] > 360f)
            hsvColour[0] = hsvColour[0] - 360f;

    }
    if (view.getId() == R.id.saturationDownButton) {
        //Log.d(TAG, "Saturation Down Button Clicked");

        hsvColour[1] = hsvColour[1] - S_ADJUST;
        //if (hsvColour[1] < 0f ) hsvColour[1] = 1f + hsvColour[1];
        if (hsvColour[1] < 0f)
            hsvColour[1] = 0f;

    }
    if (view.getId() == R.id.saturationUpButton) {
        //Log.d(TAG, "Saturation Up Button Clicked");

        hsvColour[1] = hsvColour[1] + S_ADJUST;
        //if (hsvColour[1] > 1f ) hsvColour[1] = hsvColour[1] - 1f;
        if (hsvColour[1] > 1f)
            hsvColour[1] = 1f;

    }
    if (view.getId() == R.id.lightnessDownButton) {
        //Log.d(TAG, "Lightness Down Button Clicked");

        hsvColour[2] = hsvColour[2] - V_ADJUST;
        //if (hsvColour[2] < 0f ) hsvColour[2] = 1f + hsvColour[2];
        if (hsvColour[2] < 0f)
            hsvColour[2] = 0f;

    }
    if (view.getId() == R.id.lightnessUpButton) {
        //Log.d(TAG, "Lightness Up Button Clicked");

        hsvColour[2] = hsvColour[2] + V_ADJUST;
        //if (hsvColour[2] > 1f ) hsvColour[2] = hsvColour[2] - 1f;
        if (hsvColour[2] > 1f)
            hsvColour[2] = 1f;
    }

    newColour = Color.HSVToColor(hsvColour);
    colourBlock22.setBackgroundColor(newColour);

}

From source file:com.igniva.filemanager.activities.MainActivity.java

/**
 * Call this method when you need to update the MainActivity view components' colors based on
 * update in the {@link MainActivity#currentTab}
 * Warning - All the variables should be initialised before calling this method!
 *//*from   w w w  .ja  v a  2  s . c  o  m*/
public void updateViews(ColorDrawable colorDrawable) {

    // appbar view color
    mainActivity.buttonBarFrame.setBackgroundColor(colorDrawable.getColor());
    // action bar color
    mainActivity.getSupportActionBar().setBackgroundDrawable(colorDrawable);
    // drawer status bar I guess
    mainActivity.mDrawerLayout.setStatusBarBackgroundColor(colorDrawable.getColor());
    // drawer header background
    mainActivity.drawerHeaderParent.setBackgroundColor(colorDrawable.getColor());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // for lollipop devices, the status bar color
        mainActivity.getWindow().setStatusBarColor(colorDrawable.getColor());
        if (colourednavigation)
            mainActivity.getWindow()
                    .setNavigationBarColor(PreferenceUtils.getStatusColor(colorDrawable.getColor()));
    } else if (Build.VERSION.SDK_INT == 20 || Build.VERSION.SDK_INT == 19) {

        // for kitkat devices, the status bar color
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(colorDrawable.getColor());
    }
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

/**
 * Call this method when you need to update the MainActivity view components' colors based on
 * update in the {@link MainActivity#currentTab}
 * Warning - All the variables should be initialised before calling this method!
 *//*from  w  ww  .  ja  v  a2  s .  c  o  m*/
public void updateViews(ColorDrawable colorDrawable) {
    // appbar view color
    mainActivity.buttonBarFrame.setBackgroundColor(colorDrawable.getColor());
    // action bar color
    mainActivity.getSupportActionBar().setBackgroundDrawable(colorDrawable);
    // drawer status bar I guess
    mainActivity.mDrawerLayout.setStatusBarBackgroundColor(colorDrawable.getColor());
    // drawer header background
    mainActivity.drawerHeaderParent.setBackgroundColor(colorDrawable.getColor());

    if (SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // for lollipop devices, the status bar color
        mainActivity.getWindow().setStatusBarColor(colorDrawable.getColor());
        if (colourednavigation)
            mainActivity.getWindow()
                    .setNavigationBarColor(PreferenceUtils.getStatusColor(colorDrawable.getColor()));
    } else if (SDK_INT == 20 || SDK_INT == 19) {

        // for kitkat devices, the status bar color
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(colorDrawable.getColor());
    }
}