當前位置: 首頁>>代碼示例>>Java>>正文


Java URLUtil.isValidUrl方法代碼示例

本文整理匯總了Java中android.webkit.URLUtil.isValidUrl方法的典型用法代碼示例。如果您正苦於以下問題:Java URLUtil.isValidUrl方法的具體用法?Java URLUtil.isValidUrl怎麽用?Java URLUtil.isValidUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.URLUtil的用法示例。


在下文中一共展示了URLUtil.isValidUrl方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startServiceConfig

import android.webkit.URLUtil; //導入方法依賴的package包/類
private void startServiceConfig() {
    Log.i(TAG, "Starting service config");

    String discoveryEndpoint = app.getString(R.string.discovery_endpoint);
    if (discoveryEndpoint.trim().length() == 0 || !URLUtil.isValidUrl(discoveryEndpoint)) {
        Log.i(TAG, "Using static service config");
        AuthorizationServiceConfiguration serviceConfig =
                new AuthorizationServiceConfiguration(
                        Uri.parse(app.getString(R.string.authorization_endpoint)),
                        Uri.parse(app.getString(R.string.token_endpoint)));
        authState = new AuthState(serviceConfig);
        userInfoUrl = app.getString(R.string.user_info_endpoint);

        finishServiceConfig();
    } else {
        Log.i(TAG, "Using discovery service config");
        Uri discoveryUri = Uri.parse(discoveryEndpoint);
        loginListener.onEvent(AuthRepo.this, AUTH_SERVICE_DISCOVERY_START);

        AuthorizationServiceConfiguration.fetchFromUrl(discoveryUri, this::finishServiceDiscovery);
    }
}
 
開發者ID:approov,項目名稱:AppAuth-OAuth2-Books-Demo,代碼行數:23,代碼來源:AuthRepo.java

示例2: createPlayer

import android.webkit.URLUtil; //導入方法依賴的package包/類
private void createPlayer() {
    releasePlayer();
    String videoLink = UniversalPlayer.getInstance().getPlayingMediaItem().getAudeoLink();
    try {
        Logger.printInfo(TAG, "Trying to play video: " + videoLink);

        ArrayList<String> options = new ArrayList<String>();
        options.add("--aout=opensles");
        options.add("--audio-time-stretch"); // time stretching
        options.add("-vvv"); // verbosity
        libvlc = new LibVLC(options);
        shVideoHolder.setKeepScreenOn(true);

        // Create media player
        mMediaPlayer = new MediaPlayer(libvlc);
        mMediaPlayer.setEventListener(this);

        // Set up video output
        final IVLCVout vout = mMediaPlayer.getVLCVout();
        vout.setVideoView(sfVideo);
        vout.addCallback(this);
        vout.attachViews();

        Media m = URLUtil.isValidUrl(videoLink) ? new Media(libvlc, Uri.parse(videoLink)) : new Media(libvlc, videoLink);
        mMediaPlayer.setMedia(m);
        mMediaPlayer.play();
    } catch (Exception e) {
        Logger.printInfo(TAG, "Error creating video player: ");
        e.printStackTrace();
        if (onPlayingFailedCallback != null) {
            onPlayingFailedCallback.operationFinished();
        }
    }
}
 
開發者ID:KKorvin,項目名稱:uPods-android,代碼行數:35,代碼來源:FragmentVideoPlayer.java

示例3: onClick

import android.webkit.URLUtil; //導入方法依賴的package包/類
@Override
public void onClick(View view){

    if(view.getId()==R.id.notification_extra_info_tv){
            String url = notifications.get(getAdapterPosition()).getExtraUrl();
            if(URLUtil.isValidUrl(url)) {
                Utils.openLinkInCustomTab(context, url);
            }

    } else {

        if(descTv.getVisibility()==View.GONE){
            expandView();
        }
        else collapseView();
        notifyViewToggle(getAdapterPosition());
    }

}
 
開發者ID:CSI-KJSCE,項目名稱:CSI-KJSCEOfficial,代碼行數:20,代碼來源:NotificationAdapter.java

示例4: onOptionsItemSelected

import android.webkit.URLUtil; //導入方法依賴的package包/類
@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);
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:27,代碼來源:MainActivity.java

示例5: configHasRequiredFields

