/** * Returns {@code true} if called on a background thread, {@code false} otherwise. */ public static boolean isOnBackgroundThread() { return !isOnMainThread(); }
/** * Throws an {@link java.lang.IllegalArgumentException} if called on a thread other than the main * thread. */ public static void assertMainThread() { if (!isOnMainThread()) { throw new IllegalArgumentException("You must call this method on the main thread"); } }
@NonNull public RequestManager get(@NonNull Context context) { if (context == null) { throw new IllegalArgumentException("You cannot start a load on a null Context"); } else if (Util.isOnMainThread() && !(context instanceof Application)) { if (context instanceof FragmentActivity) { return get((FragmentActivity) context); } else if (context instanceof Activity) { return get((Activity) context); } else if (context instanceof ContextWrapper) { return get(((ContextWrapper) context).getBaseContext()); } } return getApplicationManager(context); }
/** * Returns {@code true} if called on the main thread, {@code false} otherwise. */ public static boolean isOnBackgroundThread() { return !isOnMainThread(); }
/** * Throws an {@link IllegalArgumentException} if called on a thread other than the main thread. */ public static void assertMainThread() { if (!isOnMainThread()) { throw new IllegalArgumentException("You must call this method on the main thread"); } }
public RequestManager get(Context context) { if (context == null) { throw new IllegalArgumentException("You cannot start a load on a null Context"); } else if (Util.isOnMainThread() && !(context instanceof Application)) { if (context instanceof FragmentActivity) { return get((FragmentActivity) context); } else if (context instanceof Activity) { return get((Activity) context); } else if (context instanceof ContextWrapper) { return get(((ContextWrapper) context).getBaseContext()); } } return getApplicationManager(context); }
/** * Returns {@code true} if called on a background thread, {@code false} otherwise. */ public static boolean isOnBackgroundThread() { return !isOnMainThread(); }
/** * Throws an {@link java.lang.IllegalArgumentException} if called on a thread other than the main * thread. */ public static void assertMainThread() { if (!isOnMainThread()) { throw new IllegalArgumentException("You must call this method on the main thread"); } }
/** * Cancel any pending loads Glide may have for the target and free any resources (such as * {@link Bitmap}s) that may have been loaded for the target so they may be reused. * * @param target The Target to cancel loads for. */ public void clear(@Nullable final Target<?> target) { if (target == null) { return; } if (Util.isOnMainThread()) { untrackOrDelegate(target); } else { mainHandler.post(new Runnable() { @Override public void run() { clear(target); } }); } }
@Override protected void onDestroy() { super.onDestroy(); handler.removeCallbacksAndMessages(null); if(Util.isOnMainThread()) { Glide.get(this).clearMemory(); } }
public RequestManager get(Context context) { if (context == null) { throw new IllegalArgumentException("You cannot start a load on a null Context"); } else if (Util.isOnMainThread() && !(context instanceof Application)) { if (context instanceof FragmentActivity) { return get((FragmentActivity) context); } else if (context instanceof Activity) { return get((Activity) context); } else if (context instanceof ContextWrapper) { return get(((ContextWrapper) context).getBaseContext()); } } return getApplicationManager(context); }
@Override public void onDestroy() { super.onDestroy(); if(Util.isOnMainThread()) { Glide.get(getActivity()).clearMemory(); } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.WavesTheme_Translucent_Dribbble); LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper); View view = localInflater.inflate(R.layout.fragment_shot, container, false); this.initWidget(view); revealView.setState(RevealView.REVEALING); this.getComments(); if (Util.isOnMainThread()) { if (Util.isOnMainThread()) { Glide.with(getActivity()) // shot. .load(shotItem.imageUri) .crossFade(300) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .listener(palette) .into(shotImage); } Glide.with(getActivity()) // icon. .load(shotItem.imageUri) .crossFade(300) .diskCacheStrategy(DiskCacheStrategy.NONE) .into(playerIcon); } return view; }