本文整理汇总了Java中android.webkit.URLUtil.isFileUrl方法的典型用法代码示例。如果您正苦于以下问题:Java URLUtil.isFileUrl方法的具体用法?Java URLUtil.isFileUrl怎么用?Java URLUtil.isFileUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.URLUtil
的用法示例。
在下文中一共展示了URLUtil.isFileUrl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: download
import android.webkit.URLUtil; //导入方法依赖的package包/类
public void download(String url, int width, int height, DownloadListener listener) {
mHandler = new Handler(Looper.getMainLooper());
if (listener == null) {
Log.w(TAG, "download won't start since there is no assigned listener to It");
} else {
mDownloadListener = listener;
mURL = url;
mWidth = width;
mHeight = height;
if (TextUtils.isEmpty(url)) {
invokeFail(new Exception("Image URL is empty"));
} else if (URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url)) {
downloadImage();
} else if (URLUtil.isFileUrl(url)) {
loadCachedImage();
} else {
invokeFail(new Exception("Wrong file URL!"));
}
}
}
示例2: handleUriIntent
import android.webkit.URLUtil; //导入方法依赖的package包/类
private void handleUriIntent(Intent intent) {
TabsTrackerService.clearUnread();
if (intent != null) {
if (intent.getBooleanExtra(TabsTrackerService.EXTRA_CLEAR_SUBSCRIPTIONS, false)) TabsTrackerService.clearSubscriptions();
if (MainApplication.getInstance().settings.useFakeBrowser()) FakeBrowser.dismiss();
if (intent.getData() != null && URLUtil.isFileUrl(intent.getDataString())) {
LocalHandler.open(intent.getData().getPath(), this);
return;
}
String url = intent.getDataString();
if (url != null && url.length() != 0) {
UrlHandler.open(url, this, MainApplication.getInstance().settings.useFakeBrowser());
}
intent.setData(null);
}
}
示例3: isExist
import android.webkit.URLUtil; //导入方法依赖的package包/类
@Override
public boolean isExist(String key) {
if (URLUtil.isNetworkUrl(key)) {
return new File(options.getCacheRootPath() + "/" + convertUrlToFileName(key)).exists();
} else if (URLUtil.isFileUrl(key)) {
return new File(key).exists();
} else {
return false;
}
}
示例4: getFilePathByKey
import android.webkit.URLUtil; //导入方法依赖的package包/类
public String getFilePathByKey(String key){
if(URLUtil.isFileUrl(key)){
return key;
}else if(URLUtil.isNetworkUrl(key)){
return options.getCacheRootPath()+"/"+convertUrlToFileName(key);
}else {
return null;
}
}
示例5: play
import android.webkit.URLUtil; //导入方法依赖的package包/类
/**
* start playing audio
*
* @param uriOrName
* @param loopTimes
* @return
*/
public synchronized UDAudio play(String uriOrName, Integer loopTimes) {
stopAndReset();
if (uriOrName != null && uriOrName.equals(this.mUriOrName) == false) {//url 不同
this.mUriOrName = uriOrName;
}
if (loopTimes != null) {
this.mLoopTimes = loopTimes;
}
if (this.mUriOrName != null) {
final MediaPlayer player = getMediaPlayer();
if (player != null && player.isPlaying() == false) {
String uri = null;
boolean assetFileExist = false;
if (URLUtil.isNetworkUrl(this.mUriOrName) || URLUtil.isFileUrl(this.mUriOrName) || URLUtil.isAssetUrl(this.mUriOrName)) {//net & file & asset
uri = this.mUriOrName;
} else {//plain text, use as file path
uri = getLuaResourceFinder().buildFullPathInBundleOrAssets(this.mUriOrName);
assetFileExist = AssetUtil.exists(getContext(), uri);
}
try {
if (assetFileExist) {
final AssetFileDescriptor descriptor = getContext().getAssets().openFd(uri);
player.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
} else {
player.setDataSource(uri);
}
player.setOnErrorListener(this);
player.setOnCompletionListener(this);
player.setOnPreparedListener(this);
player.setLooping((this.mLoopTimes != null && this.mLoopTimes > 1) ? true : false);
player.prepareAsync();
} catch (Exception e) {
e.printStackTrace();
}
}
}
return this;
}
示例6: onActivityResult
import android.webkit.URLUtil; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK
&& data != null
&& requestCode == ActionUtils.PHOTO_REQUEST_GALLERY) {
Uri inputUri = data.getData();
String path = null;
if (URLUtil.isFileUrl(inputUri.toString())) {
// 小米手机直接返回的文件路径
path = inputUri.getPath();
} else {
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(inputUri, proj, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
path = cursor.getString(cursor.getColumnIndex(MediaStore.MediaColumns.DATA));
}
}
if (!TextUtils.isEmpty(path)) {
Result result = QrUtils.decodeImage(path);
if (result != null) {
if (BuildConfig.DEBUG) Log.d(TAG, result.getText());
handleDecode(result, null);
} else {
new AlertDialog.Builder(CaptureActivity.this)
.setTitle("提示")
.setMessage("此图片无法识别")
.setPositiveButton("确定", null)
.show();
}
} else {
if (BuildConfig.DEBUG) Log.e(TAG, "image path not found");
Toast.makeText(mActivity, "图片路径未找到", Toast.LENGTH_SHORT).show();
}
}else {//yiwen add
if (requestCode==REQEST_CARNUB&&RESULT_OK==resultCode){
Intent intent = new Intent();
intent.putExtra("result",data.getStringExtra("result") );
setResult(RESULT_OK, intent);
finish();
}
}
}
示例7: deleteTab
import android.webkit.URLUtil; //导入方法依赖的package包/类
/**
* Deletes the tab at the specified position.
*
* @param position the position at which to
* delete the tab.
*/
public void deleteTab(int position) {
Log.d(TAG, "delete Tab");
final LightningView tabToDelete = mTabsModel.getTabAtPosition(position);
if (tabToDelete == null) {
return;
}
if (!UrlUtils.isSpecialUrl(tabToDelete.getUrl()) && !mIsIncognito) {
mPreferences.setSavedUrl(tabToDelete.getUrl());
}
final boolean isShown = tabToDelete.isShown();
boolean shouldClose = mShouldClose && isShown && tabToDelete.isNewTab();
final LightningView currentTab = mTabsModel.getCurrentTab();
if (mTabsModel.size() == 1 && currentTab != null &&
URLUtil.isFileUrl(currentTab.getUrl()) &&
currentTab.getUrl().equals(mapHomepageToCurrentUrl())) {
mView.closeActivity();
return;
} else {
if (isShown) {
mView.removeTabView();
}
boolean currentDeleted = mTabsModel.deleteTab(position);
if (currentDeleted) {
tabChanged(mTabsModel.indexOfCurrentTab());
}
}
final LightningView afterTab = mTabsModel.getCurrentTab();
mView.notifyTabViewRemoved(position);
if (afterTab == null) {
mView.closeBrowser();
return;
} else if (afterTab != currentTab) {
//TODO remove this?
// switchTabs(currentTab, afterTab);
// if (currentTab != null) {
// currentTab.pauseTimers();
// }
mView.notifyTabViewChanged(mTabsModel.indexOfCurrentTab());
}
if (shouldClose) {
mShouldClose = false;
mView.closeActivity();
}
mView.updateTabNumber(mTabsModel.size());
Log.d(TAG, "deleted tab");
}
示例8: shouldOverrideUrlLoading
import android.webkit.URLUtil; //导入方法依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(final WebView view, String url)
{
Log.d(TAG, "url=" + url, Log.DEBUG_MODE);
if (webView.getProxy().hasProperty(TiC.PROPERTY_BLACKLISTED_URLS)) {
String [] blacklistedSites = TiConvert.toStringArray((Object[])webView.getProxy().getProperty(TiC.PROPERTY_BLACKLISTED_URLS));
for(String site : blacklistedSites) {
if (url.equalsIgnoreCase(site) || (url.indexOf(site) > -1)) {
KrollDict data = new KrollDict();
data.put("url", url);
data.put("message", "Webview did not load blacklisted url.");
webView.getProxy().fireEvent(TiC.PROPERTY_ON_STOP_BLACKISTED_URL, data);
return true;
}
}
}
if (URLUtil.isAssetUrl(url) || URLUtil.isContentUrl(url) || URLUtil.isFileUrl(url)) {
// go through the proxy to ensure we're on the UI thread
webView.getProxy().setPropertyAndFire(TiC.PROPERTY_URL, url);
return true;
} else if(url.startsWith(WebView.SCHEME_TEL)) {
Log.i(TAG, "Launching dialer for " + url, Log.DEBUG_MODE);
Intent dialer = Intent.createChooser(new Intent(Intent.ACTION_DIAL, Uri.parse(url)), "Choose Dialer");
webView.getProxy().getActivity().startActivity(dialer);
return true;
} else if (url.startsWith(WebView.SCHEME_MAILTO)) {
Log.i(TAG, "Launching mailer for " + url, Log.DEBUG_MODE);
Intent mailer = Intent.createChooser(new Intent(Intent.ACTION_SENDTO, Uri.parse(url)), "Send Message");
webView.getProxy().getActivity().startActivity(mailer);
return true;
} else if (url.startsWith(WebView.SCHEME_GEO)) {
Log.i(TAG, "Launching app for " + url, Log.DEBUG_MODE);
/*geo:latitude,longitude
geo:latitude,longitude?z=zoom
geo:0,0?q=my+street+address
geo:0,0?q=business+near+city
*/
Intent geoviewer = Intent.createChooser(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), "Choose Viewer");
webView.getProxy().getActivity().startActivity(geoviewer);
return true;
} else {
String extension = MimeTypeMap.getFileExtensionFromUrl(url);
String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
if (mimeType != null) {
return shouldHandleMimeType(mimeType, url);
}
return super.shouldOverrideUrlLoading(view, url);
}
}