本文整理汇总了Java中android.support.customtabs.CustomTabsSessionToken.equals方法的典型用法代码示例。如果您正苦于以下问题:Java CustomTabsSessionToken.equals方法的具体用法?Java CustomTabsSessionToken.equals怎么用?Java CustomTabsSessionToken.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.customtabs.CustomTabsSessionToken
的用法示例。
在下文中一共展示了CustomTabsSessionToken.equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleInActiveContentIfNeeded
import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/**
* Used to check whether an incoming intent can be handled by the
* current {@link CustomTabContentHandler}.
* @return Whether the active {@link CustomTabContentHandler} has handled the intent.
*/
public static boolean handleInActiveContentIfNeeded(Intent intent) {
if (sActiveContentHandler == null) return false;
if (sActiveContentHandler.shouldIgnoreIntent(intent)) {
Log.w(TAG, "Incoming intent to Custom Tab was ignored.");
return false;
}
CustomTabsSessionToken session = CustomTabsSessionToken.getSessionTokenFromIntent(intent);
if (session == null || !session.equals(sActiveContentHandler.getSession())) return false;
String url = IntentHandler.getUrlFromIntent(intent);
if (TextUtils.isEmpty(url)) return false;
sActiveContentHandler.loadUrlAndTrackFromTimestamp(new LoadUrlParams(url),
IntentHandler.getTimestampFromIntent(intent));
return true;
}
示例2: cancelSpeculation
import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/** Cancels the speculation for a given session, or any session if null. */
void cancelSpeculation(CustomTabsSessionToken session) {
ThreadUtils.assertOnUiThread();
if (mSpeculation == null) return;
if (session == null || session.equals(mSpeculation.session)) {
switch (mSpeculation.speculationMode) {
case SpeculationParams.PRERENDER:
if (mSpeculation.webContents == null) return;
mExternalPrerenderHandler.cancelCurrentPrerender();
mSpeculation.webContents.destroy();
break;
case SpeculationParams.PREFETCH:
Profile profile = Profile.getLastUsedProfile();
new LoadingPredictor(profile).cancelPageLoadHint(mSpeculation.url);
break;
default:
return;
}
mSpeculation = null;
}
}
示例3: takePrerenderedUrl
import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/**
* Transfers a prerendered WebContents if one exists.
*
* This resets the internal WebContents; a subsequent call to this method
* returns null. Must be called from the UI thread.
* If a prerender exists for a different URL with the same sessionId or with
* a different referrer, then this is treated as a mispredict from the
* client application, and cancels the previous prerender. This is done to
* avoid keeping resources laying around for too long, but is subject to a
* race condition, as the following scenario is possible:
* The application calls:
* 1. mayLaunchUrl(url1) <- IPC
* 2. loadUrl(url2) <- Intent
* 3. mayLaunchUrl(url3) <- IPC
* If the IPC for url3 arrives before the intent for url2, then this methods
* cancels the prerender for url3, which is unexpected. On the other
* hand, not cancelling the previous prerender leads to wasted resources, as
* a WebContents is lingering. This can be solved by requiring applications
* to call mayLaunchUrl(null) to cancel a current prerender before 2, that
* is for a mispredict.
*
* Note that this methods accepts URLs that don't exactly match the initially
* prerendered URL. More precisely, the #fragment is ignored. In this case,
* the client needs to navigate to the correct URL after the WebContents
* swap. This can be tested using {@link UrlUtilities#urlsFragmentsDiffer()}.
*
* @param session The Binder object identifying a session.
* @param url The URL the WebContents is for.
* @param referrer The referrer to use for |url|.
* @return The prerendered WebContents, or null.
*/
WebContents takePrerenderedUrl(CustomTabsSessionToken session, String url, String referrer) {
ThreadUtils.assertOnUiThread();
if (mSpeculation == null || session == null || !session.equals(mSpeculation.session)) {
return null;
}
if (mSpeculation.prefetchOnly) {
Profile profile = Profile.getLastUsedProfile();
new ResourcePrefetchPredictor(profile).stopPrefetching(mSpeculation.url);
mSpeculation = null;
return null;
}
WebContents webContents = mSpeculation.webContents;
String prerenderedUrl = mSpeculation.url;
String prerenderReferrer = mSpeculation.referrer;
if (referrer == null) referrer = "";
boolean ignoreFragments = mClientManager.getIgnoreFragmentsForSession(session);
boolean urlsMatch = TextUtils.equals(prerenderedUrl, url)
|| (ignoreFragments
&& UrlUtilities.urlsMatchIgnoringFragments(prerenderedUrl, url));
WebContents result = null;
if (urlsMatch && TextUtils.equals(prerenderReferrer, referrer)) {
result = webContents;
mSpeculation = null;
} else {
cancelPrerender(session);
}
if (!mClientManager.usesDefaultSessionParameters(session) && webContents != null) {
RecordHistogram.recordBooleanHistogram(
"CustomTabs.NonDefaultSessionPrerenderMatched", result != null);
}
return result;
}
示例4: getPrerenderedUrl
import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/** Returns the URL prerendered for a session, or null. */
String getPrerenderedUrl(CustomTabsSessionToken session) {
if (mSpeculation == null || session == null || !session.equals(mSpeculation.session)) {
return null;
}
return mSpeculation.webContents != null ? mSpeculation.url : null;
}
示例5: cancelPrerender
import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/** Cancels a prerender for a given session, or any session if null. */
void cancelPrerender(CustomTabsSessionToken session) {
ThreadUtils.assertOnUiThread();
if (mSpeculation != null && (session == null || session.equals(mSpeculation.session))
&& mSpeculation.webContents != null) {
mExternalPrerenderHandler.cancelCurrentPrerender();
mSpeculation.webContents.destroy();
mSpeculation = null;
}
}
示例6: takePrerenderedUrl
import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/**
* Transfers a prerendered WebContents if one exists.
*
* This resets the internal WebContents; a subsequent call to this method
* returns null. Must be called from the UI thread.
* If a prerender exists for a different URL with the same sessionId or with
* a different referrer, then this is treated as a mispredict from the
* client application, and cancels the previous prerender. This is done to
* avoid keeping resources laying around for too long, but is subject to a
* race condition, as the following scenario is possible:
* The application calls:
* 1. mayLaunchUrl(url1) <- IPC
* 2. loadUrl(url2) <- Intent
* 3. mayLaunchUrl(url3) <- IPC
* If the IPC for url3 arrives before the intent for url2, then this methods
* cancels the prerender for url3, which is unexpected. On the other
* hand, not cancelling the previous prerender leads to wasted resources, as
* a WebContents is lingering. This can be solved by requiring applications
* to call mayLaunchUrl(null) to cancel a current prerender before 2, that
* is for a mispredict.
*
* Note that this methods accepts URLs that don't exactly match the initially
* prerendered URL. More precisely, the #fragment is ignored. In this case,
* the client needs to navigate to the correct URL after the WebContents
* swap. This can be tested using {@link UrlUtilities#urlsFragmentsDiffer()}.
*
* @param session The Binder object identifying a session.
* @param url The URL the WebContents is for.
* @param referrer The referrer to use for |url|.
* @return The prerendered WebContents, or null.
*/
WebContents takePrerenderedUrl(CustomTabsSessionToken session, String url, String referrer) {
ThreadUtils.assertOnUiThread();
if (mSpeculation == null || session == null || !session.equals(mSpeculation.session)) {
return null;
}
if (mSpeculation.speculationMode == SpeculationParams.PREFETCH) {
cancelSpeculation(session);
return null;
}
WebContents webContents = mSpeculation.webContents;
String prerenderedUrl = mSpeculation.url;
String prerenderReferrer = mSpeculation.referrer;
if (referrer == null) referrer = "";
boolean ignoreFragments = mClientManager.getIgnoreFragmentsForSession(session);
boolean urlsMatch = TextUtils.equals(prerenderedUrl, url)
|| (ignoreFragments
&& UrlUtilities.urlsMatchIgnoringFragments(prerenderedUrl, url));
WebContents result = null;
if (urlsMatch && TextUtils.equals(prerenderReferrer, referrer)) {
result = webContents;
mSpeculation = null;
} else {
cancelSpeculation(session);
}
if (!mClientManager.usesDefaultSessionParameters(session) && webContents != null) {
RecordHistogram.recordBooleanHistogram(
"CustomTabs.NonDefaultSessionPrerenderMatched", result != null);
}
return result;
}
示例7: getSpeculatedUrl
import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
String getSpeculatedUrl(CustomTabsSessionToken session) {
if (mSpeculation == null || session == null || !session.equals(mSpeculation.session)) {
return null;
}
switch (mSpeculation.speculationMode) {
case SpeculationParams.PRERENDER:
return mSpeculation.webContents != null ? mSpeculation.url : null;
case SpeculationParams.HIDDEN_TAB:
return mSpeculation.tab != null ? mSpeculation.url : null;
default:
return null;
}
}