use of android.net.Uri in project photo-picker-plus-android by chute.
the class MediaScannerWrapper method onScanCompleted.
public void onScanCompleted(String path, Uri uri) {
File file = new File(path);
Uri uriFromFile = Uri.fromFile(file);
String imagePath = "";
if (mMimeType == MediaType.IMAGE) {
if (AppUtil.hasImageCaptureBug() == false) {
imagePath = uriFromFile.toString();
} else {
imagePath = Uri.fromFile(new File(AppUtil.getPath(context, intent.getData()))).toString();
}
} else if (mMimeType == MediaType.VIDEO) {
imagePath = uriFromFile.toString();
}
final AssetModel model = new AssetModel();
if (uri != null) {
model.setId(uri.toString());
}
if (mMimeType == MediaType.VIDEO) {
Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(file.getAbsolutePath(), MediaStore.Images.Thumbnails.MINI_KIND);
model.setThumbnail(thumbnail != null ? (AppUtil.getImagePath(context.getApplicationContext(), thumbnail)) : null);
model.setVideoUrl(imagePath);
} else {
model.setThumbnail(imagePath);
}
model.setUrl(imagePath);
model.setType(mMimeType.name().toLowerCase());
IntentUtil.deliverDataToInitialActivity((ServicesActivity) context, model, null);
}
use of android.net.Uri in project cw-omnibus by commonsguy.
the class ContactSpinners method onCreateLoader.
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) {
String[] projection;
Uri uri;
switch(loaderId) {
case LOADER_NAMES:
projection = PROJECTION_NAMES;
uri = ContactsContract.Contacts.CONTENT_URI;
break;
case LOADER_NAMES_NUMBERS:
projection = PROJECTION_NUMBERS;
uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
break;
default:
projection = PROJECTION_EMAILS;
uri = ContactsContract.CommonDataKinds.Email.CONTENT_URI;
break;
}
return (new CursorLoader(this, uri, projection, null, null, ContactsContract.Contacts.DISPLAY_NAME));
}
use of android.net.Uri in project cw-omnibus by commonsguy.
the class MainActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CONTENT_REQUEST) {
if (resultCode == RESULT_OK) {
Intent i = new Intent(Intent.ACTION_VIEW);
Uri outputUri = FileProvider.getUriForFile(this, AUTHORITY, output);
i.setDataAndType(outputUri, "image/jpeg");
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
startActivity(i);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.msg_no_viewer, Toast.LENGTH_LONG).show();
}
finish();
}
}
}
use of android.net.Uri in project cw-omnibus by commonsguy.
the class Provider method insert.
@Override
public Uri insert(Uri url, ContentValues initialValues) {
long rowID = db.getWritableDatabase().insert(TABLE, Constants.TITLE, initialValues);
if (rowID > 0) {
Uri uri = ContentUris.withAppendedId(Provider.Constants.CONTENT_URI, rowID);
getContext().getContentResolver().notifyChange(uri, null);
return (uri);
}
throw new SQLException("Failed to insert row into " + url);
}
use of android.net.Uri in project cw-omnibus by commonsguy.
the class RowController method bindModel.
void bindModel(Cursor row) {
title.setText(row.getString(row.getColumnIndex(MediaStore.Video.Media.TITLE)));
Uri video = ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, row.getInt(row.getColumnIndex(MediaStore.Video.Media._ID)));
Picasso.with(thumbnail.getContext()).load(video.toString()).fit().centerCrop().placeholder(R.drawable.ic_media_video_poster).into(thumbnail);
int uriColumn = row.getColumnIndex(MediaStore.Video.Media.DATA);
int mimeTypeColumn = row.getColumnIndex(MediaStore.Video.Media.MIME_TYPE);
videoUri = row.getString(uriColumn);
videoMimeType = row.getString(mimeTypeColumn);
}
Aggregations