yanzhenjie / Album

:watermelon: Album and Gallery for Android platform.
https://github.com/yanzhenjie/Album
Apache License 2.0
2.51k stars 507 forks source link

there is no duration of first video in list when using 'camera(false)' #269

Open fan90910 opened 5 years ago

fan90910 commented 5 years ago

Album.video(this) .singleChoice() .camera(false) .filterDuration(new Filter() { @Override public boolean filter(Long attributes) { return attributes < 3000; } }) .afterFilterVisibility(false)

just like this

fan90910 commented 5 years ago

image

EbelloImbox commented 3 years ago

Hello, I am trying to fix this problem, have you solved it?

EbelloImbox commented 3 years ago

I have found where is the problem, change inside of AlbumAdapter.java:

@Override
    public int getItemViewType(int position) {
        switch (position) {
            case 0: {
                if(hasCamera) {
                    return TYPE_BUTTON;
                }
                else {
                    AlbumFile albumFile = mAlbumFiles.get(position);
                    return albumFile.getMediaType() == AlbumFile.TYPE_VIDEO ? TYPE_VIDEO : TYPE_IMAGE;
                }
            }
            default: {
                position = hasCamera ? position - 1 : position;
                AlbumFile albumFile = mAlbumFiles.get(position);
                return albumFile.getMediaType() == AlbumFile.TYPE_VIDEO ? TYPE_VIDEO : TYPE_IMAGE;
            }
        }
    }

The problem was that the first element return image type.