import android.webkit.URLUtil; //導入方法依賴的package包/類
public static boolean configHasRequiredFields(LEServiceConfiguration leServiceConfiguration) throws LEServiceException {
    boolean result = true;

    try {
        if (leServiceConfiguration.captureFlowLocale.isEmpty()) result = false;
        if (leServiceConfiguration.captureClientId.isEmpty()) result = false;
        if (leServiceConfiguration.captureApplicationId.isEmpty()) result = false;
        if (leServiceConfiguration.captureFlowVersion.isEmpty()) result = false;
        if (leServiceConfiguration.captureFlowName.isEmpty()) result = false;
        if (leServiceConfiguration.policyCheckerStage.isEmpty()) result = false;
        if (leServiceConfiguration.policyCheckerTenant.isEmpty()) result = false;
        if (!URLUtil.isValidUrl(leServiceConfiguration.policyCheckerHost)) result = false;
    }catch (Exception ex){
        result = false;
    }
    if(!result) throw new LEServiceException("Invalid LEServiceConfiguration Detected");
    return result;

}
 
開發者ID:janrain,項目名稱:LoginEligibility.Android,代碼行數:20,代碼來源:LEService.java

示例6: onBindViewHolder

import android.webkit.URLUtil; //導入方法依賴的package包/類
@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());
    }
}
 
開發者ID:danimahardhika,項目名稱:wallpaperboard,代碼行數:27,代碼來源:AboutAdapter.java

示例7: onClick

import android.webkit.URLUtil; //導入方法依賴的package包/類
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.btn_host_add:
            if (editUrl.getText().toString().length() > 0 &&
                    editName.getText().toString().length() > 0 &&
                    editLogin.getText().toString().length() > 0) {
                if (URLUtil.isValidUrl(editUrl.getText().toString())) {
                    performAdd();
                } else {
                    Toast.makeText(this, getString(R.string.url_invalid),
                            Toast.LENGTH_SHORT).show();
                }
            } else {
                Toast.makeText(this, getString(R.string.fill_fields),
                        Toast.LENGTH_SHORT).show();
            }
            break;
    }
}
 
開發者ID:CactusSoft,項目名稱:zabbkit-android,代碼行數:21,代碼來源:AddHostActivity.java

示例8: saveMediaItem

import android.webkit.URLUtil; //導入方法依賴的package包/類
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;
}
 
開發者ID:KKorvin,項目名稱:uPods-android,代碼行數:22,代碼來源:DialogFragmentAddMediaItem.java

示例9: setRedditItem

import android.webkit.URLUtil; //導入方法依賴的package包/類
public void setRedditItem(RedditItem redditItem, Picasso picasso) {
    title.setText(redditItem.title);
    description.setText(redditItem.selftext);
    upVotes.setText(String.format("%s", redditItem.score));
    subreddit.setText(redditItem.subreddit);

    if (redditItem.selftext != null) {
        description.setVisibility(View.VISIBLE);
        description.setText(redditItem.selftext);
    } else {
        description.setVisibility(View.GONE);
    }

    if (URLUtil.isValidUrl(redditItem.thumbnail)) {
        postImage.setVisibility(View.VISIBLE);
        picasso.load(redditItem.thumbnail)
                .centerCrop().placeholder(R.drawable.ic_image).fit().into(postImage);
    } else {
        postImage.setVisibility(View.GONE);
    }
}
 
開發者ID:patrick-doyle,項目名稱:android-rxmvp,代碼行數:22,代碼來源:RedditPostView.java

示例10: getBitmapFromImgUrlSync

import android.webkit.URLUtil; //導入方法依賴的package包/類
/**
 * Synchronously download image and return its bitmap
 *
 * @param imgUrl - url of image
 * @return bitmap of downloaded image or null
 */
