android.webkit.URLUtil源码实例Demo

java.util.zip.DeflaterInputStream#android.webkit.URLUtil源码实例Demo

下面列出了java.util.zip.DeflaterInputStream#android.webkit.URLUtil 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AntennaPodSP   文件: DownloadRequester.java
public String getMediafilename(FeedMedia media) {
    String filename;
    String titleBaseFilename = "";

    // Try to generate the filename by the item title
    if (media.getItem() != null && media.getItem().getTitle() != null) {
        String title = media.getItem().getTitle();
        // Delete reserved characters
        titleBaseFilename = title.replaceAll("[\\\\/%\\?\\*:|<>\"\\p{Cntrl}]", "");
        titleBaseFilename = titleBaseFilename.trim();
    }

    String URLBaseFilename = URLUtil.guessFileName(media.getDownload_url(),
            null, media.getMime_type());
    ;

    if (titleBaseFilename != "") {
        // Append extension
        filename = titleBaseFilename + FilenameUtils.EXTENSION_SEPARATOR +
                FilenameUtils.getExtension(URLBaseFilename);
    } else {
        // Fall back on URL file name
        filename = URLBaseFilename;
    }
    return filename;
}
 
源代码2 项目: Ninja   文件: NinjaDownloadListener.java
@Override
public void onDownloadStart(final String url, String userAgent, final String contentDisposition, final String mimeType, long contentLength) {
    final Context holder = IntentUnit.getContext();
    if (holder == null || !(holder instanceof Activity)) {
        BrowserUnit.download(context, url, contentDisposition, mimeType);
        return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(holder);
    builder.setCancelable(false);

    builder.setTitle(R.string.dialog_title_download);
    builder.setMessage(URLUtil.guessFileName(url, contentDisposition, mimeType));

    builder.setPositiveButton(R.string.dialog_button_positive, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            BrowserUnit.download(holder, url, contentDisposition, mimeType);
        }
    });

    builder.setNegativeButton(R.string.dialog_button_negative, null);
    builder.create().show();
}
 
源代码3 项目: JumpGo   文件: GeneralSettingsFragment.java
private void homePicker() {
    String currentHomepage;
    mHomepage = mPreferenceManager.getHomepage();
    if (!URLUtil.isAboutUrl(mHomepage)) {
        currentHomepage = mHomepage;
    } else {
        currentHomepage = "https://www.google.com";
    }

    BrowserDialog.showEditText(mActivity,
        R.string.title_custom_homepage,
        R.string.title_custom_homepage,
        currentHomepage,
        R.string.action_ok,
        new BrowserDialog.EditorListener() {
            @Override
            public void onClick(String text) {
                mPreferenceManager.setHomepage(text);
                home.setSummary(text);
            }
        });
}
 
源代码4 项目: FirefoxReality   文件: WindowViewModel.java
@Override
public void onChanged(ObservableBoolean o) {
    String aUrl = url.getValue().toString();
    isUrlBarButtonsVisible.postValue(new ObservableBoolean(
            !isFocused.getValue().get() &&
                    !isLibraryVisible.getValue().get() &&
                    !UrlUtils.isContentFeed(getApplication(), aUrl) &&
                    !UrlUtils.isPrivateAboutPage(getApplication(), aUrl) &&
                    (URLUtil.isHttpUrl(aUrl) || URLUtil.isHttpsUrl(aUrl)) &&
                    (
                            (SettingsStore.getInstance(getApplication()).getTrackingProtectionLevel() != ContentBlocking.EtpLevel.NONE) ||
                            isPopUpAvailable.getValue().get() ||
                            isDrmUsed.getValue().get() ||
                            isWebXRUsed.getValue().get()
                    )
    ));
}
 
