Example usage for java.lang NoSuchMethodError toString

List of usage examples for java.lang NoSuchMethodError toString

Introduction

In this page you can find the example usage for java.lang NoSuchMethodError toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.ijiaban.yinxiang.MainActivity.java

/**
 * Changes the color of the action bar and status bar
 * @param color ARGB Color to apply/* w  ww . ja v  a 2s. c  o  m*/
 */
@SuppressLint("NewApi")
private void setColor(int color) {
    View mainView = findViewById(R.id.rootView);
    if (mainView == null) {
        Log.e("MainActivity:setColor()", "WARNING: Did not find root view.");
    } else {
        mainView.setBackgroundColor(color);
    }

    /*
    Set the action bar colour to the average colour of the generated image and
    the status bar colour for Android Version >= 5.0 accordingly.
    */
    try {
        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
    } catch (NullPointerException nullError) {
        Log.e("MainActivity:generateImageTask()", nullError.toString());
    } catch (NoSuchMethodError methodError) {
        Log.e("MainActivity:generateImageTask()", methodError.toString());
    }

    Log.d("MainActivity:generateImageTask()", "Changing status bar & action bar colour.");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // Get the window through a reference to the activity.
        Activity parent = (Activity) mContext;
        Window window = parent.getWindow();
        // Set the status bar colour of this window.
        int statusColor = ColorUtilities.getDarkenedColor(color);
        window.setStatusBarColor(statusColor);
    }
}