Search in sources :

Example 1 with AssetModel

use of com.chute.sdk.v2.model.AssetModel in project photo-picker-plus-android by chute.

the class AssetUtil method getMediaModel.

/**
	 * Creates and {@link AssetModel} out of the given {@link DeliverMediaModel}
	 * .
	 * 
	 * @param model
	 *            {@link DeliverMediaModel}
	 * @return {@link AssetModel}
	 */
public static AssetModel getMediaModel(DeliverMediaModel model) {
    final AssetModel asset = new AssetModel();
    asset.setId(model.getLocalMediaUri().toString());
    asset.setThumbnail(Uri.fromFile(new File(model.getThumbnail())).toString());
    asset.setUrl(Uri.fromFile(new File(model.getImageUrl())).toString());
    if (model.getVideoUrl() != null) {
        asset.setVideoUrl(Uri.fromFile(new File(model.getVideoUrl())).toString());
    }
    asset.setType(model.getMediaType().name().toLowerCase());
    return asset;
}
Also used : AssetModel(com.chute.sdk.v2.model.AssetModel) File(java.io.File)

Example 2 with AssetModel

use of com.chute.sdk.v2.model.AssetModel 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 3 with AssetModel

use of com.chute.sdk.v2.model.AssetModel in project photo-picker-plus-android by chute.

the class PhotoPickerPlusTutorialActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != Activity.RESULT_OK) {
        return;
    }
    final PhotoPickerPlusIntentWrapper wrapper = new PhotoPickerPlusIntentWrapper(data);
    List<AssetModel> accountMediaList = wrapper.getMediaCollection();
    AccountModel accountModel = wrapper.getAccountModel();
    Log.d(TAG, accountMediaList.toString());
    Intent intent = new Intent(getApplicationContext(), PhotoGridActivity.class);
    intent.putParcelableArrayListExtra(KEY_MEDIA_LSIT, (ArrayList) accountMediaList);
    startActivity(intent);
}
Also used : AccountModel(com.chute.sdk.v2.model.AccountModel) PhotoPickerPlusIntentWrapper(com.getchute.android.photopickerplus.util.intent.PhotoPickerPlusIntentWrapper) AssetModel(com.chute.sdk.v2.model.AssetModel) Intent(android.content.Intent)

Example 4 with AssetModel

use of com.chute.sdk.v2.model.AssetModel in project photo-picker-plus-android by chute.

the class AssetUtil method getPhotoCollection.

/**
	 * Creates a list of {@link AssetModel}s from the given
	 * {@link DeliverMediaModel} list.
	 * 
	 * @param resultList
	 *            List of {@link DeliverMediaModel}s
	 * @return List of {@link AssetModel}s
	 */
public static List<AssetModel> getPhotoCollection(List<DeliverMediaModel> resultList) {
    final List<AssetModel> collection = new ArrayList<AssetModel>();
    for (DeliverMediaModel result : resultList) {
        AssetModel asset = getMediaModel(result);
        collection.add(asset);
    }
    return collection;
}
Also used : DeliverMediaModel(com.getchute.android.photopickerplus.models.DeliverMediaModel) ArrayList(java.util.ArrayList) AssetModel(com.chute.sdk.v2.model.AssetModel)

Example 5 with AssetModel

use of com.chute.sdk.v2.model.AssetModel in project photo-picker-plus-android by chute.

the class GridAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    AssetModel asset = getItem(position);
    int orientation = resolveImageOrientation(asset);
    Picasso.with(holder.itemView.getContext()).load(asset.getThumbnail()).placeholder(R.drawable.placeholder).into(holder.imageView);
    if (asset.getType().equalsIgnoreCase(MediaType.VIDEO.name().toLowerCase())) {
        holder.videoIcon.setVisibility(View.VISIBLE);
    } else {
        holder.videoIcon.setVisibility(View.GONE);
    }
}
Also used : AssetModel(com.chute.sdk.v2.model.AssetModel)

Aggregations

AssetModel (com.chute.sdk.v2.model.AssetModel)7 Uri (android.net.Uri)3 File (java.io.File)3 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 AccountModel (com.chute.sdk.v2.model.AccountModel)1 DeliverMediaModel (com.getchute.android.photopickerplus.models.DeliverMediaModel)1 PhotoPickerPlusIntentWrapper (com.getchute.android.photopickerplus.util.intent.PhotoPickerPlusIntentWrapper)1 ArrayList (java.util.ArrayList)1