Matisse过滤视频条件
public class VideoTimeFilter extends Filter {
private final int timeDuration = 15;
@Override
protected Set<MimeType> constraintTypes() {
return new HashSet<MimeType>(){{
for (MimeType mimeType : MimeType.ofVideo()){
add(mimeType);
}
}};
}
@SuppressLint("StringFormatInvalid")
@Override
public IncapableCause filter(Context context, Item item) {
if (!needFiltering(context,item)){
return null;
} else if (item.duration >15000){
return new IncapableCause(IncapableCause.DIALOG,context.getString(R.string.error_video,timeDuration+""));
}else {
return null;
}
}
}