源代码5 项目: NewFastFrame   文件: QQVideoDetailPresenter.java
private Observable<String> getDetailDataForTwo(String url) {
    return Observable.just(url).subscribeOn(Schedulers.io())
            .flatMap(new Function<String, ObservableSource<String>>() {
                @Override
                public ObservableSource<String> apply(String s) throws Exception {
                    StringBuilder stringBuilder = new StringBuilder("http://all.baiyug.cn:2021/QQQ/index.php").append("?url=")
                            .append(s);
                    Document document = Jsoup.connect(stringBuilder.toString()).header("Referer", "http://app.baiyug.cn").get();
                    String content = document.outerHtml();
                    String start = "url:";
                    int startIndex = content.indexOf(start);
                    String end = "pic: pic";
                    String url1 = content.substring(startIndex + start.length(), content.lastIndexOf(end)).trim();
                    String realUrl = url1.substring(1, url1.length() - 2);
                    if (URLUtil.isValidUrl(realUrl)) {
                        return Observable.just(realUrl);
                    } else {
                        return getDetailDataForThree(url);
                    }
                }
            });
}
 
源代码6 项目: NewFastFrame   文件: QQVideoDetailPresenter.java
public Observable<String> getDetailDataForFour(String url) {
    return Observable.just(url).subscribeOn(Schedulers.io())
            .flatMap((Function<String, ObservableSource<String>>) s -> {
                StringBuilder stringBuilder = new StringBuilder("http://all.baiyug.cn:2021/QQ/index.php").append("?url=")
                        .append(s);
                Document document = Jsoup.connect(stringBuilder.toString()).header("Referer", "http://app.baiyug.cn").get();
                String content = document.outerHtml();
                String start = "url:";
                int startIndex = content.indexOf(start);
                String end = "pic: pic";
                String url1 = content.substring(startIndex + start.length(), content.lastIndexOf(end)).trim();
                String realUrl = url1.substring(1, url1.length() - 2);
                if (URLUtil.isValidUrl(realUrl)) {
                    return Observable.just(realUrl);
                } else {
                    return getDetailDataForThree(url);
                }
            });
}
 
源代码7 项目: EFRConnect-android   文件: UriBeacon.java
/**
 * Creates the Uri string with embedded expansion codes.
 *
 * @param uri to be encoded
 * @return the Uri string with expansion codes.
 */
public static byte[] encodeUri(String uri) {
    if (uri.length() == 0) {
        return new byte[0];
    }
    ByteBuffer bb = ByteBuffer.allocate(uri.length());
    // UUIDs are ordered as byte array, which means most significant first
    bb.order(ByteOrder.BIG_ENDIAN);
    int position = 0;

    // Add the byte code for the scheme or return null if none
    Byte schemeCode = encodeUriScheme(uri);
    if (schemeCode == null) {
        return null;
    }
    String scheme = URI_SCHEMES.get(schemeCode);
    bb.put(schemeCode);
    position += scheme.length();

    if (URLUtil.isNetworkUrl(scheme)) {
        return encodeUrl(uri, position, bb);
    } else if ("urn:uuid:".equals(scheme)) {
        return encodeUrnUuid(uri, position, bb);
    }
    return null;
}
 
源代码8 项目: travelguide   文件: ArticleInfoDetailFragment.java
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
  if (URLUtil.isNetworkUrl(url))
  {
    final Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    if (getActivity().getPackageManager().resolveActivity(i, 0) != null)
      startActivity(i);

    return true;
  }
  else if (url.startsWith("mapswithme://"))
  {
    final PendingIntent pi = ArticleInfoListActivity.createPendingIntent(getActivity());

    // TODO: Decided to use 11 as default scale, but MapsWithMe has bug with scales,
    // so do pass 13 as a compromise.
    MapsWithMeApi.showMapsWithMeUrl(getActivity(), pi, 13, url);

    return true;
  }

  return super.shouldOverrideUrlLoading(view, url);
}
 
