@Test @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void setBackgroundTestForJellyBeanAndAfter() { DeprecationUtilities.setBackground(viewMock, R.drawable.snackbar__design_snackbar_background); verify(viewMock, times(1)).setBackground(any(Drawable.class)); verifyNoMoreInteractions(connectivityManagerMock); }
public static void setBackground(final View view, final int drawableId) { final Drawable drawable = ContextCompat.getDrawable(view.getContext(), drawableId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(drawable); } else { view.setBackgroundDrawable(drawable); } }
DeprecationUtilities { public static void setBackground(final View view, final int drawableId) { final Drawable drawable = ContextCompat.getDrawable(view.getContext(), drawableId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(drawable); } else { view.setBackgroundDrawable(drawable); } } }
DeprecationUtilities { public static void setBackground(final View view, final int drawableId) { final Drawable drawable = ContextCompat.getDrawable(view.getContext(), drawableId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(drawable); } else { view.setBackgroundDrawable(drawable); } } private  DeprecationUtilities(); }
DeprecationUtilities { public static void setBackground(final View view, final int drawableId) { final Drawable drawable = ContextCompat.getDrawable(view.getContext(), drawableId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(drawable); } else { view.setBackgroundDrawable(drawable); } } private  DeprecationUtilities(); static void setBackground(final View view, final int drawableId); }
DeprecationUtilities { public static void setBackground(final View view, final int drawableId) { final Drawable drawable = ContextCompat.getDrawable(view.getContext(), drawableId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(drawable); } else { view.setBackgroundDrawable(drawable); } } private  DeprecationUtilities(); static void setBackground(final View view, final int drawableId);  }