use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.
the class NamedMediaType method getFromDescription.
/**
* Retrieves the named media type for the specified schema uri.
*
* This should only be used if you are positive that the media type
* is already cached for this description OR it is not a default
* type.
*/
public static NamedMediaType getFromDescription(String description) {
NamedMediaType type = CACHED_TYPES.get(description);
if (type != null)
return type;
MediaType mt = MediaType.getMediaTypeForSchema(description);
return getFromMediaType(mt);
}
use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.
the class LibraryFilesTransferHandler method canImport.
@Override
public boolean canImport(TransferSupport support) {
try {
LibraryNode node = getNodeFromLocation(support.getDropLocation());
if (!(node instanceof DirectoryHolderNode)) {
return false;
}
DirectoryHolder dirHolder = ((DirectoryHolderNode) node).getDirectoryHolder();
// dropping folder or folders on file types and finished downloads.
if (droppingFoldersToAddToLibrary(support, dirHolder, true)) {
return true;
}
if (!(dirHolder instanceof MediaTypeSavedFilesDirectoryHolder)) {
return false;
}
MediaTypeSavedFilesDirectoryHolder mediaTypeSavedFilesDirHolder = (MediaTypeSavedFilesDirectoryHolder) dirHolder;
MediaType mt = mediaTypeSavedFilesDirHolder.getMediaType();
return mt.equals(MediaType.getAudioMediaType()) && DNDUtils.supportCanImport(LibraryPlaylistsTableTransferable.ITEM_ARRAY, support, null, false);
} catch (Throwable e) {
LOG.error("Error in LibraryFilesTransferHandler processing", e);
}
return false;
}
use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.
the class LibraryFilesTableMediator method updateTableFiles.
/**
* 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();
}
use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.
the class NamedMediaType method getFromExtension.
/**
* Retrieves the named media type from the specified extension.
*
* This should only be used if you are positive that the media type
* is already cached for this extension.
*/
public static NamedMediaType getFromExtension(String extension) {
MediaType mt = MediaType.getMediaTypeForExtension(extension);
if (mt == null)
return null;
String description = mt.getMimeType();
return getFromDescription(description);
}
Aggregations