Last active
March 19, 2020 06:52
-
-
Save venshine/9944be33383c4ce7f13ed4f17aa5db92 to your computer and use it in GitHub Desktop.
判断用于Glide的Context是否有效
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 判断用于Glide的Context是否有效 | |
* | |
* @param context 用于Glide的Context | |
* @return 用于Glide的Context是否有效 | |
*/ | |
public static boolean isValidContext(final Context context) { | |
if (context == null) { | |
return false; | |
} | |
if (context instanceof Activity) { | |
final Activity activity = (Activity) context; | |
return !activity.isDestroyed() && !activity.isFinishing(); | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment