use of de.danoeh.antennapod.core.util.LongList in project AntennaPod by AntennaPod.
the class DBReader method getFavoriteIDList.
public static LongList getFavoriteIDList() {
Log.d(TAG, "getFavoriteIDList() called");
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
Cursor favoritesCursor = adapter.getFavoritesCursor();
LongList favoriteIDs = new LongList(favoritesCursor.getCount());
if (favoritesCursor.moveToFirst()) {
do {
favoriteIDs.add(favoritesCursor.getLong(0));
} while (favoritesCursor.moveToNext());
}
favoritesCursor.close();
adapter.close();
return favoriteIDs;
}
use of de.danoeh.antennapod.core.util.LongList in project AntennaPod by AntennaPod.
the class DBReader method extractItemlistFromCursor.
private static List<FeedItem> extractItemlistFromCursor(PodDBAdapter adapter, Cursor cursor) {
List<FeedItem> result = new ArrayList<>(cursor.getCount());
LongList imageIds = new LongList(cursor.getCount());
LongList itemIds = new LongList(cursor.getCount());
if (cursor.moveToFirst()) {
do {
int indexImage = cursor.getColumnIndex(PodDBAdapter.KEY_IMAGE);
long imageId = cursor.getLong(indexImage);
imageIds.add(imageId);
FeedItem item = FeedItem.fromCursor(cursor);
result.add(item);
itemIds.add(item.getId());
} while (cursor.moveToNext());
Map<Long, FeedImage> images = getFeedImages(adapter, imageIds.toArray());
Map<Long, FeedMedia> medias = getFeedMedia(adapter, itemIds.toArray());
for (int i = 0; i < result.size(); i++) {
FeedItem item = result.get(i);
long imageId = imageIds.get(i);
FeedImage image = images.get(imageId);
item.setImage(image);
FeedMedia media = medias.get(item.getId());
item.setMedia(media);
if (media != null) {
media.setItem(item);
}
}
}
return result;
}
use of de.danoeh.antennapod.core.util.LongList in project AntennaPod by AntennaPod.
the class DBReader method getQueueIDList.
static LongList getQueueIDList(PodDBAdapter adapter) {
Cursor queueCursor = adapter.getQueueIDCursor();
LongList queueIds = new LongList(queueCursor.getCount());
if (queueCursor.moveToFirst()) {
do {
queueIds.add(queueCursor.getLong(0));
} while (queueCursor.moveToNext());
}
queueCursor.close();
return queueIds;
}
use of de.danoeh.antennapod.core.util.LongList in project AntennaPod by AntennaPod.
the class FeedItemFilter method filter.
/**
* Run a list of feed items through the filter.
*/
public List<FeedItem> filter(List<FeedItem> items) {
if (mProperties.length == 0)
return items;
List<FeedItem> result = new ArrayList<>();
// (e.g. requiring played and unplayed at the same time)
if (showPlayed && showUnplayed)
return result;
if (showQueued && showNotQueued)
return result;
if (showDownloaded && showNotDownloaded)
return result;
final LongList queuedIds = DBReader.getQueueIDList();
for (FeedItem item : items) {
// If the item does not meet a requirement, skip it.
if (showPlayed && !item.isPlayed())
continue;
if (showUnplayed && item.isPlayed())
continue;
if (showPaused && item.getState() != FeedItem.State.IN_PROGRESS)
continue;
boolean queued = queuedIds.contains(item.getId());
if (showQueued && !queued)
continue;
if (showNotQueued && queued)
continue;
boolean downloaded = item.getMedia() != null && item.getMedia().isDownloaded();
if (showDownloaded && !downloaded)
continue;
if (showNotDownloaded && downloaded)
continue;
if (showHasMedia && !item.hasMedia())
continue;
// If the item reaches here, it meets all criteria
result.add(item);
}
return result;
}
use of de.danoeh.antennapod.core.util.LongList in project AntennaPod by AntennaPod.
the class ItemFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View layout = inflater.inflate(R.layout.feeditem_fragment, container, false);
root = (ViewGroup) layout.findViewById(R.id.content_root);
LinearLayout header = (LinearLayout) root.findViewById(R.id.header);
if (feedItems.length > 0) {
header.setOnTouchListener((v, event) -> headerGestureDetector.onTouchEvent(event));
}
txtvPodcast = (TextView) layout.findViewById(R.id.txtvPodcast);
txtvPodcast.setOnClickListener(v -> openPodcast());
txtvTitle = (TextView) layout.findViewById(R.id.txtvTitle);
if (Build.VERSION.SDK_INT >= 23) {
txtvTitle.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
}
txtvDuration = (TextView) layout.findViewById(R.id.txtvDuration);
txtvPublished = (TextView) layout.findViewById(R.id.txtvPublished);
if (Build.VERSION.SDK_INT >= 14) {
// ellipsize is causing problems on old versions, see #448
txtvTitle.setEllipsize(TextUtils.TruncateAt.END);
}
webvDescription = (WebView) layout.findViewById(R.id.webvDescription);
if (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) {
if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
webvDescription.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
webvDescription.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.black));
}
webvDescription.getSettings().setUseWideViewPort(false);
webvDescription.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webvDescription.getSettings().setLoadWithOverviewMode(true);
if (feedItems.length > 0) {
webvDescription.setOnLongClickListener(webViewLongClickListener);
}
webvDescription.setOnTouchListener((v, event) -> webviewGestureDetector.onTouchEvent(event));
webvDescription.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
if (IntentUtils.isCallable(getActivity(), intent)) {
startActivity(intent);
}
return true;
}
});
registerForContextMenu(webvDescription);
imgvCover = (ImageView) layout.findViewById(R.id.imgvCover);
imgvCover.setOnClickListener(v -> openPodcast());
progbarDownload = (ProgressBar) layout.findViewById(R.id.progbarDownload);
progbarLoading = (ProgressBar) layout.findViewById(R.id.progbarLoading);
butAction1 = (IconButton) layout.findViewById(R.id.butAction1);
butAction2 = (IconButton) layout.findViewById(R.id.butAction2);
butAction1.setOnClickListener(v -> {
if (item == null) {
return;
}
DefaultActionButtonCallback actionButtonCallback = new DefaultActionButtonCallback(getActivity());
actionButtonCallback.onActionButtonPressed(item, item.isTagged(FeedItem.TAG_QUEUE) ? LongList.of(item.getId()) : new LongList(0));
FeedMedia media = item.getMedia();
if (media != null && media.isDownloaded()) {
((MainActivity) getActivity()).dismissChildFragment();
}
});
butAction2.setOnClickListener(v -> {
if (item == null) {
return;
}
if (item.hasMedia()) {
FeedMedia media = item.getMedia();
if (!media.isDownloaded()) {
DBTasks.playMedia(getActivity(), media, true, true, true);
((MainActivity) getActivity()).dismissChildFragment();
} else {
DBWriter.deleteFeedMediaOfItem(getActivity(), media.getId());
}
} else if (item.getLink() != null) {
Uri uri = Uri.parse(item.getLink());
getActivity().startActivity(new Intent(Intent.ACTION_VIEW, uri));
}
});
return layout;
}
Aggregations