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:com.viktorrudometkin.burramys.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;/*from ww w. ja  v  a  2s.c o  m*/

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case 0:
        newUri = EntryColumns.UNREAD_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.CONTENT_URI;
        break;
    case 2:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }
        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        if (mDrawerLayout != null) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mLeftDrawer);
                }
            }, 500);
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.welcome_title).setItems(new CharSequence[] {
                getString(R.string.google_news_title), getString(R.string.add_custom_feed) },
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 1) {
                            startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                        } else {
                            startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                        }
                    }
                });
        builder.show();
    }

    // Set title & icon
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        switch (mCurrentDrawerPos) {
        case 0:
            getSupportActionBar().setTitle(R.string.unread_entries);
            break;
        case 1:
            getSupportActionBar().setTitle(R.string.all_entries);
            break;
        case 2:
            getSupportActionBar().setTitle(R.string.favorites);
            break;
        default:
            getSupportActionBar().setTitle(mTitle);
            break;
        }
    }

    // Put the good menu
    invalidateOptionsMenu();
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fmpdemo);
    /*? refer to  http://stackoverflow.com/questions/33129884/mediascannerconnection-fails-on-android-6-because-of-permission-denial*/
    myCheckPermission();//  w  ww  .  ja  va 2s .  c o  m

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

    Intent intent = getIntent();

    // 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 {
                long[] list = new long[1];
                list[0] = MusicUtils.insert(FMPDemo.this, uriString);

                mService.open(list, 0);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    });

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

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

@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
        String name = null;/*w  ww . j  av a 2s.  c  om*/
        if (ringtone != null) {
            Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), 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 == messageSoundRow) {
            if (name != null && ringtone != null) {
                editor.putString("GlobalSound", name);
                editor.putString("GlobalSoundPath", ringtone.toString());
            } else {
                editor.putString("GlobalSound", "NoSound");
                editor.putString("GlobalSoundPath", "NoSound");
            }
        } else if (requestCode == groupSoundRow) {
            if (name != null && ringtone != null) {
                editor.putString("GroupSound", name);
                editor.putString("GroupSoundPath", ringtone.toString());
            } else {
                editor.putString("GroupSound", "NoSound");
                editor.putString("GroupSoundPath", "NoSound");
            }
        }
        editor.commit();
        listView.invalidateViews();
    }
}

From source file:com.android.dialer.voicemail.VoicemailPlaybackPresenter.java

/**
 * Specify the view which this presenter controls and the voicemail to prepare to play.
 *//*from   w  w  w . jav  a 2 s  .  c o  m*/
public void setPlaybackView(PlaybackView view, Uri voicemailUri, boolean startPlayingImmediately) {
    mView = view;
    mView.setPresenter(this, voicemailUri);

    // Handles cases where the same entry is binded again when scrolling in list, or where
    // the MediaPlayer was retained after an orientation change.
    if (mMediaPlayer != null && mIsPrepared && voicemailUri.equals(mVoicemailUri)) {
        // If the voicemail card was rebinded, we need to set the position to the appropriate
        // point. Since we retain the media player, we can just set it to the position of the
        // media player.
        mPosition = mMediaPlayer.getCurrentPosition();
        onPrepared(mMediaPlayer);
    } else {
        if (!voicemailUri.equals(mVoicemailUri)) {
            mVoicemailUri = voicemailUri;
            mPosition = 0;
            // Default to earpiece.
            setSpeakerphoneOn(false);
            mVoicemailAudioManager.setSpeakerphoneOn(false);
        } else {
            // Update the view to the current speakerphone state.
            mView.onSpeakerphoneOn(mIsSpeakerphoneOn);
        }
        /*
         * Check to see if the content field in the DB is set. If set, we proceed to
         * prepareContent() method. We get the duration of the voicemail from the query and set
         * it if the content is not available.
         */
        checkForContent(new OnContentCheckedListener() {
            @Override
            public void onContentChecked(boolean hasContent) {
                if (hasContent) {
                    prepareContent();
                } else if (mView != null) {
                    mView.resetSeekBar();
                    mView.setClipPosition(0, mDuration.get());
                }
            }
        });

        if (startPlayingImmediately) {
            // Since setPlaybackView can get called during the view binding process, we don't
            // want to reset mIsPlaying to false if the user is currently playing the
            // voicemail and the view is rebound.
            mIsPlaying = startPlayingImmediately;
        }
    }
}

From source file:com.eutectoid.dosomething.picker.GraphObjectAdapter.java

private void downloadProfilePicture(final String profileId, Uri pictureUri, final ImageView imageView) {
    if (pictureUri == null) {
        return;//from  ww w .java 2s.c om
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureUri.equals(imageView.getTag())) {
        if (!prefetching) {
            // Setting the tag to the profile ID indicates that we're currently downloading the
            // picture for this profile; we'll set it to the actual picture URL when complete.
            imageView.setTag(profileId);
            imageView.setImageResource(getDefaultPicture());
        }

        ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureUri)
                .setCallerTag(this).setCallback(new ImageRequest.Callback() {
                    @Override
                    public void onCompleted(ImageResponse response) {
                        processImageResponse(response, profileId, imageView);
                    }
                });

        ImageRequest newRequest = builder.build();
        pendingRequests.put(profileId, newRequest);

        ImageDownloader.downloadAsync(newRequest);
    }
}

