use of com.frostwire.search.SearchResult in project frostwire by frostwire.
the class SearchTableTest method testAddSingleListener.
@Test
public void testAddSingleListener() {
SearchTable t = new SearchTable(0);
final AtomicBoolean b1 = new AtomicBoolean(false);
final AtomicBoolean b2 = new AtomicBoolean(false);
SearchView view = t.view(SearchFilter.NONE);
view.setListener(new SearchViewListener() {
@Override
public void viewChanged(SearchView view) {
b2.set(true);
}
@Override
public void viewAdded(SearchView view, List<SearchResult> results) {
b1.set(true);
}
});
t.add(new TestSearchResult("a"));
assertTrue(b1.get());
t.clear();
assertTrue(b2.get());
}
use of com.frostwire.search.SearchResult in project frostwire by frostwire.
the class SearchResultActionsRenderer method labelPartialDownload_mouseReleased.
private void labelPartialDownload_mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
SearchResult sr = searchResult.getSearchResult();
if (sr instanceof CrawlableSearchResult || sr instanceof ArchiveorgTorrentSearchResult) {
searchResult.download(true);
UXStats.instance().log(UXAction.SEARCH_RESULT_DETAIL_VIEW);
if (sr instanceof ArchiveorgTorrentSearchResult) {
GUIMediator.instance().showTransfers(TransfersTab.FilterMode.ALL);
}
}
}
}
use of com.frostwire.search.SearchResult in project frostwire by frostwire.
the class YouTubeSearchPerformer method crawlResult.
@Override
protected List<? extends SearchResult> crawlResult(YouTubeSearchResult sr, byte[] data) throws Exception {
List<SearchResult> list = new LinkedList<>();
String detailsUrl = sr.getDetailsUrl();
List<LinkInfo> infos = new YouTubeExtractor().extract(detailsUrl, false);
LinkInfo dashVideo = null;
LinkInfo dashAudio = null;
LinkInfo demuxVideo = null;
LinkInfo minQuality = null;
for (LinkInfo inf : infos) {
if (inf.fmt == 18) {
// save this format for the heuristic of selecting audio
// from dash or demuxing a video one
demuxVideo = inf;
}
if (!isDash(inf)) {
if (inf.fmt == 18) {
minQuality = inf;
}
list.add(new YouTubeCrawledStreamableSearchResult(sr, inf, null, minQuality));
} else {
if (inf.fmt == 137) {
// 1080p
dashVideo = inf;
}
if (inf.fmt == 141) {
// 256k
dashAudio = inf;
}
if (inf.fmt == 140 && dashAudio == null) {
// 128k
dashAudio = inf;
}
}
}
if (dashVideo != null && dashAudio != null) {
list.add(new YouTubeCrawledSearchResult(sr, dashVideo, dashAudio));
}
LinkInfo infoAudio = selectFormatForAudio(sr, dashAudio, demuxVideo);
if (infoAudio != null) {
list.add(new YouTubeCrawledStreamableSearchResult(sr, null, infoAudio, minQuality));
}
YouTubePackageSearchResult packagedResult = new YouTubePackageSearchResult(sr, list);
List<SearchResult> results = new LinkedList<>();
results.add(packagedResult);
results.addAll(list);
return results;
}
use of com.frostwire.search.SearchResult in project frostwire by frostwire.
the class SearchResultActionsRenderer method updateUIData.
private void updateUIData(SearchResultActionsHolder actionsHolder, JTable table, int row) {
cancelEdit();
if (actionsHolder == null) {
return;
}
searchResult = actionsHolder.getSearchResult();
if (searchResult == null) {
return;
}
showSolid = mouseIsOverRow(table, row);
labelPlay.setVisible(isSearchResultPlayable());
if (labelPlay.isVisible()) {
updatePlayButton();
}
labelDownload.setIcon(showSolid ? download_solid : download_transparent);
labelDownload.setVisible(true);
labelPartialDownload.setIcon(showSolid ? details_solid : details_transparent);
SearchResult sr = searchResult.getSearchResult();
labelPartialDownload.setVisible(sr instanceof CrawlableSearchResult || sr instanceof ArchiveorgTorrentSearchResult);
}
use of com.frostwire.search.SearchResult in project frostwire by frostwire.
the class SearchResultMediator method buildListeners.
/**
* Sets all the listeners.
*/
protected void buildListeners() {
super.buildListeners();
DOWNLOAD_LISTENER = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e != null && e.getSource() instanceof JButton) {
UXStats.instance().log(UXAction.SEARCH_RESULT_BIG_BUTTON_DOWNLOAD);
}
SearchMediator.doDownload(SearchResultMediator.this);
}
};
TORRENT_DETAILS_LISTENER = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
final SearchResultDataLine[] lines = getAllSelectedLines();
if (lines.length == 1) {
UISearchResult searchResult = lines[0].getSearchResult();
searchResult.showDetails(true);
}
}
}
};
COPY_MAGNET_ACTION_LISTENER = new ActionListener() {
public void actionPerformed(ActionEvent e) {
SearchResultDataLine[] lines = getAllSelectedLines();
StringBuilder sb = new StringBuilder();
for (SearchResultDataLine line : lines) {
sb.append(TorrentUtil.getMagnet(line.getInitializeObject()));
sb.append("\n");
}
GUIMediator.setClipboardContent(sb.toString());
}
};
COPY_HASH_ACTION_LISTENER = new ActionListener() {
public void actionPerformed(ActionEvent e) {
SearchResultDataLine[] lines = getAllSelectedLines();
StringBuilder sb = new StringBuilder();
for (SearchResultDataLine line : lines) {
sb.append(line.getInitializeObject().getHash());
sb.append("\n");
}
GUIMediator.setClipboardContent(sb.toString());
}
};
CONFIGURE_SHARING_LISTENER = new ActionListener() {
public void actionPerformed(ActionEvent e) {
GUIMediator.instance().setOptionsVisible(true, tr("Options"));
}
};
DOWNLOAD_PARTIAL_FILES_LISTENER = new ActionListener() {
public void actionPerformed(ActionEvent e) {
SearchResultDataLine[] lines = getAllSelectedLines();
if (lines.length == 1 && lines[0] != null) {
final SearchResult sr = lines[0].getInitializeObject().getSearchResult();
if (sr instanceof TorrentSearchResult) {
// GUIMediator gm = GUIMediator.instance();
// if (sr instanceof ScrapedTorrentFileSearchResult) {
// gm.openTorrentSearchResult((ScrapedTorrentFileSearchResult) sr);
// } else {
GUIMediator.instance().openTorrentSearchResult((TorrentSearchResult) sr, true);
// }
}
}
}
};
STOP_SEARCH_LISTENER = new ActionListener() {
public void actionPerformed(ActionEvent e) {
SearchMediator.instance().stopSearch(token);
updateSearchIcon(false);
setButtonEnabled(SearchButtons.STOP_SEARCH_BUTTON_INDEX, false);
}
};
}
Aggregations