Search in sources :

Example 6 with Uri

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);
}
Also used : Bitmap(android.graphics.Bitmap) AssetModel(com.chute.sdk.v2.model.AssetModel) File(java.io.File) Uri(android.net.Uri)

Example 7 with Uri

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));
}
Also used : CursorLoader(android.content.CursorLoader) Uri(android.net.Uri)

Example 8 with Uri

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();
        }
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) Uri(android.net.Uri)

Example 9 with Uri

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);
}
Also used : SQLException(android.database.SQLException) Uri(android.net.Uri)

Example 10 with Uri

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);
}
Also used : Uri(android.net.Uri)

Aggregations

Uri (android.net.Uri)6747 Intent (android.content.Intent)1547 Cursor (android.database.Cursor)894 File (java.io.File)744 Test (org.junit.Test)632 ContentValues (android.content.ContentValues)614 IOException (java.io.IOException)571 ContentResolver (android.content.ContentResolver)449 ArrayList (java.util.ArrayList)446 Bundle (android.os.Bundle)289 Context (android.content.Context)276 Bitmap (android.graphics.Bitmap)273 InputStream (java.io.InputStream)257 View (android.view.View)251 RemoteException (android.os.RemoteException)228 PendingIntent (android.app.PendingIntent)209 SuppressLint (android.annotation.SuppressLint)180 FileNotFoundException (java.io.FileNotFoundException)177 TextView (android.widget.TextView)175 ActivityNotFoundException (android.content.ActivityNotFoundException)169