Search in sources :

Example 1 with DownloadRequestException

use of de.danoeh.antennapod.core.storage.DownloadRequestException in project AntennaPod by AntennaPod.

the class ItemlistFragment method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    if (menuInfo == null) {
        menuInfo = lastMenuInfo;
    }
    // because of addHeaderView(), positions are increased by 1!
    FeedItem selectedItem = itemAccess.getItem(menuInfo.position - 1);
    if (selectedItem == null) {
        Log.i(TAG, "Selected item at position " + menuInfo.position + " was null, ignoring selection");
        return super.onContextItemSelected(item);
    }
    try {
        return FeedItemMenuHandler.onMenuItemClicked(getActivity(), item.getItemId(), selectedItem);
    } catch (DownloadRequestException e) {
        // context menu doesn't contain download functionality
        return true;
    }
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) AdapterView(android.widget.AdapterView) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException)

Example 2 with DownloadRequestException

use of de.danoeh.antennapod.core.storage.DownloadRequestException in project AntennaPod by AntennaPod.

the class ItemlistFragment method setupFooterView.

private void setupFooterView() {
    if (getListView() == null || feed == null) {
        Log.e(TAG, "Unable to setup listview: recyclerView = null or feed = null");
        return;
    }
    if (feed.isPaged() && feed.getNextPageLink() != null) {
        ListView lv = getListView();
        LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View header = inflater.inflate(R.layout.more_content_list_footer, lv, false);
        lv.addFooterView(header);
        listFooter = new MoreContentListFooterUtil(header);
        listFooter.setClickListener(() -> {
            if (feed != null) {
                try {
                    DBTasks.loadNextPageOfFeed(getActivity(), feed, false);
                } catch (DownloadRequestException e) {
                    e.printStackTrace();
                    DownloadRequestErrorDialogCreator.newRequestErrorDialog(getActivity(), e.getMessage());
                }
            }
        });
    }
}
Also used : ListView(android.widget.ListView) LayoutInflater(android.view.LayoutInflater) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) IconTextView(com.joanzapata.iconify.widget.IconTextView) MoreContentListFooterUtil(de.danoeh.antennapod.core.util.gui.MoreContentListFooterUtil)

Example 3 with DownloadRequestException

use of de.danoeh.antennapod.core.storage.DownloadRequestException in project AntennaPod by AntennaPod.

the class OpmlFeedQueuer method doInBackground.

@Override
protected Void doInBackground(Void... params) {
    DownloadRequester requester = DownloadRequester.getInstance();
    for (int selected : selection) {
        OpmlElement element = OpmlImportHolder.getReadElements().get(selected);
        Feed feed = new Feed(element.getXmlUrl(), null, element.getText());
        try {
            requester.downloadFeed(context.getApplicationContext(), feed);
        } catch (DownloadRequestException e) {
            e.printStackTrace();
        }
    }
    return null;
}
Also used : DownloadRequester(de.danoeh.antennapod.core.storage.DownloadRequester) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException) SuppressLint(android.annotation.SuppressLint) OpmlElement(de.danoeh.antennapod.core.export.opml.OpmlElement) Feed(de.danoeh.antennapod.core.feed.Feed)

Example 4 with DownloadRequestException

use of de.danoeh.antennapod.core.storage.DownloadRequestException in project AntennaPod by AntennaPod.

the class AllEpisodesFragment method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    Log.d(TAG, "onContextItemSelected() called with: " + "item = [" + item + "]");
    if (!isVisible()) {
        return false;
    }
    if (item.getItemId() == R.id.share_item) {
        // avoids that the position is reset when we need it in the submenu
        return true;
    }
    int pos = listAdapter.getPosition();
    if (pos < 0) {
        return false;
    }
    FeedItem selectedItem = itemAccess.getItem(pos);
    if (selectedItem == null) {
        Log.i(TAG, "Selected item at position " + pos + " was null, ignoring selection");
        return super.onContextItemSelected(item);
    }
    try {
        return FeedItemMenuHandler.onMenuItemClicked(getActivity(), item.getItemId(), selectedItem);
    } catch (DownloadRequestException e) {
        e.printStackTrace();
        Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
        return true;
    }
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException)

