Java Code Examples for com.zhihu.matisse.internal.entity.Item#isImage()

The following examples show how to use com.zhihu.matisse.internal.entity.Item#isImage() . 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 boolean add(Item item) {
    if (typeConflict(item)) {
        throw new IllegalArgumentException("Can't select images and videos at the same time.");
    }
    boolean added = mItems.add(item);
    if (added) {
        if (mCollectionType == COLLECTION_UNDEFINED) {
            if (item.isImage()) {
                mCollectionType = COLLECTION_IMAGE;
            } else if (item.isVideo()) {
                mCollectionType = COLLECTION_VIDEO;
            }
        } else if (mCollectionType == COLLECTION_IMAGE) {
            if (item.isVideo()) {
                mCollectionType = COLLECTION_MIXED;
            }
        } else if (mCollectionType == COLLECTION_VIDEO) {
            if (item.isImage()) {
                mCollectionType = COLLECTION_MIXED;
            }
        }
    }
    return added;
}
 
Example 2
Source File: SelectedItemCollection.java    From Matisse with Apache License 2.0 6 votes vote down vote up
public boolean add(Item item) {
    if (typeConflict(item)) {
        throw new IllegalArgumentException("Can't select images and videos at the same time.");
    }
    boolean added = mItems.add(item);
    if (added) {
        if (mCollectionType == COLLECTION_UNDEFINED) {
            if (item.isImage()) {
                mCollectionType = COLLECTION_IMAGE;
            } else if (item.isVideo()) {
                mCollectionType = COLLECTION_VIDEO;
            }
        } else if (mCollectionType == COLLECTION_IMAGE) {
            if (item.isVideo()) {
                mCollectionType = COLLECTION_MIXED;
            }
        } else if (mCollectionType == COLLECTION_VIDEO) {
            if (item.isImage()) {
                mCollectionType = COLLECTION_MIXED;
            }
        }
    }
    return added;
}
 
Example 3
Source File: MatisseActivity.java    From Matisse with Apache License 2.0 5 votes vote down vote up
private int countOverMaxSize() {
    int count = 0;
    int selectedCount = mSelectedCollection.count();
    for (int i = 0; i < selectedCount; i++) {
        Item item = mSelectedCollection.asList().get(i);

        if (item.isImage()) {
            float size = PhotoMetadataUtils.getSizeInMB(item.size);
            if (size > mSpec.originalMaxSize) {
                count++;
            }
        }
    }
    return count;
}
 
Example 4
Source File: SelectedItemCollection.java    From Matisse with Apache License 2.0 5 votes vote down vote up
private void refineCollectionType() {
    boolean hasImage = false;
    boolean hasVideo = false;
    for (Item i : mItems) {
        if (i.isImage() && !hasImage) hasImage = true;
        if (i.isVideo() && !hasVideo) hasVideo = true;
    }
    if (hasImage && hasVideo) {
        mCollectionType = COLLECTION_MIXED;
    } else if (hasImage) {
        mCollectionType = COLLECTION_IMAGE;
    } else if (hasVideo) {
        mCollectionType = COLLECTION_VIDEO;
    }
}
 
Example 5
Source File: BasePreviewActivity.java    From Matisse with Apache License 2.0 5 votes vote down vote up
private int countOverMaxSize() {
    int count = 0;
    int selectedCount = mSelectedCollection.count();
    for (int i = 0; i < selectedCount; i++) {
        Item item = mSelectedCollection.asList().get(i);
        if(item.isImage()){
            float size = PhotoMetadataUtils.getSizeInMB(item.size);
            if (size > mSpec.originalMaxSize) {
                count++;
            }
        }
    }
    return count;
}
 
Example 6
Source File: MatisseActivity.java    From Matisse with Apache License 2.0 5 votes vote down vote up
private int countOverMaxSize() {
    int count = 0;
    int selectedCount = mSelectedCollection.count();
    for (int i = 0; i < selectedCount; i++) {
        Item item = mSelectedCollection.asList().get(i);

        if (item.isImage()) {
            float size = PhotoMetadataUtils.getSizeInMB(item.size);
            if (size > mSpec.originalMaxSize) {
                count++;
            }
        }
    }
    return count;
}
 
Example 7
Source File: SelectedItemCollection.java    From Matisse with Apache License 2.0 5 votes vote down vote up
private void refineCollectionType() {
    boolean hasImage = false;
    boolean hasVideo = false;
    for (Item i : mItems) {
        if (i.isImage() && !hasImage) hasImage = true;
        if (i.isVideo() && !hasVideo) hasVideo = true;
    }
    if (hasImage && hasVideo) {
        mCollectionType = COLLECTION_MIXED;
    } else if (hasImage) {
        mCollectionType = COLLECTION_IMAGE;
    } else if (hasVideo) {
        mCollectionType = COLLECTION_VIDEO;
    }
}
 
Example 8
Source File: BasePreviewActivity.java    From Matisse with Apache License 2.0 5 votes vote down vote up
private int countOverMaxSize() {
    int count = 0;
    int selectedCount = mSelectedCollection.count();
    for (int i = 0; i < selectedCount; i++) {
        Item item = mSelectedCollection.asList().get(i);
        if (item.isImage()) {
            float size = PhotoMetadataUtils.getSizeInMB(item.size);
            if (size > mSpec.originalMaxSize) {
                count++;
            }
        }
    }
    return count;
}
 
Example 9
Source File: SelectedItemCollection.java    From Matisse with Apache License 2.0 4 votes vote down vote up
/**
 * Determine whether there will be conflict media types. A user can only select images and videos at the same time
 * while {@link SelectionSpec#mediaTypeExclusive} is set to false.
 */
public boolean typeConflict(Item item) {
    return SelectionSpec.getInstance().mediaTypeExclusive
            && ((item.isImage() && (mCollectionType == COLLECTION_VIDEO || mCollectionType == COLLECTION_MIXED))
            || (item.isVideo() && (mCollectionType == COLLECTION_IMAGE || mCollectionType == COLLECTION_MIXED)));
}
 
Example 10
Source File: SelectedItemCollection.java    From Matisse with Apache License 2.0 4 votes vote down vote up
/**
 * Determine whether there will be conflict media types. A user can only select images and videos at the same time
 * while {@link SelectionSpec#mediaTypeExclusive} is set to false.
 */
public boolean typeConflict(Item item) {
    return SelectionSpec.getInstance().mediaTypeExclusive
            && ((item.isImage() && (mCollectionType == COLLECTION_VIDEO || mCollectionType == COLLECTION_MIXED))
            || (item.isVideo() && (mCollectionType == COLLECTION_IMAGE || mCollectionType == COLLECTION_MIXED)));
}