picture_library/src/main/java/com/luck/picture/lib/adapter/PictureImageGridAdapter.java
/**
     * Handle mask effects
     *
     * @param contentHolder
     * @param item
     */
Handle mask effects
@param contentHolder
@param item
Handle mask effects @param contentHolder @param item
private void dispatchHandleMask(ViewHolder contentHolder, LocalMedia item) {
        if (config.isWithVideoImage && config.maxVideoSelectNum > 0) {
            if (getSelectedSize() >= config.maxSelectNum) {
                boolean isSelected = contentHolder.tvCheck.isSelected();
                contentHolder.ivPicture.setColorFilter(ContextCompat.getColor
                        (context, isSelected ? R.color.picture_color_80 : R.color.picture_color_half_white), PorterDuff.Mode.SRC_ATOP);
                item.setMaxSelectEnabledMask(!isSelected);
            } else {
                item.setMaxSelectEnabledMask(false);
            }
        } else {
            LocalMedia media = selectData.size() > 0 ? selectData.get(0) : null;
            if (media != null) {
                boolean isSelected = contentHolder.tvCheck.isSelected();
                if (config.chooseMode == PictureMimeType.ofAll()) {
                    if (PictureMimeType.isHasImage(media.getMimeType())) {
                        if (!isSelected && !PictureMimeType.isHasImage(item.getMimeType())) {
                            contentHolder.ivPicture.setColorFilter(ContextCompat.getColor
                                    (context, PictureMimeType.isHasVideo(item.getMimeType()) ? R.color.picture_color_half_white : R.color.picture_color_20), PorterDuff.Mode.SRC_ATOP);
                        }
                        item.setMaxSelectEnabledMask(PictureMimeType.isHasVideo(item.getMimeType()));
                    } else if (PictureMimeType.isHasVideo(media.getMimeType())) {
                        if (!isSelected && !PictureMimeType.isHasVideo(item.getMimeType())) {
                            contentHolder.ivPicture.setColorFilter(ContextCompat.getColor
                                    (context, PictureMimeType.isHasImage(item.getMimeType()) ? R.color.picture_color_half_white : R.color.picture_color_20), PorterDuff.Mode.SRC_ATOP);
                        }
                        item.setMaxSelectEnabledMask(PictureMimeType.isHasImage(item.getMimeType()));
                    }
                } else {
                    if (config.chooseMode == PictureMimeType.ofVideo() && config.maxVideoSelectNum > 0) {
                        if (!isSelected && getSelectedSize() == config.maxVideoSelectNum) {
                            contentHolder.ivPicture.setColorFilter(ContextCompat.getColor
                                    (context, R.color.picture_color_half_white), PorterDuff.Mode.SRC_ATOP);
                        }
                        item.setMaxSelectEnabledMask(!isSelected && getSelectedSize() == config.maxVideoSelectNum);
                    } else {
                        if (!isSelected && getSelectedSize() == config.maxSelectNum) {
                            contentHolder.ivPicture.setColorFilter(ContextCompat.getColor
                                    (context, R.color.picture_color_half_white), PorterDuff.Mode.SRC_ATOP);
                        }
                        item.setMaxSelectEnabledMask(!isSelected && getSelectedSize() == config.maxSelectNum);
                    }
                }
            }
        }
    }
private void dispatchHandleMask ( ViewHolder contentHolder , LocalMedia item ) { if ( config . isWithVideoImage && config . maxVideoSelectNum > 0 ) { if ( getSelectedSize ( ) >= config . maxSelectNum ) { boolean isSelected = contentHolder . tvCheck . isSelected ( ) ; contentHolder . ivPicture . setColorFilter ( ContextCompat . getColor ( context , isSelected ? R . color . picture_color_80 : R . color . picture_color_half_white ) , PorterDuff . Mode . SRC_ATOP ) ; item . setMaxSelectEnabledMask ( ! isSelected ) ; } else { item . setMaxSelectEnabledMask ( false ) ; } } else { LocalMedia media = selectData . size ( ) > 0 ? selectData . get ( 0 ) : null ; if ( media != null ) { boolean isSelected = contentHolder . tvCheck . isSelected ( ) ; if ( config . chooseMode == PictureMimeType . ofAll ( ) ) { if ( PictureMimeType . isHasImage ( media . getMimeType ( ) ) ) { if ( ! isSelected && ! PictureMimeType . isHasImage ( item . getMimeType ( ) ) ) { contentHolder . ivPicture . setColorFilter ( ContextCompat . getColor ( context , PictureMimeType . isHasVideo ( item . getMimeType ( ) ) ? R . color . picture_color_half_white : R . color . picture_color_20 ) , PorterDuff . Mode . SRC_ATOP ) ; } item . setMaxSelectEnabledMask ( PictureMimeType . isHasVideo ( item . getMimeType ( ) ) ) ; } else if ( PictureMimeType . isHasVideo ( media . getMimeType ( ) ) ) { if ( ! isSelected && ! PictureMimeType . isHasVideo ( item . getMimeType ( ) ) ) { contentHolder . ivPicture . setColorFilter ( ContextCompat . getColor ( context , PictureMimeType . isHasImage ( item . getMimeType ( ) ) ? R . color . picture_color_half_white : R . color . picture_color_20 ) , PorterDuff . Mode . SRC_ATOP ) ; } item . setMaxSelectEnabledMask ( PictureMimeType . isHasImage ( item . getMimeType ( ) ) ) ; } } else { if ( config . chooseMode == PictureMimeType . ofVideo ( ) && config . maxVideoSelectNum > 0 ) { if ( ! isSelected && getSelectedSize ( ) == config . maxVideoSelectNum ) { contentHolder . ivPicture . setColorFilter ( ContextCompat . getColor ( context , R . color . picture_color_half_white ) , PorterDuff . Mode . SRC_ATOP ) ; } item . setMaxSelectEnabledMask ( ! isSelected && getSelectedSize ( ) == config . maxVideoSelectNum ) ; } else { if ( ! isSelected && getSelectedSize ( ) == config . maxSelectNum ) { contentHolder . ivPicture . setColorFilter ( ContextCompat . getColor ( context , R . color . picture_color_half_white ) , PorterDuff . Mode . SRC_ATOP ) ; } item . setMaxSelectEnabledMask ( ! isSelected && getSelectedSize ( ) == config . maxSelectNum ) ; } } } } }
Handle mask effects
 @param contentHolder
 @param item
Handle mask effects @param contentHolder @param item
// All videos are not optional // All images are not optional