本文整理匯總了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);
}