Search in sources :

Example 1 with Uri

use of android.net.Uri in project Meizhi by drakeet.

the class WebActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch(id) {
        case R.id.action_refresh:
            refresh();
            return true;
        case R.id.action_copy_url:
            String copyDone = getString(R.string.tip_copy_done);
            Androids.copyToClipBoard(this, mWebView.getUrl(), copyDone);
            return true;
        case R.id.action_open_url:
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            Uri uri = Uri.parse(mUrl);
            intent.setData(uri);
            if (intent.resolveActivity(getPackageManager()) != null) {
                startActivity(intent);
            } else {
                Toasts.showLong(R.string.tip_open_fail);
            }
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : Intent(android.content.Intent) Uri(android.net.Uri)

Example 2 with Uri

use of android.net.Uri in project kickmaterial by byoutline.

the class VideoActivity method setDataFromArgs.

private void setDataFromArgs() {
    Intent intent = getIntent();
    if (intent == null) {
        // NOI18E
        LogUtils.LOGE(TAG, "Null intent");
        return;
    }
    Bundle args = intent.getExtras();
    if (args == null) {
        // NOI18E
        LogUtils.LOGE(TAG, "Null args");
        return;
    }
    String videoUrl = args.getString(BUNDLE_VIDEO_URL);
    String altVideoUrl = args.getString(BUNDLE_ALT_VIDEO_URL);
    String webviewUrl = args.getString(BUNDLE_WEBVIEW_URL);
    Uri uri = Uri.parse(videoUrl);
    videoView.setMediaController(new VideoController(this, webviewUrl));
    videoView.setVideoURI(uri);
    videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {

        boolean tryAltVideo = !TextUtils.isEmpty(altVideoUrl);

        @Override
        public boolean onError(MediaPlayer mediaPlayer, int i, int i1) {
            if (tryAltVideo) {
                tryAltVideo = false;
                videoView.setVideoURI(Uri.parse(altVideoUrl));
                videoView.start();
                return true;
            }
            return false;
        }
    });
    videoView.setOnCompletionListener(mediaPlayer -> finish());
    videoView.requestFocus();
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) VideoController(com.byoutline.kickmaterial.views.VideoController) Uri(android.net.Uri) MediaPlayer(android.media.MediaPlayer)

Example 3 with Uri

use of android.net.Uri in project Android-ShareEverywhere by dgmltn.

the class MainActivity method getRandomImageUri.

// Get the uri to a random image in the photo gallery
private Uri getRandomImageUri() {
    Uri mediaUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
    String[] projection = { MediaStore.Images.Media._ID };
    Cursor cursor = null;
    try {
        cursor = getContentResolver().query(mediaUri, projection, null, null, null);
        cursor.moveToPosition((int) (Math.random() * cursor.getCount()));
        String id = cursor.getString(0);
        Uri uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id);
        return uri;
    } catch (Exception e) {
        return null;
    } finally {
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }
    }
}
Also used : Cursor(android.database.Cursor) Uri(android.net.Uri)

Example 4 with Uri

use of android.net.Uri in project Android-ShareEverywhere by dgmltn.

the class MainActivity method getImageIntent.

private Intent getImageIntent() {
    Uri imageUri = getRandomImageUri();
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
    shareIntent.setType("image/jpeg");
    return shareIntent;
}
Also used : Intent(android.content.Intent) Uri(android.net.Uri)

Example 5 with Uri

use of android.net.Uri in project photo-picker-plus-android by chute.

the class ServicesRecyclerAdapter method setupLocalService.

private void setupLocalService(ListItemViewHolder holder, LocalServiceType type) {
    Uri lastVideoThumbFromAllVideos = MediaDAO.getLastVideoThumbnailFromAllVideos(context.getApplicationContext());
    Uri lastVideoThumbFromCameraVideos = MediaDAO.getLastVideoThumbnailFromCameraVideos(context.getApplicationContext());
    Uri lastImageFromAllPhotos = MediaDAO.getLastPhotoFromAllPhotos(context.getApplicationContext());
    Uri lastImageFromCameraPhotos = MediaDAO.getLastPhotoFromCameraPhotos(context.getApplicationContext());
    switch(type) {
        case TAKE_PHOTO:
            holder.imageViewService.setBackgroundResource(R.drawable.take_photo);
            holder.textViewServiceTitle.setText(R.string.take_photos);
            break;
        case CAMERA_MEDIA:
            Uri uriCameraMedia = null;
            if (supportsImages) {
                uriCameraMedia = lastImageFromAllPhotos;
            } else {
                uriCameraMedia = lastVideoThumbFromCameraVideos;
            }
            Picasso.with(context).load(uriCameraMedia).fit().centerCrop().into(holder.imageViewService);
            holder.textViewServiceTitle.setText(R.string.camera_media);
            break;
        case LAST_PHOTO_TAKEN:
            Picasso.with(context).load(lastImageFromAllPhotos).fit().centerCrop().into(holder.imageViewService);
            holder.textViewServiceTitle.setText(context.getResources().getString(R.string.last_photo));
            break;
        case ALL_MEDIA:
            Uri uriAllMedia = null;
            if (supportsImages) {
                uriAllMedia = lastImageFromAllPhotos;
            } else {
                uriAllMedia = lastVideoThumbFromAllVideos;
            }
            Picasso.with(context).load(uriAllMedia).fit().centerCrop().into(holder.imageViewService);
            holder.textViewServiceTitle.setText(context.getResources().getString(R.string.all_media));
            break;
        case LAST_VIDEO_CAPTURED:
            String thumbnail = MediaDAO.getLastVideoThumbnailFromCurosr(context);
            Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(thumbnail, MediaStore.Images.Thumbnails.MINI_KIND);
            holder.imageViewService.setImageBitmap(bitmap);
            holder.textViewServiceTitle.setText(context.getResources().getString(R.string.last_video_captured));
            break;
        case RECORD_VIDEO:
            holder.imageViewService.setBackgroundResource(R.drawable.take_photo);
            holder.textViewServiceTitle.setText(R.string.record_video);
            break;
    }
    /* Click listeners */
    switch(type) {
        case ALL_MEDIA:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.photoStream();
                }
            });
            break;
        case CAMERA_MEDIA:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.cameraRoll();
                }
            });
            break;
        case TAKE_PHOTO:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.takePhoto();
                }
            });
            break;
        case LAST_PHOTO_TAKEN:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.lastPhoto();
                }
            });
            break;
        case LAST_VIDEO_CAPTURED:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.lastVideo();
                }
            });
            break;
        case RECORD_VIDEO:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.recordVideo();
                }
            });
            break;
    }
}
Also used : Bitmap(android.graphics.Bitmap) OnClickListener(android.view.View.OnClickListener) Uri(android.net.Uri) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Uri (android.net.Uri)6700 Intent (android.content.Intent)1538 Cursor (android.database.Cursor)891 File (java.io.File)739 Test (org.junit.Test)622 ContentValues (android.content.ContentValues)614 IOException (java.io.IOException)563 ContentResolver (android.content.ContentResolver)448 ArrayList (java.util.ArrayList)445 Bundle (android.os.Bundle)286 Context (android.content.Context)275 Bitmap (android.graphics.Bitmap)266 InputStream (java.io.InputStream)253 View (android.view.View)248 RemoteException (android.os.RemoteException)228 PendingIntent (android.app.PendingIntent)206 SuppressLint (android.annotation.SuppressLint)179 FileNotFoundException (java.io.FileNotFoundException)174 TextView (android.widget.TextView)172 ActivityNotFoundException (android.content.ActivityNotFoundException)170