content: package com.github.airsaid.accountbook.util;
  
  import android.content.Context;
  import android.util.DisplayMetrics;
  import android.view.WindowManager;
  
  /**
   * @author Airsaid
   * @github https://github.com/airsaid
   * @date 2017/5/4
   * @desc 屏幕相关工具类。
   */
  public class WindowUtils {
  
      private WindowUtils() {
          throw new UnsupportedOperationException("cannot be instantiated");
      }
  
      /**
       * 获得屏幕宽度
       */
      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;
      }
  
      /**
       * 获得屏幕宽高度
       */
      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;
      }
  
  }
  