Example usage for android.graphics PorterDuff.Mode toString

List of usage examples for android.graphics PorterDuff.Mode toString

Introduction

In this page you can find the example usage for android.graphics PorterDuff.Mode toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.example.android.drawabletinting.DrawableTintingFragment.java

/**
 * Update the tint of the image with the color set in the seekbars and selected blend mode.
 * The seekbars are set to a maximum of 255, with one for each of the four components of the
 * ARGB color. (Alpha, Red, Green, Blue.) Once a color has been computed using
 * {@link Color#argb(int, int, int, int)}, it is set togethe with the blend mode on the background
 * image using//ww w .j av  a2 s .  c o m
 * {@link android.widget.ImageView#setColorFilter(int, android.graphics.PorterDuff.Mode)}.
 */
public void updateTint(int color, PorterDuff.Mode mode) {
    // Set the color hint of the image: ARGB
    mHintColor = color;

    // Set the color tint mode based on the selection of the Spinner
    mMode = mode;

    // Log selection
    Log.d(TAG, String.format("Updating tint with color [ARGB: %d,%d,%d,%d] and mode [%s]", Color.alpha(color),
            Color.red(color), Color.green(color), Color.blue(color), mode.toString()));

    // Apply the color tint for the selected tint mode
    mImage.setColorFilter(mHintColor, mMode);

    // Update the text for each label with the value of each channel
    mAlphaText.setText(getString(R.string.value_alpha, Color.alpha(color)));
    mRedText.setText(getString(R.string.value_red, Color.red(color)));
    mGreenText.setText(getString(R.string.value_green, Color.green(color)));
    mBlueText.setText(getString(R.string.value_blue, Color.blue(color)));
}