源代码9 项目: travelguide   文件: ArticleInfoDetailFragment.java
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
  super.onPageStarted(view, url, favicon);

  // Fix java.lang.NullPointerException at:
  // android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:71)
  final Context context = getActivity();
  if (shouldAnimate(url, context))
  {
    Utils.fadeOut(context, mWebView);
    Utils.fadeIn(context, mProgressContainer);
  }

  if (URLUtil.isFileUrl(url) && url.endsWith(".html"))
  {
    final String strippedUrl = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
    mTitle.setText(getStorage().getArticleInfoByUrl(strippedUrl).getName());
  }
}
 
源代码10 项目: edx-app-android   文件: WebViewDiscoverFragment.java
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setWebViewActionListener();
    // Check for search query in extras
    String searchQueryExtra = null;
    String searchUrl = null;

    if (savedInstanceState != null) {
        searchUrl = savedInstanceState.getString(INSTANCE_CURRENT_DISCOVER_URL, null);
    }
    if (searchUrl == null && getArguments() != null) {
        searchQueryExtra = getArguments().getString(Router.EXTRA_SEARCH_QUERY);
    }

    if (searchQueryExtra != null) {
        initSearch(searchQueryExtra);
    } else {
        loadUrl(searchUrl == null || !URLUtil.isValidUrl(searchUrl) ? getInitialUrl() : searchUrl);
    }
    if (!EventBus.getDefault().isRegistered(this)) {
        EventBus.getDefault().register(this);
    }
}
 
源代码11 项目: HtmlNative   文件: MainActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.layout_example:
            Intent i = new Intent(this, ExampleListActivity.class);
            startActivity(i);
            break;

        case R.id.about:
            Intent ii = new Intent(this, TestActivity.class);
            startActivity(ii);
            break;

        case R.id.main_in_webview:
            String url = mSearch.getText().toString();
            if (URLUtil.isValidUrl(url)) {
                Intent intent = new Intent(this, WebViewActivity.class);
                intent.putExtra(EXTAL_URL, url);
                startActivity(intent);
            } else {
                Toast.makeText(this, "not valid url", Toast.LENGTH_LONG).show();
            }
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
源代码12 项目: wallpaperboard   文件: AboutAdapter.java
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == TYPE_HEADER) {
        HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder;
        String imageUri = mContext.getString(R.string.about_image);

        if (ColorHelper.isValidColor(imageUri)) {
            headerViewHolder.image.setBackgroundColor(Color.parseColor(imageUri));
        } else if (!URLUtil.isValidUrl(imageUri)) {
            imageUri = "drawable://" + DrawableHelper.getResourceId(mContext, imageUri);
            ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image,
                    ImageConfig.getDefaultImageOptions());
        } else {
            ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image,
                    ImageConfig.getDefaultImageOptions());
        }

        String profileUri = mContext.getResources().getString(R.string.about_profile_image);
        if (!URLUtil.isValidUrl(profileUri)) {
            profileUri = "drawable://" + DrawableHelper.getResourceId(mContext, profileUri);
        }

        ImageLoader.getInstance().displayImage(profileUri, headerViewHolder.profile,
                ImageConfig.getDefaultImageOptions());
    }
}
 
源代码13 项目: Xndroid   文件: LightningWebClient.java
private boolean shouldOverrideLoading(@NonNull WebView view, @NonNull String url) {
    // Check if configured proxy is available
    if (!mProxyUtils.isProxyReady(mActivity)) {
        // User has been notified
        return true;
    }

    Map<String, String> headers = mLightningView.getRequestHeaders();

    if (mLightningView.isIncognito()) {
        // If we are in incognito, immediately load, we don't want the url to leave the app
        return continueLoadingUrl(view, url, headers);
    }
    if (URLUtil.isAboutUrl(url)) {
        // If this is an about page, immediately load, we don't need to leave the app
        return continueLoadingUrl(view, url, headers);
    }

    if (isMailOrIntent(url, view) || mIntentUtils.startActivityForUrl(view, url)) {
        // If it was a mailto: link, or an intent, or could be launched elsewhere, do that
        return true;
    }

    // If none of the special conditions was met, continue with loading the url
    return continueLoadingUrl(view, url, headers);
}
 