@WorkerThread
public static @Nullable
Bitmap getBitmapFromImgUrlSync(@Nullable String imgUrl) {
    if (!URLUtil.isValidUrl(imgUrl)) {
        return null;
    }
    Bitmap bitmap = null;
    try {
        bitmap = PICASSO
                .load(imgUrl)
                .get();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return bitmap;
}
 
開發者ID:Vovchyk,項目名稱:android-rss-feed-reader,代碼行數:23,代碼來源:ImageUtils.java

示例11: doInBackground

import android.webkit.URLUtil; //導入方法依賴的package包/類
protected String doInBackground(Void... args) {

        String url = start_url;
        int ttl = max_ttl;
        int type = NONE;

        if ( url != null && url.length() != 0 && URLUtil.isValidUrl(url) ) {
            type = playlistType(url);
        } else {
            url = null;
        }

        if (url != null && type != NONE ) {
            ttl -= 1;
            url = selectUrlFromPlaylist(url,type);
        }

        if (ttl  == 0)
            url = null;

        return url;
    }
 
開發者ID:Old-Geek,項目名稱:Radio2,代碼行數:23,代碼來源:Playlist.java

示例12: chooseUrl

import android.webkit.URLUtil; //導入方法依賴的package包/類
private String chooseUrl() {
    // Handle intents
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (URLUtil.isValidUrl(intent.getStringExtra(Intent.EXTRA_TEXT))) {
            try {
                Log.v(Helpers.LogTag, "Shared URL Intent");
                return "https://mbasic.facebook.com/composer/?text=" + URLEncoder.encode(intent.getStringExtra(Intent.EXTRA_TEXT), "utf-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null && URLUtil.isValidUrl(intent.getData().toString())) {
        // If there is a intent containing a facebook link, go there
        Log.v(Helpers.LogTag, "Opened URL Intent");
        return intent.getData().toString();
    }

    // If nothing has happened at this point, we want the default url
    return FACEBOOK_URL_BASE;
}
 
開發者ID:JakeLane,項目名稱:Toffeed,代碼行數:25,代碼來源:MainActivity.java

示例13: addUrlSchemeIfNeeded

import android.webkit.URLUtil; //導入方法依賴的package包/類
/**
 * Add scheme prefix to an URL. This method must be called on all user entered or server fetched URLs to ensure
 * http client will work as expected.
 *
 * @param url url entered by the user or fetched from a server
 * @param isHTTPS true will make the url starts with https;//
 * @return transformed url prefixed by its http;// or https;// scheme
 */
public static String addUrlSchemeIfNeeded(String url, boolean isHTTPS) {
    if (url == null) {
        return null;
    }

    // Remove leading double slash (eg. //example.com), needed for some wporg instances configured to
    // switch between http or https
    url = removeLeadingDoubleSlash(url, (isHTTPS ? "https" : "http") + "://");

    if (!URLUtil.isValidUrl(url)) {
        if (!(url.toLowerCase().startsWith("http://")) && !(url.toLowerCase().startsWith("https://"))) {
            url = (isHTTPS ? "https" : "http") + "://" + url;
        }
    }

    return url;
}
 
開發者ID:ldsddn,項目名稱:wordpress_app_android,代碼行數:26,代碼來源:UrlUtils.java

示例14: setURL

import android.webkit.URLUtil; //導入方法依賴的package包/類
public void setURL(String url, String username) throws URLInvalid
{
  // check whether the URL is valid... otherwise there is no use going on....
  if (!URLUtil.isValidUrl(url) || !URLUtil.isHttpUrl(url))
  {
    throw new URLInvalid(url);
  }

  if (this.url.contentEquals(url) && this.username.contentEquals(username) && !username.isEmpty())
  {
    return;
  }

  RestAdapter restAdapter = new RestAdapter.Builder()
      .setEndpoint(url)
      .setClient(new HueConnectionClient())
          //.setLogLevel(RestAdapter.LogLevel.FULL)
      .build();
  hueRestInterface = restAdapter.create(HueRestInterface.class);
  this.url = url;

  connectionGood = false;
  lights = null;
  this.username = username;
  isConnected = false;
}
 
開發者ID:thht,項目名稱:ambilike,代碼行數:27,代碼來源:Hue.java

示例15: openWebPage

import android.webkit.URLUtil; //導入方法依賴的package包/類
public static void openWebPage(MainActivity activity, String URL) {
    if (URLUtil.isValidUrl(URL)) {
        if (PreferenceManager.getDefaultSharedPreferences(activity).getBoolean("use_custom_tabs", true)) {
            activity.tabsHelper.openURL(activity, URL);
        } else {
            Uri webPage = Uri.parse(URL);
            Intent intent = new Intent(Intent.ACTION_VIEW, webPage);

            PackageManager packageManager = activity.getPackageManager();
            List activities = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);

            if (activities.size() > 0) {
                activity.startActivity(intent);
            }
        }
    }
}
 
開發者ID:teinvdlugt,項目名稱:PapyrosProgress,代碼行數:18,代碼來源:MainActivity.java


注:本文中的android.webkit.URLUtil.isValidUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。