本文整理汇总了Java中android.net.UrlQuerySanitizer类的典型用法代码示例。如果您正苦于以下问题:Java UrlQuerySanitizer类的具体用法?Java UrlQuerySanitizer怎么用?Java UrlQuerySanitizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UrlQuerySanitizer类属于android.net包,在下文中一共展示了UrlQuerySanitizer类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paramLoader
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
public static void paramLoader(WebView view, String url) {
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
sanitizer.setAllowUnregisteredParamaters(true);
sanitizer.parseUrl(url);
String param = sanitizer.getValue("pageload");
if (param != null) {
switch (param) {
case "composer":
view.loadUrl("javascript:(function()%7Btry%7Bdocument.querySelector('button%5Bname%3D%22view_overview%22%5D').click()%7Dcatch(_)%7B%7D%7D)()");
break;
case "composer_photo":
view.loadUrl("javascript:(function()%7Btry%7Bdocument.querySelector('button%5Bname%3D%22view_photo%22%5D').click()%7Dcatch(_)%7B%7D%7D)()");
break;
case "composer_checkin":
view.loadUrl("javascript:(function()%7Btry%7Bdocument.querySelector('button%5Bname%3D%22view_location%22%5D').click()%7Dcatch(_)%7B%7D%7D)()");
break;
default:
break;
}
}
}
示例2: handleIntent
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
@Override
protected void handleIntent(KolibriWebView view, Intent intent) {
final UrlQuerySanitizer sanitizer = new UrlQuerySanitizer(intent.getData().toString());
view.setIntent(intent);
if (sanitizer.hasParameter("url")) {
final Uri url;
if (intent.hasExtra(Kolibri.EXTRA_DEEPLINK)) {
url = Uri.parse(intent.getStringExtra(Kolibri.EXTRA_DEEPLINK));
} else {
url = Uri.parse(intent.getData().getQueryParameter("url"));
}
final boolean handled = view.handleUri(url);
if (!handled) {
view.loadUrl(url.toString());
}
}
}
示例3: checkParams
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
private boolean checkParams(String url, String url2) {
try {
URL fullUrl = new URL(url2);
String baseUrl = fullUrl.getProtocol() + "://" + fullUrl.getHost() + fullUrl.getPath();
Log.d("BASEURL", "checkParams: " + baseUrl);
if (!url.contains(baseUrl)) {
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
try {
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer(url);
UrlQuerySanitizer sanitizer2 = new UrlQuerySanitizer(url2);
String paymentId = sanitizer.getValue("paymentId");
String paymentId2 = sanitizer2.getValue("paymentId");
String referenceId = sanitizer.getValue("referenceId");
String referenceId2 = sanitizer2.getValue("referenceId");
if (paymentId.equalsIgnoreCase(paymentId2) && referenceId.equalsIgnoreCase(referenceId2)) {
return true;
}
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
示例4: composeFormParamsMap
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
private Map<String, RequestBody> composeFormParamsMap(String source) {
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
sanitizer.registerParameter(ApiConstants.AMAZON_EXPIRES, UrlQuerySanitizer.getSpaceLegal());
sanitizer.setAllowUnregisteredParamaters(true);
sanitizer.parseUrl(source);
Map<String, RequestBody> result = new HashMap<>();
result.put(ApiConstants.AMAZON_CONTENT_TYPE,
createPartFromString(sanitizer.getValue(ApiConstants.AMAZON_CONTENT_TYPE)));
result.put(ApiConstants.AMAZON_EXPIRES,
createPartFromString(sanitizer.getValue(ApiConstants.AMAZON_EXPIRES)));
result.put(ApiConstants.AMAZON_ACL,
createPartFromString(sanitizer.getValue(ApiConstants.AMAZON_ACL)));
result.put(ApiConstants.AMAZON_KEY,
createPartFromString(sanitizer.getValue(ApiConstants.AMAZON_KEY)));
result.put(ApiConstants.AMAZON_POLICY,
createPartFromString(sanitizer.getValue(ApiConstants.AMAZON_POLICY)));
result.put(ApiConstants.AMAZON_ACTION_STATUS,
createPartFromString(sanitizer.getValue(ApiConstants.AMAZON_ACTION_STATUS)));
result.put(ApiConstants.AMAZON_ALGORITHM,
createPartFromString(sanitizer.getValue(ApiConstants.AMAZON_ALGORITHM)));
result.put(ApiConstants.AMAZON_CREDENTIAL,
createPartFromString(sanitizer.getValue(ApiConstants.AMAZON_CREDENTIAL)));
result.put(ApiConstants.AMAZON_DATE,
createPartFromString(sanitizer.getValue(ApiConstants.AMAZON_DATE)));
result.put(ApiConstants.AMAZON_SIGNATURE,
createPartFromString(sanitizer.getValue(ApiConstants.AMAZON_SIGNATURE)));
return result;
}
示例5: buildAnimation
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
public static XulDrawable buildAnimation(InputStream stream, String url, String imageKey) {
if (stream == null) {
return null;
}
UrlQuerySanitizer s = new UrlQuerySanitizer(url);
boolean noLoop = s.hasParameter("NoLoop");
boolean noTransparent = s.hasParameter("noTransparent");
float speed = XulUtils.tryParseFloat(s.getValue("Speed"), 1.0f);
if (speed <= 0) {
speed = 0.01f;
}
XulGIFDecoder.GIFFrame[] frames = XulGIFDecoder.decode(stream, noLoop, noTransparent);
if (frames.length == 1) {
XulGIFDecoder.GIFStaticRender staticRenderer = XulGIFDecoder.createStaticRenderer(frames, noTransparent);
return staticRenderer.extractDrawable(url, imageKey);
} else {
XulGIFAnimationDrawable drawable = new XulGIFAnimationDrawable();
drawable._gifRender = XulGIFDecoder.createAnimationRenderer(frames, noLoop, noTransparent);
drawable._url = url;
drawable._key = imageKey;
drawable._speed = speed;
return drawable;
}
}
示例6: initWebView
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void initWebView() {
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith(ApiConfig.REDIRECT_URI)) {
List<UrlQuerySanitizer.ParameterValuePair> pvpList = new UrlQuerySanitizer(url)
.getParameterList();
for (UrlQuerySanitizer.ParameterValuePair pvp : pvpList) {
if ("code".equals(pvp.mParameter)) {
Intent data = new Intent();
data.putExtra(CODE, pvp.mValue);
setResult(RESULT_OK, data);
finish();
break;
}
}
} else {
webView.loadUrl(url);
}
return true;
}
});
webView.loadUrl(url);
}
示例7: c
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
private void c(Uri paramUri)
{
String str1 = paramUri.getPath();
an localan = (an)this.iU.get(str1);
if (localan != null)
{
HashMap localHashMap = new HashMap();
UrlQuerySanitizer localUrlQuerySanitizer = new UrlQuerySanitizer();
localUrlQuerySanitizer.setAllowUnregisteredParamaters(true);
localUrlQuerySanitizer.setUnregisteredParameterValueSanitizer(UrlQuerySanitizer.getAllButNulLegal());
localUrlQuerySanitizer.parseUrl(paramUri.toString());
Iterator localIterator1 = localUrlQuerySanitizer.getParameterList().iterator();
while (localIterator1.hasNext())
{
UrlQuerySanitizer.ParameterValuePair localParameterValuePair = (UrlQuerySanitizer.ParameterValuePair)localIterator1.next();
localHashMap.put(localParameterValuePair.mParameter, localParameterValuePair.mValue);
}
if (ct.n(2))
{
ct.u("Received GMSG: " + str1);
Iterator localIterator2 = localHashMap.keySet().iterator();
while (localIterator2.hasNext())
{
String str2 = (String)localIterator2.next();
ct.u(" " + str2 + ": " + (String)localHashMap.get(str2));
}
}
localan.a(this.gv, localHashMap);
return;
}
ct.v("No GMSG handler found for GMSG: " + paramUri);
}
示例8: extractAuthCodeFromUrl
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
@Nullable
public static String extractAuthCodeFromUrl(@NonNull String url) {
return new UrlQuerySanitizer(url).getValue("code");
}
示例9: UriMapper
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
public UriMapper(Uri uri) {
this.setUriObject(uri);
mSanitizer = new UrlQuerySanitizer(uri.toString());
}
示例10: setUp
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
@Before
public void setUp() {
mSanitizer = new UrlQuerySanitizer();
mSanitizer.setAllowUnregisteredParamaters(true);
mSanitizer.setUnregisteredParameterValueSanitizer(UrlQuerySanitizer.getUrlAndSpaceLegal());
}
示例11: getThreadIdFromURL
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
public static Integer getThreadIdFromURL(String url) {
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer(url);
return Integer.parseInt(sanitizer.getValue("t")); // get your value
}
示例12: onPageFinished
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
@Override
public void onPageFinished(String url) {
// Only do things if logged in
if (mActivity.checkLoggedInState()) {
// Load a certain page if there is a parameter
JavaScriptHelpers.paramLoader(mWebView, url);
// Hide Orange highlight on focus
String css = HIDE_ORANGE_FOCUS;
// Hide the menu bar (but not on the composer or if disabled)
if (mPreferences.getBoolean(SettingsActivity.KEY_PREF_HIDE_MENU_BAR, true) && !url.contains("/composer/") && !url.contains("/friends/")) {
css += HIDE_MENU_BAR_CSS;
mActivity.swipeView.setEnabled(true);
} else {
mActivity.swipeView.setEnabled(false);
}
if (url.contains("mbasic.facebook.com/composer/?text=")) {
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
sanitizer.setAllowUnregisteredParamaters(true);
sanitizer.parseUrl(url);
String param = sanitizer.getValue("text");
mWebView.loadUrl("javascript:(function()%7Bdocument.querySelector('%23composerInput').innerHTML%3D'" + param + "'%7D)()");
}
// Hide the status editor on the News Feed if setting is enabled
if (mPreferences.getBoolean(SettingsActivity.KEY_PREF_HIDE_EDITOR, true)) {
css += HIDE_COMPOSER_CSS;
}
// Hide 'Sponsored' content (ads)
if (mPreferences.getBoolean(SettingsActivity.KEY_PREF_HIDE_SPONSORED, true)) {
css += HIDE_SPONSORED;
}
// Hide birthday content from News Feed
if (mPreferences.getBoolean(SettingsActivity.KEY_PREF_HIDE_BIRTHDAYS, true)) {
css += HIDE_BIRTHDAYS;
}
// Hide Top Stories button on News Feed
if (mPreferences.getBoolean(SettingsActivity.KEY_PREF_MOST_RECENT_MENU, true)) {
css += HIDE_TOP_STORIES_BUTTON;
}
// Inject the css
JavaScriptHelpers.loadCSS(mWebView, css);
// Get the currently open tab and check on the navigation menu
JavaScriptHelpers.updateCurrentTab(mWebView);
// Get the notification number
JavaScriptHelpers.updateNumsService(mWebView);
// Stop loading
mActivity.setLoading(false);
}
}
示例13: handleOnComplete
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
private void handleOnComplete(Uri uri) {
String query = uri.getQuery();
if (query == null) {
query = "";
}
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
sanitizer.setAllowUnregisteredParamaters(true);
sanitizer.setUnregisteredParameterValueSanitizer(UrlQuerySanitizer.getAllButNulLegal());
sanitizer.parseQuery(query);
String code = sanitizer.getValue("code");
String state = sanitizer.getValue("state");
String error = sanitizer.getValue("error");
if (code == null || state == null) {
Toast.makeText(this, "Invalid query string: " + query, Toast.LENGTH_LONG).show();
Log.e(TAG, String.format("Invalid query string: %s (%s, %s, %s)", query, code, state, error));
setResult(Activity.RESULT_CANCELED);
finish();
return;
}
// begin code from handleOAuthResponse
Log.d(TAG, "handleOAuthResponse: code=" + code + ", state=" + state + ", error=" + error);
if (error != null) {
Toast.makeText(this, "Error: " + error, Toast.LENGTH_LONG).show();
Log.e(TAG, "Error: " + error);
return;
}
if (!state.equals(mState)) {
Toast.makeText(this, "Invalid state: " + state, Toast.LENGTH_LONG).show();
Log.e(TAG, "Invalid state: " + state);
return;
}
Toast.makeText(this, "Got authorization code: " + code, Toast.LENGTH_SHORT).show();
Log.i(TAG, "Got authorization code: " + code);
mAuthTask = new GetTokenTask(new BetterAsyncTask.ResultListener<Pair<String,String>>() {
@Override
public void onSuccess(Pair<String, String> tokens) {
final String accessToken = tokens.first;
final String refreshToken = tokens.second;
Toast.makeText(IonAuthenticatorActivity.this,
"Got tokens: " + accessToken + ", " + refreshToken,
Toast.LENGTH_SHORT).show();
Log.i(TAG, "Got access token: " + accessToken + " and refresh token: " + refreshToken);
// TODO: get username rip
final Intent res = new Intent();
res.putExtra(AccountManager.KEY_ACCOUNT_NAME, "unknown_username");
res.putExtra(AccountManager.KEY_ACCOUNT_TYPE, IonAuthenticator.ACCOUNT_TYPE);
res.putExtra(AccountManager.KEY_AUTHTOKEN, accessToken);
res.putExtra(AccountManager.KEY_PASSWORD, refreshToken);
finishLogin(res);
finish();
}
@Override
public void onError(Exception e) {
Toast.makeText(IonAuthenticatorActivity.this, "Error: " + e, Toast.LENGTH_LONG).show();
}
});
mAuthTask.execute(code);
}
示例14: unEscape
import android.net.UrlQuerySanitizer; //导入依赖的package包/类
public final static String unEscape( String s ) {
UrlQuerySanitizer urlqs = new UrlQuerySanitizer();
return urlqs.unescape( s.replaceAll( "\\+", "_pLuS_" ) ).replaceAll( "_pLuS_", "+" );
}