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);
}
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();
}
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();
}
}
}
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;
}
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;
}
}
Aggregations