Example 5 with DownloadRequestException

use of de.danoeh.antennapod.core.storage.DownloadRequestException in project AntennaPod by AntennaPod.

the class GpodnetSyncService method syncSubscriptionChanges.

private synchronized void syncSubscriptionChanges() {
    final long timestamp = GpodnetPreferences.getLastSubscriptionSyncTimestamp();
    try {
        final List<String> localSubscriptions = DBReader.getFeedListDownloadUrls();
        Collection<String> localAdded = GpodnetPreferences.getAddedFeedsCopy();
        Collection<String> localRemoved = GpodnetPreferences.getRemovedFeedsCopy();
        GpodnetService service = tryLogin();
        // first sync: download all subscriptions...
        GpodnetSubscriptionChange subscriptionChanges = service.getSubscriptionChanges(GpodnetPreferences.getUsername(), GpodnetPreferences.getDeviceID(), timestamp);
        long newTimeStamp = subscriptionChanges.getTimestamp();
        Log.d(TAG, "Downloaded subscription changes: " + subscriptionChanges);
        processSubscriptionChanges(localSubscriptions, localAdded, localRemoved, subscriptionChanges);
        if (timestamp == 0) {
            // this is this apps first sync with gpodder:
            // only submit changes gpodder has not just sent us
            localAdded = localSubscriptions;
            localAdded.removeAll(subscriptionChanges.getAdded());
            localRemoved.removeAll(subscriptionChanges.getRemoved());
        }
        if (localAdded.size() > 0 || localRemoved.size() > 0) {
            Log.d(TAG, String.format("Uploading subscriptions, Added: %s\nRemoved: %s", localAdded, localRemoved));
            GpodnetUploadChangesResponse uploadResponse = service.uploadChanges(GpodnetPreferences.getUsername(), GpodnetPreferences.getDeviceID(), localAdded, localRemoved);
            newTimeStamp = uploadResponse.timestamp;
            Log.d(TAG, "Upload changes response: " + uploadResponse);
            GpodnetPreferences.removeAddedFeeds(localAdded);
            GpodnetPreferences.removeRemovedFeeds(localRemoved);
        }
        GpodnetPreferences.setLastSubscriptionSyncTimestamp(newTimeStamp);
        GpodnetPreferences.setLastSyncAttempt(true, System.currentTimeMillis());
        clearErrorNotifications();
    } catch (GpodnetServiceException e) {
        e.printStackTrace();
        updateErrorNotification(e);
    } catch (DownloadRequestException e) {
        e.printStackTrace();
    }
}
Also used : GpodnetSubscriptionChange(de.danoeh.antennapod.core.gpoddernet.model.GpodnetSubscriptionChange) GpodnetServiceException(de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException) GpodnetService(de.danoeh.antennapod.core.gpoddernet.GpodnetService) GpodnetUploadChangesResponse(de.danoeh.antennapod.core.gpoddernet.model.GpodnetUploadChangesResponse) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException)

Aggregations

DownloadRequestException (de.danoeh.antennapod.core.storage.DownloadRequestException)10 FeedItem (de.danoeh.antennapod.core.feed.FeedItem)3 AdapterView (android.widget.AdapterView)2 GpodnetService (de.danoeh.antennapod.core.gpoddernet.GpodnetService)2 GpodnetServiceException (de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException)2 SuppressLint (android.annotation.SuppressLint)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 SearchView (android.support.v7.widget.SearchView)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 IconTextView (com.joanzapata.iconify.widget.IconTextView)1 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 FeedRemover (de.danoeh.antennapod.core.asynctask.FeedRemover)1 ConfirmationDialog (de.danoeh.antennapod.core.dialog.ConfirmationDialog)1 OpmlElement (de.danoeh.antennapod.core.export.opml.OpmlElement)1