use of de.danoeh.antennapod.core.feed.Feed in project AntennaPod by AntennaPod.
the class DownloadRequester method downloadMedia.
public synchronized void downloadMedia(Context context, FeedMedia feedmedia) throws DownloadRequestException {
if (feedFileValid(feedmedia)) {
Feed feed = feedmedia.getItem().getFeed();
String username;
String password;
if (feed != null && feed.getPreferences() != null) {
username = feed.getPreferences().getUsername();
password = feed.getPreferences().getPassword();
} else {
username = null;
password = null;
}
File dest;
if (feedmedia.getFile_url() != null) {
dest = new File(feedmedia.getFile_url());
} else {
dest = new File(getMediafilePath(context, feedmedia), getMediafilename(feedmedia));
}
download(context, feedmedia, feed, dest, false, username, password, null, false, null);
}
}
use of de.danoeh.antennapod.core.feed.Feed in project AntennaPod by AntennaPod.
the class DBReader method extractFeedFromCursorRow.
private static Feed extractFeedFromCursorRow(PodDBAdapter adapter, Cursor cursor) {
final FeedImage image;
int indexImage = cursor.getColumnIndex(PodDBAdapter.KEY_IMAGE);
long imageId = cursor.getLong(indexImage);
if (imageId != 0) {
image = getFeedImage(adapter, imageId);
} else {
image = null;
}
Feed feed = Feed.fromCursor(cursor);
if (image != null) {
feed.setImage(image);
image.setOwner(feed);
}
FeedPreferences preferences = FeedPreferences.fromCursor(cursor);
feed.setPreferences(preferences);
return feed;
}
use of de.danoeh.antennapod.core.feed.Feed in project AntennaPod by AntennaPod.
the class PodDBAdapter method setImage.
/**
* Inserts or updates an image entry
*
* @return the id of the entry
*/
public long setImage(FeedImage image) {
boolean startedTransaction = false;
try {
if (!db.inTransaction()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
db.beginTransactionNonExclusive();
} else {
db.beginTransaction();
}
startedTransaction = true;
}
ContentValues values = new ContentValues();
values.put(KEY_TITLE, image.getTitle());
values.put(KEY_DOWNLOAD_URL, image.getDownload_url());
values.put(KEY_DOWNLOADED, image.isDownloaded());
values.put(KEY_FILE_URL, image.getFile_url());
if (image.getId() == 0) {
image.setId(db.insert(TABLE_NAME_FEED_IMAGES, null, values));
} else {
db.update(TABLE_NAME_FEED_IMAGES, values, KEY_ID + "=?", new String[] { String.valueOf(image.getId()) });
}
final FeedComponent owner = image.getOwner();
if (owner != null && owner.getId() != 0) {
values.clear();
values.put(KEY_IMAGE, image.getId());
if (owner instanceof Feed) {
db.update(TABLE_NAME_FEEDS, values, KEY_ID + "=?", new String[] { String.valueOf(image.getOwner().getId()) });
}
}
if (startedTransaction) {
db.setTransactionSuccessful();
}
} catch (SQLException e) {
Log.e(TAG, Log.getStackTraceString(e));
} finally {
if (startedTransaction) {
db.endTransaction();
}
}
return image.getId();
}
use of de.danoeh.antennapod.core.feed.Feed in project AntennaPod by AntennaPod.
the class GpodnetSyncService method processSubscriptionChanges.
private synchronized void processSubscriptionChanges(List<String> localSubscriptions, Collection<String> localAdded, Collection<String> localRemoved, GpodnetSubscriptionChange changes) throws DownloadRequestException {
// add subscription if (1) not already subscribed and (2) not just unsubscribed
for (String downloadUrl : changes.getAdded()) {
if (!localSubscriptions.contains(downloadUrl) && !localRemoved.contains(downloadUrl)) {
Feed feed = new Feed(downloadUrl, null);
DownloadRequester.getInstance().downloadFeed(this, feed);
}
}
// remove subscription if not just subscribed (again)
for (String downloadUrl : changes.getRemoved()) {
if (!localAdded.contains(downloadUrl)) {
DBTasks.removeFeedWithDownloadUrl(GpodnetSyncService.this, downloadUrl);
}
}
}
use of de.danoeh.antennapod.core.feed.Feed in project AntennaPod by AntennaPod.
the class SubscriptionFragment method onCreateContextMenu.
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
AdapterView.AdapterContextMenuInfo adapterInfo = (AdapterView.AdapterContextMenuInfo) menuInfo;
int position = adapterInfo.position;
Object selectedObject = subscriptionAdapter.getItem(position);
if (selectedObject.equals(SubscriptionsAdapter.ADD_ITEM_OBJ)) {
mPosition = position;
return;
}
Feed feed = (Feed) selectedObject;
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.nav_feed_context, menu);
menu.setHeaderTitle(feed.getTitle());
mPosition = position;
}
Aggregations