Search in sources :

Example 6 with Feed

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);
    }
}
Also used : FeedFile(de.danoeh.antennapod.core.feed.FeedFile) File(java.io.File) Feed(de.danoeh.antennapod.core.feed.Feed)

Example 7 with Feed

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;
}
Also used : FeedPreferences(de.danoeh.antennapod.core.feed.FeedPreferences) FeedImage(de.danoeh.antennapod.core.feed.FeedImage) Feed(de.danoeh.antennapod.core.feed.Feed)

Example 8 with 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();
}
Also used : ContentValues(android.content.ContentValues) SQLException(android.database.SQLException) FeedComponent(de.danoeh.antennapod.core.feed.FeedComponent) Feed(de.danoeh.antennapod.core.feed.Feed)

Example 9 with Feed

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);
        }
    }
}
Also used : Feed(de.danoeh.antennapod.core.feed.Feed)

Example 10 with Feed

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;
}
Also used : MenuInflater(android.view.MenuInflater) AdapterView(android.widget.AdapterView) Feed(de.danoeh.antennapod.core.feed.Feed)

Aggregations

Feed (de.danoeh.antennapod.core.feed.Feed)95 FeedItem (de.danoeh.antennapod.core.feed.FeedItem)55 PodDBAdapter (de.danoeh.antennapod.core.storage.PodDBAdapter)32 ArrayList (java.util.ArrayList)30 Date (java.util.Date)30 FeedMedia (de.danoeh.antennapod.core.feed.FeedMedia)21 File (java.io.File)20 Cursor (android.database.Cursor)16 FeedImage (de.danoeh.antennapod.core.feed.FeedImage)14 Context (android.content.Context)13 FlakyTest (android.test.FlakyTest)9 DialogInterface (android.content.DialogInterface)8 Intent (android.content.Intent)8 LayoutInflater (android.view.LayoutInflater)7 AdapterView (android.widget.AdapterView)7 ConfirmationDialog (de.danoeh.antennapod.core.dialog.ConfirmationDialog)6 FeedPreferences (de.danoeh.antennapod.core.feed.FeedPreferences)6 DownloadRequestException (de.danoeh.antennapod.core.storage.DownloadRequestException)6 Log (android.util.Log)4 View (android.view.View)4