hedzr / android-file-chooser

a lightweight file/folder chooser or picker
Apache License 2.0
284 stars 62 forks source link

Thumbnail of images #68

Open smedic opened 5 years ago

smedic commented 5 years ago

Is it possible to implement thumbnails for images? On left side, there can be a thumbnail instead of small file icon.

hedzr commented 5 years ago

There is no shortcut but:

.withAdapterSetter(new ChooserDialog.AdapterSetter() {
    @Override
    public void apply(DirAdapter adapter) {
        // since 1.1.17
        adapter.overrideGetView((file, isSelected, isFocused, convertView, parent, inflater) -> {
            ViewGroup view = (ViewGroup) inflater.inflate(R.layout.li_row, parent, false);
            ...
            return view;
        }
    }
})
smedic commented 5 years ago

How to use that? To set custom layout for every row, right?

hedzr commented 5 years ago

no bother so much:

    adapter.overrideGetView((file, isSelected, isFocused, convertView, parent, inflater) -> {
        ViewGroup view = (ViewGroup) inflater.inflate(com.obsez.filechooser.R.layout.li_row, parent, false);
        // ...
        // set filename, isSelected, isFocused to control views
        // ...
        ImageView iv = view.findViewById(com.obsez.filechooser.R.layout.icon) // ?? find the right res id from xml source file pls.
        // ...generate thumb image and set it to iv

        return view;
    }

pls refer the redIds from the source xml of R.layout.li_row. sorry for the simple reply from phone editor.

Guiorgy commented 5 years ago

@smedic, if the only thing you want to change are the icons, you can copy the source code of getView in DirAdapter here

smedic commented 5 years ago

Thanks for prompt answers, I ll try this :)