源代码14 项目: Xndroid   文件: GeneralSettingsFragment.java
private void homePicker() {
    String currentHomepage;
    mHomepage = mPreferenceManager.getHomepage();
    if (!URLUtil.isAboutUrl(mHomepage)) {
        currentHomepage = mHomepage;
    } else {
        currentHomepage = "https://www.google.com";
    }

    BrowserDialog.showEditText(mActivity,
        R.string.title_custom_homepage,
        R.string.title_custom_homepage,
        currentHomepage,
        R.string.action_ok,
        new BrowserDialog.EditorListener() {
            @Override
            public void onClick(String text) {
                mPreferenceManager.setHomepage(text);
                home.setSummary(text);
            }
        });
}
 
public static String decodeUri(final byte[] serviceData, final int start, final int length) {
    if (start < 0 || serviceData.length < start + length)
        return null;

    final StringBuilder uriBuilder = new StringBuilder();
    int offset = 0;
    if (offset < length) {
        byte b = serviceData[start + offset++];
        String scheme = URI_SCHEMES.get(b);
        if (scheme != null) {
            uriBuilder.append(scheme);
            if (URLUtil.isNetworkUrl(scheme)) {
                return decodeUrl(serviceData, start + offset, length - 1, uriBuilder);
            } else if ("urn:uuid:".equals(scheme)) {
                return decodeUrnUuid(serviceData, start + offset, uriBuilder);
            }
        }
        Log.w(TAG, "decodeUri unknown Uri scheme code=" + b);
    }
    return null;
}
 
源代码16 项目: uPods-android   文件: DialogFragmentAddMediaItem.java
private boolean saveMediaItem() {
    if (etMediaName.getText().toString().length() < MIN_TITLE_LENGTH) {
        Toast.makeText(getActivity(), getString(R.string.title_too_short), Toast.LENGTH_SHORT).show();
        return false;
    } else if (!URLUtil.isValidUrl(etMediaUrl.getText().toString())) {
        Toast.makeText(getActivity(), getString(R.string.url_not_correct), Toast.LENGTH_SHORT).show();
        return false;
    }

    if (mediaItemType == MediaItemType.RADIO) {
        StreamUrl streamUrl = new StreamUrl(etMediaUrl.getText().toString());
        RadioItem radioItem = new RadioItem(etMediaName.getText().toString(), streamUrl, "");
        ProfileManager.getInstance().addSubscribedMediaItem(radioItem);
        Toast.makeText(getActivity(), getString(R.string.radio_added), Toast.LENGTH_SHORT).show();
    } else if (mediaItemType == MediaItemType.PODCAST) {
        Podcast podcast = new Podcast(etMediaName.getText().toString(), etMediaUrl.getText().toString());
        ProfileManager.getInstance().addSubscribedMediaItem(podcast);
        Toast.makeText(getActivity(), getString(R.string.podcast_added), Toast.LENGTH_SHORT).show();
    }
    return true;
}
 
源代码17 项目: android-sdk   文件: ActionFactory.java
/**
 * Gets URL parameter from JSON and validates it.
 *
 * @param jsonElement - JsonElement that contains the url string.
 * @param messageType - Message type.
 * @return - Returns the verified URI string. If not valid or empty will return an empty string.
 */
public static String getUriFromJson(JsonElement jsonElement, int messageType) {
    String urlToCheck = jsonElement == null || jsonElement.isJsonNull() ? "" : jsonElement.getAsString();
    String returnUrl = "";

    //we allow deep links for in app actions and URL messages; we enforce valid network URLs
    // for the visit website action
    if ((messageType == ServerType.IN_APP && validatedUrl(urlToCheck))
            || (messageType == ServerType.URL_MESSAGE && validatedUrl(urlToCheck))
            || URLUtil.isNetworkUrl(urlToCheck)) {
        returnUrl = urlToCheck;
    }

    if (returnUrl.isEmpty()) {
        Logger.log.logError("URL is invalid, please change in the campaign settings.");
    }

    return returnUrl;
}
 
