content: package cn.addapp.pickers.util;
  
  import android.annotation.TargetApi;
  import android.content.Context;
  import android.graphics.drawable.Drawable;
  import android.os.Build;
  import android.support.annotation.DrawableRes;
  import android.view.View;
  
  /**
   * 兼容旧版&新版
   * @author matt
   * blog: addapp.cn
   */
  public class CompatUtils {
  
      @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
      public static void setBackground(View view, Drawable drawable) {
          if (Build.VERSION.SDK_INT < 16) {
              //noinspection deprecation
              view.setBackgroundDrawable(drawable);
          } else {
              view.setBackground(drawable);
          }
      }
  
      @TargetApi(Build.VERSION_CODES.LOLLIPOP)
      public static Drawable getDrawable(Context context, @DrawableRes int drawableRes) {
          if (Build.VERSION.SDK_INT < 21) {
              //noinspection deprecation
              return context.getResources().getDrawable(drawableRes);
          } else {
              return context.getDrawable(drawableRes);
          }
      }
  
  }
  