/*
 * 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.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;
    }
}

@@ -683,16 +683,48 @@
 etrics;%0A
+import android.util.TypedValue;%0A
 import a
@@ -1581,11 +1581,856 @@
 s;%0A    %7D
+%0A%0A    /**%0A     * %E8%8E%B7%E5%8F%96%E7%8A%B6%E6%80%81%E6%A0%8F%E9%AB%98%E5%BA%A6%0A     * @param context%0A     * @return%0A     */%0A    public static int getStatusBarHeight(Context context) %7B%0A        int result = 0;%0A%0A        int resourceId = context.getResources().getIdentifier(%22status_bar_height%22, %22dimen%22, %22android%22);%0A%0A        if (resourceId %3E 0) %7B%0A            result = context.getResources().getDimensionPixelSize(resourceId);%0A        %7D%0A%0A        return result;%0A    %7D%0A%0A    /**%0A     * %E8%8E%B7%E5%8F%96toolbar%E7%9A%84%E9%AB%98%E5%BA%A6%0A     * @param context%0A     * @return%0A     */%0A    public static int getToolbarHeight(Context context) %7B%0A        TypedValue typedValue = new TypedValue();%0A%0A        if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) %7B%0A            return TypedValue.complexToDimensionPixelSize(typedValue.data, context.getResources().getDisplayMetrics());%0A        %7D%0A%0A        return 0;%0A    %7D
 %0A%7D%0A

add methods