源代码18 项目: Yahala-Messenger   文件: ConnectActivity.java
private boolean validateUrl(String url) {
     if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url)) {
         return true;
     }
     FileLog.e(TAG + ": " + getText(R.string.invalid_url_title), getString(R.string.invalid_url_text, url));
/* new AlertDialog.Builder(this)
     .setTitle(getText(R.string.invalid_url_title))
     .setMessage(getString(R.string.invalid_url_text, url))
     .setCancelable(false)
     .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           dialog.cancel();
         }
       }).create().show();*/
     return false;
 }
 
源代码19 项目: Yahala-Messenger   文件: WebRtcPhone.java
private boolean validateUrl(String url) {

        if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url)) {
            return true;
        }

        FileLog.e(TAG + ": " + ApplicationLoader.applicationContext.getText(R.string.invalid_url_title), ApplicationLoader.applicationContext.getString(R.string.invalid_url_text, url));

        /* new AlertDialog.Builder(this)
        .setTitle(getText(R.string.invalid_url_title))
        .setMessage(getString(R.string.invalid_url_text, url))
        .setCancelable(false)
        .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
            }
          }).create().show();*/

        return false;
    }
 
源代码20 项目: candybar   文件: OtherAppsAdapter.java
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
    ViewHolder holder;
    if (view == null) {
        view = View.inflate(mContext, R.layout.fragment_other_apps_item_list, null);
        holder = new ViewHolder(view);
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }

    CandyBarApplication.OtherApp otherApp = mOtherApps.get(position);
    String uri = otherApp.getIcon();
    if (!URLUtil.isValidUrl(uri)) {
        uri = "drawable://" + DrawableHelper.getResourceId(mContext, uri);
    }

    ImageLoader.getInstance().displayImage(
            uri, holder.image, ImageConfig.getDefaultImageOptions(true));
    holder.title.setText(otherApp.getTitle());

    if (otherApp.getDescription() == null || otherApp.getDescription().length() == 0) {
        holder.desc.setVisibility(View.GONE);
    } else {
        holder.desc.setText(otherApp.getDescription());
        holder.desc.setVisibility(View.VISIBLE);
    }

    holder.container.setOnClickListener(v -> {
        if (!URLUtil.isValidUrl(otherApp.getUrl())) return;

        try {
            mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(otherApp.getUrl())));
        } catch (ActivityNotFoundException e) {
            LogUtil.e(Log.getStackTraceString(e));
        }
    });
    return view;
}
 
