本文整理了Java中com.bumptech.glide.util.Util.isOnMainThread()
方法的一些代码示例,展示了Util.isOnMainThread()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.isOnMainThread()
方法的具体详情如下:
包路径:com.bumptech.glide.util.Util
类名称:Util
方法名:isOnMainThread
[英]Returns true if called on the main thread, false otherwise.
[中]如果在主线程上调用,则返回true,否则返回false。
代码示例来源:origin: bumptech/glide
/**
* Returns {@code true} if called on a background thread, {@code false} otherwise.
*/
public static boolean isOnBackgroundThread() {
return !isOnMainThread();
}
代码示例来源:origin: bumptech/glide
/**
* 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");
}
}
代码示例来源:origin: bumptech/glide
@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);
}
代码示例来源:origin: guolindev/giffun
/**
* Returns {@code true} if called on the main thread, {@code false} otherwise.
*/
public static boolean isOnBackgroundThread() {
return !isOnMainThread();
}
代码示例来源:origin: guolindev/giffun
/**
* 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");
}
}
代码示例来源:origin: guolindev/giffun
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);
}
代码示例来源:origin: mozilla-tw/Rocket
/**
* Returns {@code true} if called on a background thread, {@code false} otherwise.
*/
public static boolean isOnBackgroundThread() {
return !isOnMainThread();
}
代码示例来源:origin: mozilla-tw/Rocket
/**
* 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");
}
}
代码示例来源:origin: mozilla-tw/Rocket
/**
* 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);
}
});
}
}
代码示例来源:origin: WangDaYeeeeee/Waves
@Override
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacksAndMessages(null);
if(Util.isOnMainThread()) {
Glide.get(this).clearMemory();
}
}
代码示例来源:origin: mozilla-tw/Rocket
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);
}
代码示例来源:origin: WangDaYeeeeee/Waves
@Override
public void onDestroy() {
super.onDestroy();
if(Util.isOnMainThread()) {
Glide.get(getActivity()).clearMemory();
}
}
代码示例来源:origin: WangDaYeeeeee/Waves
@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;
}
内容来源于网络,如有侵权,请联系作者删除!