本文整理匯總了Java中android.net.Uri.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java Uri.equals方法的具體用法?Java Uri.equals怎麽用?Java Uri.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.net.Uri
的用法示例。
在下文中一共展示了Uri.equals方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onClick
import android.net.Uri; //導入方法依賴的package包/類
@Override
public void onClick(View v) {
/*
* If user deleted a dir which was one in history, then maybe there
* are duplicates, so we check and remove them here.
*/
Uri currentLoc = getCurrentLocation();
Uri nextLoc = null;
while (currentLoc.equals(nextLoc = mHistory.nextOf(currentLoc)))
mHistory.remove(nextLoc);
if (nextLoc != null)
goTo(nextLoc);
else
mViewGoForward.setEnabled(false);
}
示例2: loadFolder
import android.net.Uri; //導入方法依賴的package包/類
private void loadFolder(Uri uri) {
if(DBG) Log.d(TAG, "loadFolder " + uri);
if (uri.equals(VIRTUAL_ROOT_POINT)) {
loadVirtualRoot();
// update the current selection
mCurrentSelectionTv.setText(R.string.no_selection); // virtual root is not a valid location
// disable the back button at root level
mBackButton.setEnabled(false);
} else {
mCurrentlyInVirtualRoot = false;
if (mListingEngine != null) {
mListingEngine.abort();
}
mListingEngine = ListingEngineFactory.getListingEngineForUrl(getActivity(), uri);
mListingEngine.setListener(this);
mListingEngine.start();
// update the current selection
mCurrentSelectionTv.setText(uri.getPath());
// enable the back button at non-root level
mBackButton.setEnabled(true);
}
// update the ok button
setOkButtonState();
}
示例3: shouldInterceptRequest
import android.net.Uri; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
try {
// Check the against the whitelist and lock out access to the WebView directory
// Changing this will cause problems for your application
if (!parentEngine.pluginManager.shouldAllowRequest(url)) {
LOG.w(TAG, "URL blocked by whitelist: " + url);
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
CordovaResourceApi resourceApi = parentEngine.resourceApi;
Uri origUri = Uri.parse(url);
// Allow plugins to intercept WebView requests.
Uri remappedUri = resourceApi.remapUri(origUri);
if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
}
// If we don't need to special-case the request, let the browser load it.
return null;
} catch (IOException e) {
if (!(e instanceof FileNotFoundException)) {
LOG.e(TAG, "Error occurred while loading a file (returning a 404).", e);
}
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
}
示例4: notifyUpdatedEntities
import android.net.Uri; //導入方法依賴的package包/類
private void notifyUpdatedEntities(Uri uri) {
getContext().getContentResolver().notifyChange(uri, null);
if (!uri.equals(OhaEnergyUseContract.CONTENT_URI_DAYS))
getContext().getContentResolver().notifyChange(OhaEnergyUseContract.CONTENT_URI_DAYS, null);
if (!uri.equals(OhaEnergyUseContract.CONTENT_URI_BILL))
getContext().getContentResolver().notifyChange(OhaEnergyUseContract.CONTENT_URI_BILL, null);
}
示例5: onActivityResultFragment
import android.net.Uri; //導入方法依賴的package包/類
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (data == null) {
return;
}
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
String name = null;
if (ringtone != null) {
Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone);
if (rng != null) {
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
name = LocaleController.getString("SoundDefault", R.string.SoundDefault);
} else {
name = rng.getTitle(getParentActivity());
}
rng.stop();
}
}
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
if (requestCode == 12) {
if (name != null) {
editor.putString("sound_" + dialog_id, name);
editor.putString("sound_path_" + dialog_id, ringtone.toString());
} else {
editor.putString("sound_" + dialog_id, "NoSound");
editor.putString("sound_path_" + dialog_id, "NoSound");
}
}
editor.commit();
listView.invalidateViews();
}
}
示例6: shouldInterceptRequest
import android.net.Uri; //導入方法依賴的package包/類
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
try {
// Check the against the whitelist and lock out access to the WebView directory
// Changing this will cause problems for your application
if (isUrlHarmful(url)) {
LOG.w(TAG, "URL blocked by whitelist: " + url);
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
CordovaResourceApi resourceApi = appView.getResourceApi();
Uri origUri = Uri.parse(url);
// Allow plugins to intercept WebView requests.
Uri remappedUri = resourceApi.remapUri(origUri);
if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
}
// If we don't need to special-case the request, let the browser load it.
return null;
} catch (IOException e) {
if (!(e instanceof FileNotFoundException)) {
LOG.e("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
}
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
}
示例7: getValueDisplayString
import android.net.Uri; //導入方法依賴的package包/類
public static String getValueDisplayString(Context context, Uri uri) {
if (uri == null)
return context.getString(R.string.value_none);
if (uri.equals(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)))
return context.getString(R.string.value_default);
Ringtone ret = RingtoneManager.getRingtone(context, uri);
if (ret != null)
return ret.getTitle(context);
return null;
}
示例8: addChannel
import android.net.Uri; //導入方法依賴的package包/類
@WorkerThread
static long addChannel(Context context, Playlist playlist) {
String channelInputId = createInputId(context);
Channel channel = new Channel.Builder()
.setDisplayName(playlist.getName())
.setDescription(playlist.getDescription())
.setType(TvContractCompat.Channels.TYPE_PREVIEW)
.setInputId(channelInputId)
.setAppLinkIntentUri(Uri.parse(SCHEME + "://" + APPS_LAUNCH_HOST
+ "/" + START_APP_ACTION_PATH))
.setInternalProviderId(playlist.getPlaylistId())
.build();
Uri channelUri = context.getContentResolver().insert(Channels.CONTENT_URI,
channel.toContentValues());
if (channelUri == null || channelUri.equals(Uri.EMPTY)) {
Log.e(TAG, "Insert channel failed");
return 0;
}
long channelId = ContentUris.parseId(channelUri);
playlist.setChannelPublishedId(channelId);
writeChannelLogo(context, channelId, R.drawable.app_icon);
List<Clip> clips = playlist.getClips();
int weight = clips.size();
for (int i = 0; i < clips.size(); ++i, --weight) {
Clip clip = clips.get(i);
final String clipId = clip.getClipId();
final String contentId = clip.getContentId();
PreviewProgram program = new PreviewProgram.Builder()
.setChannelId(channelId)
.setTitle(clip.getTitle())
.setDescription(clip.getDescription())
.setPosterArtUri(Uri.parse(clip.getCardImageUrl()))
.setIntentUri(Uri.parse(SCHEME + "://" + APPS_LAUNCH_HOST
+ "/" + PLAY_VIDEO_ACTION_PATH + "/" + clipId))
.setPreviewVideoUri(Uri.parse(clip.getPreviewVideoUrl()))
.setInternalProviderId(clipId)
.setContentId(contentId)
.setWeight(weight)
.setPosterArtAspectRatio(clip.getAspectRatio())
.setType(TvContractCompat.PreviewPrograms.TYPE_MOVIE)
.build();
Uri programUri = context.getContentResolver().insert(PREVIEW_PROGRAMS_CONTENT_URI,
program.toContentValues());
if (programUri == null || programUri.equals(Uri.EMPTY)) {
Log.e(TAG, "Insert program failed");
} else {
clip.setProgramId(ContentUris.parseId(programUri));
}
}
return channelId;
}
示例9: copyFileToURL
import android.net.Uri; //導入方法依賴的package包/類
@Override
public JSONObject copyFileToURL(LocalFilesystemURL destURL, String newName,
Filesystem srcFs, LocalFilesystemURL srcURL, boolean move) throws IOException, InvalidModificationException, JSONException, NoModificationAllowedException, FileExistsException {
// Check to see if the destination directory exists
String newParent = this.filesystemPathForURL(destURL);
File destinationDir = new File(newParent);
if (!destinationDir.exists()) {
// The destination does not exist so we should fail.
throw new FileNotFoundException("The source does not exist");
}
// Figure out where we should be copying to
final LocalFilesystemURL destinationURL = makeDestinationURL(newName, srcURL, destURL, srcURL.isDirectory);
Uri dstNativeUri = toNativeUri(destinationURL);
Uri srcNativeUri = srcFs.toNativeUri(srcURL);
// Check to see if source and destination are the same file
if (dstNativeUri.equals(srcNativeUri)) {
throw new InvalidModificationException("Can't copy onto itself");
}
if (move && !srcFs.canRemoveFileAtLocalURL(srcURL)) {
throw new InvalidModificationException("Source URL is read-only (cannot move)");
}
File destFile = new File(dstNativeUri.getPath());
if (destFile.exists()) {
if (!srcURL.isDirectory && destFile.isDirectory()) {
throw new InvalidModificationException("Can't copy/move a file to an existing directory");
} else if (srcURL.isDirectory && destFile.isFile()) {
throw new InvalidModificationException("Can't copy/move a directory to an existing file");
}
}
if (srcURL.isDirectory) {
// E.g. Copy /sdcard/myDir to /sdcard/myDir/backup
if (dstNativeUri.toString().startsWith(srcNativeUri.toString() + '/')) {
throw new InvalidModificationException("Can't copy directory into itself");
}
copyDirectory(srcFs, srcURL, destFile, move);
} else {
copyFile(srcFs, srcURL, destFile, move);
}
return makeEntryForURL(destinationURL);
}
示例10: onCreate
import android.net.Uri; //導入方法依賴的package包/類
/******************************************************************
** Activity life cycle
******************************************************************/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Log.d(TAG, "onCreate : intent=" + getIntent());
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
if (icicle != null) {
// Restore former activity state
mListState = icicle.getParcelable(LIST_STATE_KEY);
mListHasFocus = icicle.getBoolean(FOCUS_KEY);
}
if (Intent.ACTION_GET_CONTENT.equals(getIntent().getAction())) {
mBaseUri = VideoStore.Video.Media.EXTERNAL_CONTENT_URI;
} else {
mBaseUri = getIntent().getData();
if (mBaseUri == null) {
Log.e(TAG, "No data URI given to GET_CONTENT action");
setResult(RESULT_CANCELED);
finish();
return;
}
}
setContentView(R.layout.video_picker);
final ListView listView = getListView();
listView.setItemsCanFocus(false);
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(this);
mAdapter = new VideoListAdapter(this, listView,
R.layout.video_picker_item, new String[] {},
new int[] {});
setListAdapter(mAdapter);
// We manually save/restore the listview state
listView.setSaveEnabled(false);
mQueryHandler = new QueryHandler(this);
mProgressContainer = findViewById(R.id.progressContainer);
mListContainer = findViewById(R.id.listContainer);
mCancelButton = findViewById(R.id.cancelButton);
mCancelButton.setOnClickListener(this);
// If there is a currently selected Uri, then try to determine who it is.
if (mSelectedUri != null) {
Uri.Builder builder = mSelectedUri.buildUpon();
String path = mSelectedUri.getEncodedPath();
int idx = path.lastIndexOf('/');
if (idx >= 0) {
path = path.substring(0, idx);
}
builder.encodedPath(path);
Uri baseSelectedUri = builder.build();
if (DBG) Log.v(TAG, "Selected Uri: " + mSelectedUri);
if (DBG) Log.v(TAG, "Selected base Uri: " + baseSelectedUri);
if (DBG) Log.v(TAG, "Base Uri: " + mBaseUri);
if (baseSelectedUri.equals(mBaseUri)) {
// If the base Uri of the selected Uri is the same as our
// content's base Uri, then use the selection!
mSelectedId = ContentUris.parseId(mSelectedUri);
}
}
doQuery(false, null);
}
示例11: isMatch
import android.net.Uri; //導入方法依賴的package包/類
private boolean isMatch(Uri url) {
return url != null && mBitmap != null && url.equals(mUrl);
}
示例12: refreshList
import android.net.Uri; //導入方法依賴的package包/類
private void refreshList(@Nullable GreatUri thisUri, boolean add, boolean delete) {
int max_recent_files = 15;
if(add)
max_recent_files--;
// File paths saved in preferences
String[] savedPaths = PreferenceHelper.getSavedPaths(this);
int first_index_of_array = savedPaths.length > max_recent_files ? savedPaths.length - max_recent_files : 0;
savedPaths = ArrayUtils.subarray(savedPaths, first_index_of_array, savedPaths.length);
// File names for the list
greatUris.clear();
// StringBuilder that will contain the file paths
StringBuilder sb = new StringBuilder();
// for cycle to convert paths to names
for(int i = 0; i < savedPaths.length; i++){
Uri particularUri = Uri.parse(savedPaths[i]);
String name = AccessStorageApi.getName(this, particularUri);
// Check that the file exist
// if is null or empty the particular url we dont use it
if (particularUri != null && !particularUri.equals(Uri.EMPTY) && !TextUtils.isEmpty(name)) {
// if the particular uri is good
boolean good = false;
if (thisUri == null || thisUri.getUri() == null || thisUri.getUri() == Uri.EMPTY)
good = true;
else {
if (delete == false)
good = true;
else if (!thisUri.getUri().equals(particularUri))
good = true;
else
good = false;
}
if (good) {
greatUris.addFirst(new GreatUri(particularUri, AccessStorageApi.getPath(this, particularUri), name));
sb.append(savedPaths[i]).append(",");
}
}
//}
}
// if is not null, empty, we have to add something and we dont already have this uri
if(thisUri != null && !thisUri.getUri().equals(Uri.EMPTY) && add && !ArrayUtils.contains(savedPaths, thisUri.getUri().toString())) {
sb.append(thisUri.getUri().toString()).append(",");
greatUris.addFirst(thisUri);
}
// save list without empty or non existed files
PreferenceHelper.setSavedPaths(this, sb);
// Set adapter
arrayAdapter.notifyDataSetChanged();
}