Skip to content

Instantly share code, notes, and snippets.

@saurabharora90
Created January 10, 2018 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saurabharora90/219ec8f926755607d80a7b41d8ea7a6e to your computer and use it in GitHub Desktop.
Save saurabharora90/219ec8f926755607d80a7b41d8ea7a6e to your computer and use it in GitHub Desktop.
Performance at Viki
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/gray"/>
</selector>
public static @DrawableRes int getPlaceHolder(Context context, @DrawableRes int actualPlaceholder) {
if(isLowRamDevice(context))
return R.drawable.low_ram_placeholder;
else
return actualPlaceholder;
}
public static boolean isLowRamDevice(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
return activityManager != null && ActivityManagerCompat.isLowRamDevice(activityManager);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment