Example usage for android.net Uri equals

List of usage examples for android.net Uri equals

Introduction

In this page you can find the example usage for android.net Uri equals.

Prototype

public boolean equals(Object o) 

Source Link

Document

Compares this Uri to another object for equality.

Usage

From source file:org.pixmob.feedme.ui.Feedme.java

@Override
public void onEntrySelected(Uri entryUri) {
    if (!dualPane) {
        // There is not enough space to display the entry details fragment:
        // start a new activity to show the entry URL.
        final Cursor c = getContentResolver().query(entryUri, new String[] { Entries.URL }, null, null, null);
        try {/*from  w  w w  .  j  a  v  a 2 s .  c om*/
            if (c.moveToNext()) {
                final String entryUrl = c.getString(c.getColumnIndexOrThrow(Entries.URL));
                final Intent i = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(entryUrl));
                startActivity(i);
            }
        } finally {
            c.close();
        }
    } else if (!entryUri.equals(selectedEntryUri)) {
        // Update the entry details fragment.
        final EntryDetailsFragment entryDetailsFragment = EntryDetailsFragment.newInstance(entryUri);
        final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.entry_details, entryDetailsFragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.commit();
    }

    selectedEntryUri = entryUri;
}

From source file:org.apache.cordova.engine.crosswalk.XWalkCordovaWebViewClient.java

@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {/*from ww  w  .  j av  a2  s  . c om*/
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(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);
    }
}

From source file:com.wizardsofm.deskclock.data.TimerModel.java

/**
 * @return the title of the ringtone that is played for all timers
 *///from  w ww . j a  va2 s  . co m
String getTimerRingtoneTitle() {
    if (mTimerRingtoneTitle == null) {
        if (isTimerRingtoneSilent()) {
            // Special case: no ringtone has a title of "Silent".
            mTimerRingtoneTitle = mContext.getString(com.wizardsofm.deskclock.R.string.silent_ringtone_title);
        } else {
            final Uri defaultUri = getDefaultTimerRingtoneUri();
            final Uri uri = getTimerRingtoneUri();

            if (defaultUri.equals(uri)) {
                // Special case: default ringtone has a title of "Timer Expired".
                mTimerRingtoneTitle = mContext
                        .getString(com.wizardsofm.deskclock.R.string.default_timer_ringtone_title);
            } else {
                final Ringtone ringtone = RingtoneManager.getRingtone(mContext, uri);
                mTimerRingtoneTitle = ringtone.getTitle(mContext);
            }
        }
    }

    return mTimerRingtoneTitle;
}

From source file:com.androidinspain.deskclock.data.TimerModel.java

/**
 * @return the title of the ringtone that is played for all timers
 *///from w  w  w.  j  a v a  2s  .co m
String getTimerRingtoneTitle() {
    if (mTimerRingtoneTitle == null) {
        if (isTimerRingtoneSilent()) {
            // Special case: no ringtone has a title of "Silent".
            mTimerRingtoneTitle = mContext
                    .getString(com.androidinspain.deskclock.R.string.silent_ringtone_title);
        } else {
            final Uri defaultUri = getDefaultTimerRingtoneUri();
            final Uri uri = getTimerRingtoneUri();

            if (defaultUri.equals(uri)) {
                // Special case: default ringtone has a title of "Timer Expired".
                mTimerRingtoneTitle = mContext
                        .getString(com.androidinspain.deskclock.R.string.default_timer_ringtone_title);
            } else {
                mTimerRingtoneTitle = mRingtoneModel.getRingtoneTitle(uri);
            }
        }
    }

    return mTimerRingtoneTitle;
}

From source file:com.stasbar.knowyourself.data.TimerModel.java

/**
 * @return the title of the ringtone that is played for all timers
 *//*from   w ww  . j  a  v a  2s. c o m*/
String getTimerRingtoneTitle() {
    if (mTimerRingtoneTitle == null) {
        if (isTimerRingtoneSilent()) {
            // Special case: no ringtone has a title of "Silent".
            mTimerRingtoneTitle = mContext.getString(R.string.silent_ringtone_title);
        } else {
            final Uri defaultUri = getDefaultTimerRingtoneUri();
            final Uri uri = getTimerRingtoneUri();

            if (defaultUri.equals(uri)) {
                // Special case: default ringtone has a title of "Timer Expired".
                mTimerRingtoneTitle = mContext.getString(R.string.default_timer_ringtone_title);
            } else {
                final Ringtone ringtone = RingtoneManager.getRingtone(mContext, uri);
                mTimerRingtoneTitle = ringtone.getTitle(mContext);
            }
        }
    }

    return mTimerRingtoneTitle;
}

From source file:com.mediatek.galleryfeature.stereo.segment.background.StereoBackgroundActivity.java

void changeBitmap(Uri uri) {
    if (uri == null) {
        uri = mOriginalRefineImage;/*from   w  w w  . ja v  a2 s.com*/
        if (uri == null) {
            return;
        }
    }
    if (mOriginalRefineImage == null) {
        mOriginalRefineImage = mSelectedImageUri;
        MtkLog.d(TAG, "<changeBitmap> mOriginalRefineImage = " + mOriginalRefineImage);
    }
    if (uri.equals(mOriginalRefineImage)) {
        mSaveButton.setVisibility(View.INVISIBLE);
        mImageShowBackground.setZoomPanSupported(false);
    }
    mLoadBitmapTask = new LoadBitmapTask();
    mLoadBitmapTask.execute(uri);
}

From source file:com.android.deskclock.data.TimerModel.java

/**
 * @return the title of the ringtone that is played for all timers
 *///  www . j  av  a2s . c  om
String getTimerRingtoneTitle() {
    if (mTimerRingtoneTitle == null) {
        if (isTimerRingtoneSilent()) {
            // Special case: no ringtone has a title of "Silent".
            mTimerRingtoneTitle = mContext.getString(R.string.silent_timer_ringtone_title);
        } else {
            final Uri defaultUri = getDefaultTimerRingtoneUri();
            final Uri uri = getTimerRingtoneUri();

            if (defaultUri.equals(uri)) {
                // Special case: default ringtone has a title of "Timer Expired".
                mTimerRingtoneTitle = mContext.getString(R.string.default_timer_ringtone_title);
            } else {
                final Ringtone ringtone = RingtoneManager.getRingtone(mContext, uri);
                mTimerRingtoneTitle = ringtone.getTitle(mContext);
            }
        }
    }

    return mTimerRingtoneTitle;
}

From source file:org.telegram.ui.ProfileNotificationsActivity.java

@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        if (data == null) {
            return;
        }/* w  w  w.j  a  va2s. c o  m*/
        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();
    }
}

From source file:wseemann.media.fmpdemo.FMPDemo.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fmpdemo);

    final EditText uriText = (EditText) findViewById(R.id.uri);
    // Uncomment for debugging
    //uriText.setText("http://...");

    Intent intent = getIntent();//from w  w  w.  j av a 2 s  .  c  o m

    // Populate the edit text field with the intent uri, if available
    Uri uri = intent.getData();

    if (intent.getExtras() != null && intent.getExtras().getCharSequence(Intent.EXTRA_TEXT) != null) {
        uri = Uri.parse(intent.getExtras().getCharSequence(Intent.EXTRA_TEXT).toString());
    }

    if (uri != null) {
        try {
            uriText.setText(URLDecoder.decode(uri.toString(), "UTF-8"));
        } catch (UnsupportedEncodingException e1) {
        }
    }

    setIntent(null);

    Button goButton = (Button) findViewById(R.id.go_button);
    goButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // Clear the error message
            uriText.setError(null);

            // Hide the keyboard
            InputMethodManager imm = (InputMethodManager) FMPDemo.this
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(uriText.getWindowToken(), 0);

            String uri = uriText.getText().toString();

            if (uri.equals("")) {
                uriText.setError(getString(R.string.uri_error));
                return;
            }

            String uriString = uriText.getText().toString();

            try {
                mService.openFile(uriString);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    });

    mToken = MusicUtils.bindToService(this, this);
}

From source file:org.opensilk.video.data.VideosProviderClient.java

public void removeOrphans(MediaBrowser.MediaItem parentItem, List<MediaBrowser.MediaItem> childItems) {
    List<MediaBrowser.MediaItem> indexedItems = getChildren(parentItem);
    for (MediaBrowser.MediaItem item : childItems) {
        Uri itemUri = MediaItemUtil.getMediaUri(item);
        ListIterator<MediaBrowser.MediaItem> indexedII = indexedItems.listIterator();
        while (indexedII.hasNext()) {
            MediaBrowser.MediaItem indexedItem = indexedII.next();
            Uri indexedItemUri = MediaItemUtil.getMediaUri(indexedItem);
            if (itemUri.equals(indexedItemUri)) {
                indexedII.remove();//ww  w .ja v a2  s.  c om
                break;
            }
        }
    }
    for (MediaBrowser.MediaItem mediaItem : indexedItems) {
        removeMediaRecursive(mediaItem);
    }
}