1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-02 08:25:02 -04:00

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

View File

@ -1,5 +1,7 @@
package net.filebot.ui.list; package net.filebot.ui.list;
import static net.filebot.media.XattrMetaInfo.*;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -16,7 +18,7 @@ public class IndexedBindingBean extends MediaBindingBean {
private int to; private int to;
public IndexedBindingBean(Object object, int i, int from, int to, List<?> context) { 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.i = i;
this.from = from; this.from = from;
this.to = to; this.to = to;
@ -37,12 +39,26 @@ public class IndexedBindingBean extends MediaBindingBean {
return to; 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) { private static File getMediaFile(Object object) {
return object instanceof File ? (File) object : new File(object.toString()); return object instanceof File ? (File) object : new File(object.toString());
} }
private static Map<File, Object> getContext(List<?> context) { 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);
} }
} }