本文整理汇总了Java中android.os.Handler.postAtFrontOfQueue方法的典型用法代码示例。如果您正苦于以下问题:Java Handler.postAtFrontOfQueue方法的具体用法?Java Handler.postAtFrontOfQueue怎么用?Java Handler.postAtFrontOfQueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Handler
的用法示例。
在下文中一共展示了Handler.postAtFrontOfQueue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeAtFrontUninterruptibly
import android.os.Handler; //导入方法依赖的package包/类
/**
* Post |runner| to |handler|, at the front, and wait for
* completion.
*/
public static void invokeAtFrontUninterruptibly(final Handler handler, final Runnable runner) {
if (handler.getLooper().getThread() == Thread.currentThread()) {
runner.run();
return;
}
final CountDownLatch barrier = new CountDownLatch(1);
handler.postAtFrontOfQueue(new Runnable() {
@Override
public void run() {
runner.run();
barrier.countDown();
}
});
awaitUninterruptibly(barrier);
}
示例2: isCanceled
import android.os.Handler; //导入方法依赖的package包/类
@Override
public boolean isCanceled() {
// This is a little bit of a hack, but hey, why not.
mCache.clear();
if (mCallback != null) {
Handler handler = new Handler(Looper.getMainLooper());
handler.postAtFrontOfQueue(mCallback);
}
return true;
}
示例3: setupWebCache
import android.os.Handler; //导入方法依赖的package包/类
private void setupWebCache(final Context context) {
Handler handler = new Handler(Looper.getMainLooper());
handler.postAtFrontOfQueue(new Runnable() {
@Override
public void run() {
dfpWebCache = new WebView(context);
dfpWebCache.getSettings().setDomStorageEnabled(true);
dfpWebCache.getSettings().setJavaScriptEnabled(true);
}
});
}
示例4: saveCacheForWeb
import android.os.Handler; //导入方法依赖的package包/类
private void saveCacheForWeb(final String cacheId, final String bid) {
Handler handler = new Handler(Looper.getMainLooper());
handler.postAtFrontOfQueue(new Runnable() {
@Override
public void run() {
String escapedBid = StringEscapeUtils.escapeEcmaScript(bid);
String result = "<html><script> localStorage.setItem('" + cacheId + "', '" + escapedBid + "');</script></html>";
if (dfpWebCache != null) {
dfpWebCache.loadDataWithBaseURL("https://pubads.g.doubleclick.net", result, "text/html", null, null);
}
}
});
}
示例5: invokeNowUninterruptibly
import android.os.Handler; //导入方法依赖的package包/类
public static void invokeNowUninterruptibly(final Handler handler, final Runnable runner) {
final CountDownLatch barrier = new CountDownLatch(1);
handler.postAtFrontOfQueue(new Runnable() {
@Override
public void run() {
runner.run();
barrier.countDown();
}
});
awaitUninterruptibly(barrier);
}