本文整理匯總了Java中org.chromium.chrome.browser.tabmodel.DocumentModeAssassin.DocumentModeAssassinObserver類的典型用法代碼示例。如果您正苦於以下問題:Java DocumentModeAssassinObserver類的具體用法?Java DocumentModeAssassinObserver怎麽用?Java DocumentModeAssassinObserver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DocumentModeAssassinObserver類屬於org.chromium.chrome.browser.tabmodel.DocumentModeAssassin包,在下文中一共展示了DocumentModeAssassinObserver類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: UpgradeActivity
import org.chromium.chrome.browser.tabmodel.DocumentModeAssassin.DocumentModeAssassinObserver; //導入依賴的package包/類
public UpgradeActivity() {
mHandler = new Handler(Looper.getMainLooper());
mObserver = new DocumentModeAssassinObserver() {
@Override
public void onStageChange(int newStage) {
if (newStage != DocumentModeAssassin.STAGE_DONE) return;
DocumentModeAssassin.getInstance().removeObserver(this);
// Always post to avoid any issues that could arise from firing the Runnable
// while other Observers are being alerted.
long msElapsed = System.currentTimeMillis() - mStartTimestamp;
long msRemaining = Math.max(0, MIN_MS_TO_DISPLAY_ACTIVITY - msElapsed);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
continueApplicationLaunch();
}
}, msRemaining);
}
};
}
示例2: onHandleIntent
import org.chromium.chrome.browser.tabmodel.DocumentModeAssassin.DocumentModeAssassinObserver; //導入依賴的package包/類
@Override
protected void onHandleIntent(Intent intent) {
final DocumentModeAssassin assassin = DocumentModeAssassin.getInstance();
if (!assassin.isMigrationNecessary()) return;
final CountDownLatch finishSignal = new CountDownLatch(1);
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
if (assassin.isMigrationNecessary()) {
// Kick off migration if it hasn't already started.
DocumentModeAssassinObserver observer = new DocumentModeAssassinObserver() {
@Override
public void onStageChange(int newStage) {
if (newStage != DocumentModeAssassin.STAGE_DONE) return;
assassin.removeObserver(this);
finishSignal.countDown();
}
};
assassin.addObserver(observer);
assassin.migrateFromDocumentToTabbedMode();
} else {
// Migration finished in the background.
finishSignal.countDown();
}
}
});
try {
boolean success = finishSignal.await(TIMEOUT_MS, TimeUnit.MILLISECONDS);
Log.d(TAG, "Migration completed. Status: " + success);
} catch (InterruptedException e) {
Log.e(TAG, "Failed to migrate user on time.");
}
}