源代码21 项目: candybar   文件: CreditsAdapter.java
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
    ViewHolder holder;
    if (view == null) {
        view = View.inflate(mContext, R.layout.fragment_credits_item_list, null);
        holder = new ViewHolder(view);
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }

    Credit credit = mCredits.get(position);
    holder.title.setText(credit.getName());
    holder.subtitle.setText(credit.getContribution());
    holder.container.setOnClickListener(view1 -> {
        String link = credit.getLink();
        if (URLUtil.isValidUrl(link)) {
            try {
                mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link)));
            } catch (ActivityNotFoundException e) {
                LogUtil.e(Log.getStackTraceString(e));
            }
        }
    });

    if (credit.getContribution().length() == 0) {
        holder.subtitle.setVisibility(View.GONE);
    } else {
        holder.subtitle.setVisibility(View.VISIBLE);
    }

    ImageLoader.getInstance().displayImage(credit.getImage(),
            new ImageViewAware(holder.image), mOptions.build(),
            new ImageSize(144, 144), null, null);
    return view;
}
 
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.activity_download_from_url, container, false);
    context = getActivity();
    download = view.findViewById(R.id.download);
    edt_url = view.findViewById(R.id.edt_url);
    adContainer = view.findViewById(R.id.adContainer);
    open_instagram = view.findViewById(R.id.open_instagram);
    showBannerAd();
    download.setOnClickListener(v -> {

        if (TextUtils.isEmpty(edt_url.getText().toString())) {
            ToastUtils.ErrorToast(context, "Url field can't be empty");
        } else if (!URLUtil.isValidUrl(edt_url.getText().toString())) {
            ToastUtils.ErrorToast(context, "Url is not valid url");
        } else if (checkURL(edt_url.getText().toString())) {
            new ValidateFileFromURL().execute(edt_url.getText().toString());
        } else {
            ToastUtils.ErrorToast(context, "Url is not valid url");
        }


    });

    open_instagram.setOnClickListener(v -> {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("https://www.instagram.com/"));
        startActivity(intent);

    });

    return view;
}
 
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.activity_download_igtv_from_url, container, false);


    download = view.findViewById(R.id.download);
    url = view.findViewById(R.id.edt_url);
    adContainer = view.findViewById(R.id.adContainer);
    open_instagram = view.findViewById(R.id.open_instagram);
    showBannerAd();
    download.setOnClickListener(v -> {

        if (TextUtils.isEmpty(url.getText().toString())) {
            ToastUtils.ErrorToast(context, "Url field can't be empty");
        } else if (!URLUtil.isValidUrl(url.getText().toString())) {
            ToastUtils.ErrorToast(context, "Url is not valid url");
        } else if (checkURL(url.getText().toString())) {

            new ValidateFileFromURL().execute(url.getText().toString());
        } else {
            ToastUtils.ErrorToast(context, "Url is not valid url");
        }


    });

    open_instagram.setOnClickListener(v -> {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("https://www.instagram.com/explore/tags/igtv/"));
        startActivity(intent);

    });


    return view;
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_download_from_url);
    context = this;
    download = findViewById(R.id.download);
    url = findViewById(R.id.edt_url);



    download.setOnClickListener(v -> {

        if (TextUtils.isEmpty(url.getText().toString())) {
            ToastUtils.ErrorToast(context, "Url field can't be empty");
        } else if (URLUtil.isValidUrl(url.getText().toString())) {
            ToastUtils.ErrorToast(context, "Url is not valid url");
        } else if (URLUtil.isFileUrl(url.getText().toString())) {
            String _url = url.getText().toString();
            if (_url.endsWith(".jpg")) {
                new saveImage(_url).execute();
            } else {
                new saveVideo(_url).execute(new String[0]);
            }
        }


    });


}
 
源代码25 项目: indigenous-android   文件: UpdateActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_update);
    super.onCreate(savedInstanceState);

    // Get default user.
    user = new Accounts(this).getDefaultUser();

    layout = findViewById(R.id.update_root);
    url = findViewById(R.id.url);
    postStatus = findViewById(R.id.postStatus);
    title = findViewById(R.id.title);
    body = findViewById(R.id.body);

    // Set listener.
    VolleyRequestListener(this);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {

        String status = extras.getString("status");
        if (status != null && status.equals("draft")) {
            postStatus.setChecked(false);
        }

        String urlToUpdate = extras.getString("url");
        if (urlToUpdate != null && urlToUpdate.length() > 0) {
            if (URLUtil.isValidUrl(urlToUpdate)) {
                url.setText(urlToUpdate);
                getPostFromServer(urlToUpdate);
            }
        }

    }
}
 