From source file:info.guardianproject.otr.app.im.app.MessageView.java

/**
 * @param contentResolver/*from w w w  . ja v a2s.  co m*/
 * @param aHolder
 * @param uri
 */
private void setThumbnail(final ContentResolver contentResolver, final ViewHolder aHolder, final Uri uri) {
    new AsyncTask<String, Void, Bitmap>() {

        @Override
        protected Bitmap doInBackground(String... params) {

            Bitmap result = mBitmapCache.get(uri.toString());

            if (result == null)
                return getThumbnail(contentResolver, uri);
            else
                return result;
        }

        @Override
        protected void onPostExecute(Bitmap result) {

            if (uri != null && result != null) {
                mBitmapCache.put(uri.toString(), result);

                // confirm the holder is still paired to this uri
                if (!uri.equals(aHolder.mMediaUri)) {
                    return;
                }
                // set the thumbnail
                aHolder.mMediaThumbnail.setImageBitmap(result);
            }
        }
    }.execute();
}

From source file:wseemann.media.demo.FMMRFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = super.onCreateView(inflater, container, savedInstanceState);
    ListView lv = (ListView) layout.findViewById(android.R.id.list);
    ViewGroup parent = (ViewGroup) lv.getParent();

    View v = inflater.inflate(R.layout.fragment, container, false);

    // Remove ListView and add my view in its place
    int lvIndex = parent.indexOfChild(lv);
    parent.removeViewAt(lvIndex);/*from ww w.jav a2s  . c o  m*/
    parent.addView(v, lvIndex, lv.getLayoutParams());

    final EditText uriText = (EditText) v.findViewById(R.id.uri);
    // Uncomment for debugging
    //uriText.setText("http://...");
    //uriText.setText("http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_stereo_abl.mp4");
    //https://ia700401.us.archive.org/19/items/ksnn_compilation_master_the_internet/ksnn_compilation_master_the_internet_512kb.mp4

    Intent intent = getActivity().getIntent();

    // 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) {
        }
    }

    getActivity().setIntent(null);

    Button goButton = (Button) v.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) FMMRFragment.this.getActivity()
                    .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;
            }

            // Start out with a progress indicator.
            setListShown(false);

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

            Bundle bundle = new Bundle();
            try {
                bundle.putString("uri", URLDecoder.decode(uriString, "UTF-8"));
                mId++;
                FMMRFragment.this.getLoaderManager().initLoader(mId, bundle, FMMRFragment.this);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            //   mAdapter.add(new Metadata("test", "test"));
            //   mAdapter.notifyDataSetChanged();
        }
    });

    return layout;
}

From source file:org.cgnet.swara.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;/*from  w ww  . j  a  v  a  2  s  .  c om*/
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    case 2:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }
        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
    }
}

From source file:com.app.uafeed.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;//from  www  .j  a  va 2s.com
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    case 2:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }
        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        mDrawerLayout.postDelayed(new Runnable() {
            @Override
            public void run() {
                mDrawerLayout.openDrawer(mDrawerList);
            } //   500  300
        }, 300);
    }
}

From source file:com.flym.echo24.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;//from   w  ww . j a  v a 2s  .c  o  m
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case SEARCH_DRAWER_POSITION:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }
        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        if (mDrawerLayout != null) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mLeftDrawer);
                }
            }, 500);
        }

        FeedDataContentProvider.addFeed(this, "http://echo24.cz/rss/s/domov", "Domov", true);
        FeedDataContentProvider.addFeed(this, "http://echo24.cz/rss/s/svet", "Svt", true);
        FeedDataContentProvider.addFeed(this, "http://echo24.cz/rss/s/byznys", "Byznys", true);
        FeedDataContentProvider.addFeed(this, "http://echo24.cz/rss/s/panorama", "Panorama", true);
        FeedDataContentProvider.addFeed(this, "http://echo24.cz/rss/s/nazory", "Nzory", true);
        FeedDataContentProvider.addFeed(this, "http://echo24.cz/rss/s/blogy", "Blogy", true);

        /*
                  AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.setTitle(R.string.welcome_title)
            .setItems(new CharSequence[]{getString(R.string.google_news_title), getString(R.string.add_custom_feed)}, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    if (which == 1) {
                        startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                    } else {
                        startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                    }
                }
            });
                    builder.show(); */
    }

    // Set title & icon
    switch (mCurrentDrawerPos) {
    case SEARCH_DRAWER_POSITION:
        getSupportActionBar().setTitle(android.R.string.search_go);
        getSupportActionBar().setIcon(R.drawable.action_search);
        break;

    default:
        getSupportActionBar().setTitle(mTitle);
        if (mIcon != null) {
            getSupportActionBar().setIcon(mIcon);
        } else {
            getSupportActionBar().setIcon(null);
        }
        break;
    }

    // Put the good menu
    invalidateOptionsMenu();
}