/*
 * Copyright (C) 2015, 程序亦非猿
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.yifeiyuan.utils;

import android.content.Context;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.WindowManager;

/**
 * Created by 程序亦非猿 on 16/1/7.
 */
public class ScreenUtil {

    /**
     * 获得屏幕高度
     *
     * @param context
     * @return
     */
    public static int getScreenWidth(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics outMetrics = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(outMetrics);
        return outMetrics.widthPixels;
    }

    /**
     * 获得屏幕宽度
     *
     * @param context
     * @return
     */
    public static int getScreenHeight(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics outMetrics = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(outMetrics);
        return outMetrics.heightPixels;
    }

    /**
     * 获取状态栏高度
     * @param context
     * @return
     */
    public static int getStatusBarHeight(Context context) {
        int result = 0;

        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");

        if (resourceId > 0) {
            result = context.getResources().getDimensionPixelSize(resourceId);
        }

        return result;
    }

    /**
     * 获取toolbar的高度
     * @param context
     * @return
     */
    public static int getToolbarHeight(Context context) {
        TypedValue typedValue = new TypedValue();

        if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) {
            return TypedValue.complexToDimensionPixelSize(typedValue.data, context.getResources().getDisplayMetrics());
        }

        return 0;
    }
}

@@ -647,16 +647,59 @@
 ontext;%0A
+import android.support.annotation.NonNull;%0A
 import a
@@ -971,16 +971,25 @@
 enWidth(
+@NonNull 
 Context 
@@ -1359,24 +1359,33 @@
 creenHeight(
+@NonNull 
 Context cont
@@ -1695,32 +1695,44 @@
 t%0A     * @return
+ %E7%8A%B6%E6%80%81%E6%A0%8F%E9%AB%98%E5%BA%A6  %E9%BB%98%E8%AE%A4%E4%B8%BA0
 %0A     */%0A    pub
@@ -1757,32 +1757,41 @@
 StatusBarHeight(
+@NonNull 
 Context context)
@@ -2129,32 +2129,37 @@
 t%0A     * @return
+ %E9%BB%98%E8%AE%A4%E4%B8%BA0
 %0A     */%0A    pub
@@ -2190,16 +2190,25 @@
 rHeight(
+@NonNull 
 Context 

update comments