@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
    if (resultCode == RESULT_OK) {
        switch (requestCode) {
            case RequestCode.SELECT_JSON_FILE:
                selectedFilePath = data.getData();
                rlJsonUp.setVisibility(View.GONE);
                rlJsonPath.setVisibility(View.VISIBLE);
                tlJsonPwd.setVisibility(View.VISIBLE);
                if (selectedFilePath != null) {
                    btnRestore.setEnabled(true);
                    String fileName = URLUtil.guessFileName(selectedFilePath.getLastPathSegment(), null, null);
                    tvJsonPath.setText(fileName);
                } else {
                    Toast.makeText(getApplicationContext(), getString(R.string.restore_backup_wrong_file_name), Toast.LENGTH_LONG).show();
                }
                break;
            case RequestCode.QR_CODE_REQUEST_CODE:
                String result = data.getStringExtra(Extras.QR_CODE_RESULT);
                if (!result.isEmpty()) {
                    String address = filterAddress(result);
                    etBackupPhrase.setText(address);
                }
                break;
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
    if (resultCode == RESULT_OK) {
        switch (requestCode) {
            case RequestCode.SELECT_JSON_FILE:
                selectedFilePath = data.getData();
                rlJsonUp.setVisibility(View.GONE);
                rlJsonPath.setVisibility(View.VISIBLE);
                tlJsonPwd.setVisibility(View.VISIBLE);
                if (selectedFilePath != null) {
                    btnRestore.setEnabled(true);
                    String fileName = URLUtil.guessFileName(selectedFilePath.getLastPathSegment(), null, null);
                    tvJsonPath.setText(fileName);
                } else {
                    Toast.makeText(getApplicationContext(), getString(R.string.restore_backup_wrong_file_name), Toast.LENGTH_LONG).show();
                }
                break;
            case RequestCode.QR_CODE_REQUEST_CODE:
                String result = data.getStringExtra(Extras.QR_CODE_RESULT);
                if (!result.isEmpty()) {
                    String address = filterAddress(result);
                    etBackupPhrase.setText(address);
                }
                break;
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
    if (resultCode == RESULT_OK) {
        switch (requestCode) {
            case RequestCode.SELECT_JSON_FILE:
                selectedFilePath = data.getData();
                rlJsonUp.setVisibility(View.GONE);
                rlJsonPath.setVisibility(View.VISIBLE);
                tlJsonPwd.setVisibility(View.VISIBLE);
                if (selectedFilePath != null) {
                    btnRestore.setEnabled(true);
                    String fileName = URLUtil.guessFileName(selectedFilePath.getLastPathSegment(), null, null);
                    tvJsonPath.setText(fileName);
                } else {
                    Toast.makeText(getApplicationContext(), getString(R.string.restore_backup_wrong_file_name), Toast.LENGTH_LONG).show();
                }
                break;
            case RequestCode.QR_CODE_REQUEST_CODE:
                String result = data.getStringExtra(Extras.QR_CODE_RESULT);
                if (!result.isEmpty()) {
                    String address = filterAddress(result);
                    etBackupPhrase.setText(address);
                }
                break;
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
源代码29 项目: 365browser   文件: DataReductionProxySettings.java
/**
 * If the given URL is a WebLite URL and should be overridden because the Data
 * Reduction Proxy is on, the user is in the Lo-Fi previews experiment, and the scheme of the
 * lite_url param is HTTP, returns the URL contained in the lite_url param. Otherwise returns
 * the given URL.
 *
 * @param url The URL to evaluate.
 * @return The URL to be used. Returns null if the URL param is null.
 */
public String maybeRewriteWebliteUrl(String url) {
    if (url == null || !URLUtil.isValidUrl(url) || !areLoFiPreviewsEnabled()
            || !isDataReductionProxyEnabled()) {
        return url;
    }
    String rewritten = extractUrlFromWebliteQueryParams(url);
    if (rewritten == null
            || !TextUtils.equals(Uri.parse(rewritten).getScheme(),
                    UrlConstants.HTTP_SCHEME)) {
        return url;
    }

    return rewritten;
}
 
/**
 * loads a custom url from the url bar
 * @param v
 * @param actionId
 * @return
 */
@OnEditorAction(R.id.website_input)
boolean onEditorAction(TextView v, int actionId){

    if (URLUtil.isValidUrl(v.getText().toString()))
        webView.loadUrl(v.getText().toString());
    else
        Toast.makeText(getActivity(),getString(R.string.web_error_toast), Toast.LENGTH_SHORT).show();
    Util.hideKeyboard(websiteInput, getActivity());
    return true;
}