com.zhihu.matisse.internal.entity.IncapableCause Java Examples

The following examples show how to use com.zhihu.matisse.internal.entity.IncapableCause. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SelectedItemCollection.java    From Matisse with Apache License 2.0 6 votes vote down vote up
public IncapableCause isAcceptable(Item item) {
    if (maxSelectableReached()) {
        int maxSelectable = currentMaxSelectable();
        String cause;

        try {
            cause = mContext.getString(
                    R.string.error_over_count,
                    maxSelectable
            );
        } catch (Resources.NotFoundException e) {
            cause = mContext.getString(
                    R.string.error_over_count,
                    maxSelectable
            );
        }

        return new IncapableCause(cause);
    } else if (typeConflict(item)) {
        return new IncapableCause(mContext.getString(R.string.error_type_conflict));
    }

    return PhotoMetadataUtils.isAcceptable(mContext, item);
}
 
Example #2
Source File: GifSizeFilter.java    From Matisse with Apache License 2.0 5 votes vote down vote up
@Override
public IncapableCause filter(Context context, Item item) {
    if (!needFiltering(context, item))
        return null;

    Point size = PhotoMetadataUtils.getBitmapBound(context.getContentResolver(), item.getContentUri());
    if (size.x < mMinWidth || size.y < mMinHeight || item.size > mMaxSize) {
        return new IncapableCause(IncapableCause.DIALOG, context.getString(R.string.error_gif, mMinWidth,
                String.valueOf(PhotoMetadataUtils.getSizeInMB(mMaxSize))));
    }
    return null;
}
 
Example #3
Source File: PhotoMetadataUtils.java    From Matisse with Apache License 2.0 5 votes vote down vote up
public static IncapableCause isAcceptable(Context context, Item item) {
    if (!isSelectableType(context, item)) {
        return new IncapableCause(context.getString(R.string.error_file_type));
    }

    if (SelectionSpec.getInstance().filters != null) {
        for (Filter filter : SelectionSpec.getInstance().filters) {
            IncapableCause incapableCause = filter.filter(context, item);
            if (incapableCause != null) {
                return incapableCause;
            }
        }
    }
    return null;
}
 
Example #4
Source File: GifSizeFilter.java    From Matisse with Apache License 2.0 5 votes vote down vote up
@Override
public IncapableCause filter(Context context, Item item) {
    if (!needFiltering(context, item))
        return null;

    Point size = PhotoMetadataUtils.getBitmapBound(context.getContentResolver(), item.getContentUri());
    if (size.x < mMinWidth || size.y < mMinHeight || item.size > mMaxSize) {
        return new IncapableCause(IncapableCause.DIALOG, context.getString(R.string.error_gif, mMinWidth,
                String.valueOf(PhotoMetadataUtils.getSizeInMB(mMaxSize))));
    }
    return null;
}
 
Example #5
Source File: PhotoMetadataUtils.java    From Matisse with Apache License 2.0 5 votes vote down vote up
public static IncapableCause isAcceptable(Context context, Item item) {
    if (!isSelectableType(context, item)) {
        return new IncapableCause(context.getString(R.string.error_file_type));
    }

    if (SelectionSpec.getInstance().filters != null) {
        for (Filter filter : SelectionSpec.getInstance().filters) {
            IncapableCause incapableCause = filter.filter(context, item);
            if (incapableCause != null) {
                return incapableCause;
            }
        }
    }
    return null;
}
 
Example #6
Source File: GifSizeFilter.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@Override
public IncapableCause filter(Context context, Item item) {
    if (!needFiltering(context, item))
        return null;

    Point size = PhotoMetadataUtils.getBitmapBound(context.getContentResolver(), item.getContentUri());
    if (size.x < mMinWidth || size.y < mMinHeight || item.size > mMaxSize) {
        return new IncapableCause(IncapableCause.DIALOG, context.getString(R.string.error_gif, mMinWidth,
                String.valueOf(PhotoMetadataUtils.getSizeInMB(mMaxSize))));
    }
    return null;
}
 
Example #7
Source File: BasePreviewActivity.java    From Matisse with Apache License 2.0 4 votes vote down vote up
private boolean assertAddSelection(Item item) {
    IncapableCause cause = mSelectedCollection.isAcceptable(item);
    IncapableCause.handleCause(this, cause);
    return cause == null;
}
 
Example #8
Source File: AlbumMediaAdapter.java    From Matisse with Apache License 2.0 4 votes vote down vote up
private boolean assertAddSelection(Context context, Item item) {
    IncapableCause cause = mSelectedCollection.isAcceptable(item);
    IncapableCause.handleCause(context, cause);
    return cause == null;
}
 
Example #9
Source File: BasePreviewActivity.java    From Matisse with Apache License 2.0 4 votes vote down vote up
private boolean assertAddSelection(Item item) {
    IncapableCause cause = mSelectedCollection.isAcceptable(item);
    IncapableCause.handleCause(this, cause);
    return cause == null;
}
 
Example #10
Source File: AlbumMediaAdapter.java    From Matisse with Apache License 2.0 4 votes vote down vote up
private boolean assertAddSelection(Context context, Item item) {
    IncapableCause cause = mSelectedCollection.isAcceptable(item);
    IncapableCause.handleCause(context, cause);
    return cause == null;
}
 
Example #11
Source File: Filter.java    From Matisse with Apache License 2.0 2 votes vote down vote up
/**
 * Invoked for filtering each item.
 *
 * @return null if selectable, {@link IncapableCause} if not selectable.
 */
public abstract IncapableCause filter(Context context, Item item);
 
Example #12
Source File: Filter.java    From Matisse with Apache License 2.0 2 votes vote down vote up
/**
 * Invoked for filtering each item.
 *
 * @return null if selectable, {@link IncapableCause} if not selectable.
 */
public abstract IncapableCause filter(Context context, Item item);