/** * Updates the Table based on the selection of the given table. Perform lookups to remove any * store files from the shared folder view and to only display store files in the store view */ void updateTableFiles(DirectoryHolder dirHolder) { if (dirHolder == null) { return; } if (dirHolder instanceof MediaTypeSavedFilesDirectoryHolder) { MediaType mediaType = ((MediaTypeSavedFilesDirectoryHolder) dirHolder).getMediaType(); setMediaType(mediaType); if (mediaType.equals(MediaType.getAudioMediaType())) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_AUDIO); } else if (mediaType == MediaType.getImageMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_PICTURES); } else if (mediaType == MediaType.getDocumentMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_DOCUMENTS); } else if (mediaType == MediaType.getVideoMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_VIDEOS); } else if (mediaType == MediaType.getTorrentMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_TORRENTS); } else if (mediaType == MediaType.getProgramMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_APPLICATIONS); } } else { setMediaType(MediaType.getAnyTypeMediaType()); } clearTable(); List<List<File>> partitionedFiles = split(100, Arrays.asList(dirHolder.getFiles())); for (List<File> partition : partitionedFiles) { final List<File> fPartition = partition; BackgroundExecutorService.schedule( new Runnable() { @Override public void run() { for (final File file : fPartition) { GUIMediator.safeInvokeLater( new Runnable() { public void run() { addUnsorted(file); } }); } GUIMediator.safeInvokeLater( new Runnable() { public void run() { LibraryMediator.instance().getLibrarySearch().addResults(fPartition.size()); } }); } }); } forceResort(); }
public void scan(String filePath) { try { MediaType mt = MediaType.getMediaTypeForExtension(FilenameUtils.getExtension(filePath)); if (mt == null) { scanDocument(filePath, true); } else if (mt.equals(MediaType.getAudioMediaType())) { scanAudio(filePath, true); } else if (mt.equals(MediaType.getImageMediaType())) { scanPictures(filePath, true); } else if (mt.equals(MediaType.getVideoMediaType())) { scanVideo( filePath, true); // until we integrate mplayer for video and research metadata extraction } else { scanDocument(filePath, true); } } catch (Throwable e) { scanDocument(filePath, true); LOG.log(Level.WARNING, "Error scanning file, scanned as document: " + filePath, e); } }