Use xattr metadata as info object by default

This commit is contained in:
Reinhard Pointner 2016-05-06 01:25:58 +08:00
parent e8295884ba
commit db455e027a
1 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,7 @@
package net.filebot.ui.list;
import static net.filebot.media.XattrMetaInfo.*;
import java.io.File;
import java.util.List;
import java.util.Map;
@ -16,7 +18,7 @@ public class IndexedBindingBean extends MediaBindingBean {
private int to;
public IndexedBindingBean(Object object, int i, int from, int to, List<?> context) {
super(object, getMediaFile(object), getContext(context));
super(getInfoObject(object), getMediaFile(object), getContext(context));
this.i = i;
this.from = from;
this.to = to;
@ -37,12 +39,26 @@ public class IndexedBindingBean extends MediaBindingBean {
return to;
}
private static Object getInfoObject(Object object) {
if (object instanceof File) {
File file = (File) object;
Object metaInfo = xattr.getMetaInfo(file);
if (metaInfo != null) {
return metaInfo;
}
}
return object;
}
private static File getMediaFile(Object object) {
return object instanceof File ? (File) object : new File(object.toString());
}
private static Map<File, Object> getContext(List<?> context) {
return new EntryList<File, Object>(new FunctionList<Object, File>((List<Object>) context, IndexedBindingBean::getMediaFile), context);
List<Object> values = new FunctionList<Object, Object>((List<Object>) context, IndexedBindingBean::getInfoObject);
List<File> files = new FunctionList<Object, File>((List<Object>) context, IndexedBindingBean::getMediaFile);
return new EntryList<File, Object>(files, values);
}
}