Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * This file is part of Integreat.
 *
 * Integreat is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Integreat is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Integreat.  If not, see <http://www.gnu.org/licenses/>.
 */

import android.annotation.TargetApi;
import android.content.res.ColorStateList;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Build;
import android.support.annotation.NonNull;

public class Main {
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @NonNull
    private static Drawable getPressedColorRippleDrawable(int normalColor, int pressedColor) {
        Drawable drawable = new RippleDrawable(getPressedColorSelector(normalColor, pressedColor),
                getColorDrawableFromColor(normalColor), null);
        drawable.setAlpha(70);
        return drawable;
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    @NonNull
    private static ColorStateList getPressedColorSelector(int normalColor, int pressedColor) {
        return new ColorStateList(new int[][] { new int[] { android.R.attr.state_pressed },
                new int[] { android.R.attr.state_focused }, new int[] { android.R.attr.state_activated },
                new int[] {} }, new int[] { pressedColor, pressedColor, pressedColor, normalColor });
    }

    @NonNull
    private static ColorDrawable getColorDrawableFromColor(int color) {
        return new ColorDrawable(color);
    }
}