Example usage for android.widget ProgressBar setIndeterminateTintList

List of usage examples for android.widget ProgressBar setIndeterminateTintList

Introduction

In this page you can find the example usage for android.widget ProgressBar setIndeterminateTintList.

Prototype

@RemotableViewMethod
public void setIndeterminateTintList(@Nullable ColorStateList tint) 

Source Link

Document

Applies a tint to the indeterminate drawable.

Usage

From source file:uk.ac.horizon.artcodes.scanner.ScannerActivity.java

/**
 * This function sets the colors of the scan screen (only if the experience contains colors).
 *//*from   w  ww .jav a 2 s.  c  om*/
public void setExperienceStyle() {
    if (this.experience != null) {
        if (this.experience.getBackgroundColor() != null || this.experience.getForegroundColor() != null) {

            if (this.experience.getBackgroundColor() != null) {
                View topFrame = findViewById(R.id.topView);
                View bottomFrame = findViewById(R.id.bottomView);
                int backgroundColor = Color.parseColor(this.experience.getBackgroundColor());
                // If no transparency is set add default transparency to background:
                if (this.experience.getBackgroundColor().length() <= 7)
                    backgroundColor &= 0xbbffffff;
                if (topFrame != null)
                    topFrame.setBackgroundColor(backgroundColor);
                if (bottomFrame != null)
                    bottomFrame.setBackgroundColor(backgroundColor);
            }

            if (this.experience.getForegroundColor() != null) {
                int foregroundColor = Color.parseColor(this.experience.getForegroundColor());
                Toolbar v = (Toolbar) findViewById(R.id.toolbar);
                if (v != null) {
                    v.setTitleTextColor(foregroundColor);
                    // set back icon color:
                    try {
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                            v.getNavigationIcon().setTint(foregroundColor);
                        } else {
                            v.getNavigationIcon().setColorFilter(
                                    new PorterDuffColorFilter(foregroundColor, PorterDuff.Mode.MULTIPLY));
                        }
                    } catch (NullPointerException e) {
                        Log.w("", "Exception setting toolbar icon colour.", e);
                    }
                }

                TextView scanScreenTextTitle = (TextView) findViewById(R.id.scanScreenTextTitle);
                if (scanScreenTextTitle != null) {
                    scanScreenTextTitle.setTextColor(foregroundColor);
                }
                TextView scanScreenTextDesc = (TextView) findViewById(R.id.scanScreenTextDesc);
                if (scanScreenTextDesc != null) {
                    scanScreenTextDesc.setTextColor(foregroundColor);
                }
            }

        }

        if (this.experience.getHighlightBackgroundColor() != null
                && this.experience.getHighlightForegroundColor() != null) {
            int foregroundColor = Color.parseColor(this.experience.getHighlightForegroundColor());
            int backgroundColor = Color.parseColor(this.experience.getHighlightBackgroundColor());

            Button b = (Button) findViewById(R.id.scan_event_button);
            if (b != null) {
                b.setTextColor(foregroundColor);
                b.setBackgroundColor(backgroundColor);
            }
            ProgressBar pb = (ProgressBar) findViewById(R.id.progressBar);
            if (pb != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                pb.setIndeterminateTintList(ColorStateList.valueOf(backgroundColor));
            }
        }

        if (this.experience.getScanScreenTextTitle() != null) {
            TextView textView = (TextView) findViewById(R.id.scanScreenTextTitle);
            if (textView != null) {
                textView.setVisibility(View.VISIBLE);
                textView.setText(this.experience.getScanScreenTextTitle());
            }
        }
        if (this.experience.getScanScreenTextDesciption() != null) {
            TextView textView = (TextView) findViewById(R.id.scanScreenTextDesc);
            if (textView != null) {
                textView.setVisibility(View.VISIBLE);
                textView.setText(this.experience.getScanScreenTextDesciption());
            }
        }

    }
}