Removed unused code

This commit is contained in:
ByteHamster 2020-03-25 22:45:14 +01:00
parent 3399be1290
commit 902215c18d
39 changed files with 65 additions and 448 deletions

View File

@ -139,19 +139,19 @@ public class FeedHandlerTest {
@Test
public void testRSS2Basic() throws IOException, UnsupportedFeedtypeException, SAXException, ParserConfigurationException {
Feed f1 = createTestFeed(10, false, true, true);
Feed f1 = createTestFeed(10, true);
Feed f2 = runFeedTest(f1, new RSS2Generator(), "UTF-8", RSS2Generator.FEATURE_WRITE_GUID);
feedValid(f1, f2, Feed.TYPE_RSS2);
}
@Test
public void testAtomBasic() throws IOException, UnsupportedFeedtypeException, SAXException, ParserConfigurationException {
Feed f1 = createTestFeed(10, false, true, true);
Feed f1 = createTestFeed(10, true);
Feed f2 = runFeedTest(f1, new AtomGenerator(), "UTF-8", 0);
feedValid(f1, f2, Feed.TYPE_ATOM1);
}
private Feed createTestFeed(int numItems, boolean withImage, boolean withFeedMedia, boolean withChapters) {
private Feed createTestFeed(int numItems, boolean withFeedMedia) {
Feed feed = new Feed(0, null, "title", "http://example.com", "This is the description",
"http://example.com/payment", "Daniel", "en", null, "http://example.com/feed", "http://example.com/picture", file.getAbsolutePath(),
"http://example.com/feed", true);

View File

@ -45,13 +45,10 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @see HttpDownloaderTest for the test of actual download (and saving the file)
* @see HttpDownloaderTest for the test of actual download (and saving the file).
*/
@RunWith(AndroidJUnit4.class)
public class DownloadServiceTest {
private CountDownLatch latch = null;
private Feed testFeed = null;
private FeedMedia testMedia11 = null;
private DownloaderFactory origFactory = null;
@ -61,7 +58,7 @@ public class DownloadServiceTest {
EspressoTestUtils.clearDatabase();
EspressoTestUtils.clearPreferences();
origFactory = DownloadService.getDownloaderFactory();
testFeed = setUpTestFeeds();
Feed testFeed = setUpTestFeeds();
testMedia11 = testFeed.getItemAtIndex(0).getMedia();
}

View File

@ -124,7 +124,6 @@ public class PlaybackServiceMediaPlayerTest {
}
private Playable writeTestPlayable(String downloadUrl, String fileUrl) {
final Context c = getInstrumentation().getTargetContext();
Feed f = new Feed(0, null, "f", "l", "d", null, null, null, null, "i", null, null, "l", false);
FeedPreferences prefs = new FeedPreferences(f.getId(), false, FeedPreferences.AutoDeleteAction.NO, VolumeAdaptionSetting.OFF, null, null);
f.setPreferences(prefs);

View File

@ -1,20 +1,16 @@
package de.test.antennapod.storage;
import android.content.Context;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.filters.SmallTest;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.FeedItemStatistics;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
import de.danoeh.antennapod.core.util.LongList;
import org.junit.After;
@ -103,7 +99,6 @@ public class DBReaderTest {
@Test
public void testLoadFeedDataOfFeedItemlist() {
final Context context = InstrumentationRegistry.getTargetContext();
final int numFeeds = 10;
final int numItems = 1;
List<Feed> feeds = saveFeedlist(numFeeds, numItems, false);
@ -313,24 +308,11 @@ public class DBReaderTest {
}
}
@Test
public void testGetFeedStatisticsCheckOrder() {
final int NUM_FEEDS = 10;
final int NUM_ITEMS = 10;
List<Feed> feeds = DBTestUtils.saveFeedlist(NUM_FEEDS, NUM_ITEMS, false);
List<FeedItemStatistics> statistics = DBReader.getFeedStatisticsList();
assertNotNull(statistics);
assertEquals(feeds.size(), statistics.size());
for (int i = 0; i < NUM_FEEDS; i++) {
assertEquals("Wrong entry at index " + i, feeds.get(i).getId(), statistics.get(i).getFeedID());
}
}
@Test
public void testGetNavDrawerDataQueueEmptyNoUnreadItems() {
final int NUM_FEEDS = 10;
final int NUM_ITEMS = 10;
List<Feed> feeds = DBTestUtils.saveFeedlist(NUM_FEEDS, NUM_ITEMS, true);
DBTestUtils.saveFeedlist(NUM_FEEDS, NUM_ITEMS, true);
DBReader.NavDrawerData navDrawerData = DBReader.getNavDrawerData();
assertEquals(NUM_FEEDS, navDrawerData.feeds.size());
assertEquals(0, navDrawerData.numNewItems);

View File

@ -422,7 +422,6 @@ public class DBWriterTest {
}
private FeedMedia playbackHistorySetup(Date playbackCompletionDate) {
final Context context = getInstrumentation().getTargetContext();
Feed feed = new Feed("url", null, "title");
feed.setItems(new ArrayList<>());
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed);
@ -558,7 +557,6 @@ public class DBWriterTest {
@Test
public void testAddQueueItemMultipleItems() throws InterruptedException, ExecutionException, TimeoutException {
final Context context = getInstrumentation().getTargetContext();
final int NUM_ITEMS = 10;
Feed feed = queueTestSetupMultipleItems(NUM_ITEMS);
@ -583,7 +581,7 @@ public class DBWriterTest {
public void testClearQueue() throws InterruptedException, ExecutionException, TimeoutException {
final int NUM_ITEMS = 10;
Feed feed = queueTestSetupMultipleItems(NUM_ITEMS);
queueTestSetupMultipleItems(NUM_ITEMS);
DBWriter.clearQueue().get(TIMEOUT, TimeUnit.SECONDS);
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();

View File

@ -618,7 +618,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
private final String feedUrl;
FeedViewAuthenticationDialog(Context context, int titleRes, String feedUrl) {
super(context, titleRes, true, false, null, null);
super(context, titleRes, true, null, null);
this.feedUrl = feedUrl;
}
@ -629,7 +629,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
}
@Override
protected void onConfirmed(String username, String password, boolean saveUsernamePassword) {
protected void onConfirmed(String username, String password) {
startFeedDownload(feedUrl, username, password);
}
}

View File

@ -190,8 +190,6 @@ public class GpodnetAuthenticationActivity extends AppCompatActivity {
final AtomicReference<List<GpodnetDevice>> devices = new AtomicReference<>();
new AsyncTask<GpodnetService, Void, List<GpodnetDevice>>() {
private volatile Exception exception;
@Override
protected void onPreExecute() {
super.onPreExecute();
@ -226,7 +224,6 @@ public class GpodnetAuthenticationActivity extends AppCompatActivity {
return params[0].getDevices(username);
} catch (GpodnetServiceException e) {
e.printStackTrace();
exception = e;
return null;
}
}

View File

@ -38,13 +38,6 @@ public abstract class StatisticsListAdapter extends RecyclerView.Adapter<Recycle
return statisticsData.size() + 1;
}
public StatisticsItem getItem(int position) {
if (position == 0) {
return null;
}
return statisticsData.get(position - 1);
}
@Override
public int getItemViewType(int position) {
return position == 0 ? TYPE_HEADER : TYPE_FEED;

View File

@ -44,11 +44,6 @@ public class DownloadServiceCallbacksImpl implements DownloadServiceCallbacks {
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
@Override
public void onFeedParsed(Context context, Feed feed) {
// do nothing
}
@Override
public boolean shouldCreateReport() {
return true;

View File

@ -33,8 +33,4 @@ public class PlaybackServiceCallbacksImpl implements PlaybackServiceCallbacks {
return true;
}
@Override
public int getNotificationIconResource(Context context) {
return R.drawable.ic_antenna;
}
}

View File

@ -3,7 +3,6 @@ package de.danoeh.antennapod.dialog;
import android.app.AlertDialog;
import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import de.danoeh.antennapod.R;
@ -13,8 +12,7 @@ import de.danoeh.antennapod.R;
public abstract class AuthenticationDialog extends AlertDialog.Builder {
public AuthenticationDialog(Context context, int titleRes, boolean enableUsernameField,
boolean showSaveCredentialsCheckbox, String usernameInitialValue,
String passwordInitialValue) {
String usernameInitialValue, String passwordInitialValue) {
super(context);
setTitle(titleRes);
View rootView = View.inflate(context, R.layout.authentication_dialog, null);
@ -22,14 +20,8 @@ public abstract class AuthenticationDialog extends AlertDialog.Builder {
final EditText etxtUsername = rootView.findViewById(R.id.etxtUsername);
final EditText etxtPassword = rootView.findViewById(R.id.etxtPassword);
final CheckBox saveUsernamePassword = rootView.findViewById(R.id.chkSaveUsernamePassword);
etxtUsername.setEnabled(enableUsernameField);
if (showSaveCredentialsCheckbox) {
saveUsernamePassword.setVisibility(View.VISIBLE);
} else {
saveUsernamePassword.setVisibility(View.GONE);
}
if (usernameInitialValue != null) {
etxtUsername.setText(usernameInitialValue);
}
@ -39,13 +31,12 @@ public abstract class AuthenticationDialog extends AlertDialog.Builder {
setOnCancelListener(dialog -> onCancelled());
setNegativeButton(R.string.cancel_label, null);
setPositiveButton(R.string.confirm_label, (dialog, which)
-> onConfirmed(etxtUsername.getText().toString(), etxtPassword.getText().toString(),
showSaveCredentialsCheckbox && saveUsernamePassword.isChecked()));
-> onConfirmed(etxtUsername.getText().toString(), etxtPassword.getText().toString()));
}
protected void onCancelled() {
}
protected abstract void onConfirmed(String username, String password, boolean saveUsernamePassword);
protected abstract void onConfirmed(String username, String password);
}

View File

@ -25,7 +25,6 @@ import java.util.Set;
* supports swiping to mark as read.
*/
public class AllEpisodesFragment extends EpisodesListFragment {
public static final String TAG = "AllEpisodesFragment";
private static final String PREF_NAME = "PrefAllEpisodesFragment";
private static final String PREF_FILTER = "filter";

View File

@ -200,10 +200,10 @@ public class FeedSettingsFragment extends Fragment {
private void setupAuthentificationPreference() {
findPreference("authentication").setOnPreferenceClickListener(preference -> {
new AuthenticationDialog(getContext(),
R.string.authentication_label, true, false,
R.string.authentication_label, true,
feedPreferences.getUsername(), feedPreferences.getPassword()) {
@Override
protected void onConfirmed(String username, String password, boolean saveUsernamePassword) {
protected void onConfirmed(String username, String password) {
feedPreferences.setUsername(username);
feedPreferences.setPassword(password);
feed.savePreferences();

View File

@ -38,16 +38,6 @@ public class ItemPagerFragment extends Fragment {
private static final String ARG_FEEDITEMS = "feeditems";
private static final String ARG_FEEDITEM_POS = "feeditem_pos";
/**
* Creates a new instance of an ItemPagerFragment.
*
* @param feeditem The ID of the FeedItem that should be displayed.
* @return The ItemFragment instance
*/
public static ItemPagerFragment newInstance(long feeditem) {
return newInstance(new long[] { feeditem }, 0);
}
/**
* Creates a new instance of an ItemPagerFragment.
*

View File

@ -1,6 +1,5 @@
package de.danoeh.antennapod.fragment.gpodnet;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@ -28,7 +27,7 @@ public class GpodnetMainFragment extends Fragment {
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
ViewPager viewPager = root.findViewById(R.id.viewpager);
GpodnetPagerAdapter pagerAdapter = new GpodnetPagerAdapter(getChildFragmentManager(), getResources());
GpodnetPagerAdapter pagerAdapter = new GpodnetPagerAdapter(getChildFragmentManager());
viewPager.setAdapter(pagerAdapter);
// Give the TabLayout the ViewPager
@ -39,18 +38,13 @@ public class GpodnetMainFragment extends Fragment {
}
public class GpodnetPagerAdapter extends FragmentPagerAdapter {
private static final int NUM_PAGES = 2;
private static final int POS_TOPLIST = 0;
private static final int POS_TAGS = 1;
private static final int POS_SUGGESTIONS = 2;
final Resources resources;
public GpodnetPagerAdapter(FragmentManager fm, Resources resources) {
public GpodnetPagerAdapter(FragmentManager fm) {
super(fm);
this.resources = resources;
}
@Override

View File

@ -63,11 +63,11 @@ public class GpodderPreferencesFragment extends PreferenceFragmentCompat {
findPreference(PREF_GPODNET_SETLOGIN_INFORMATION)
.setOnPreferenceClickListener(preference -> {
AuthenticationDialog dialog = new AuthenticationDialog(activity,
R.string.pref_gpodnet_setlogin_information_title, false, false, GpodnetPreferences.getUsername(),
R.string.pref_gpodnet_setlogin_information_title, false, GpodnetPreferences.getUsername(),
null) {
@Override
protected void onConfirmed(String username, String password, boolean saveUsernamePassword) {
protected void onConfirmed(String username, String password) {
GpodnetPreferences.setPassword(password);
}
};

View File

@ -8,7 +8,6 @@ import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.PreferenceFragmentCompat;
import android.widget.ListView;
import android.widget.Toast;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.activity.PreferenceActivity;
@ -19,7 +18,6 @@ import org.apache.commons.lang3.ArrayUtils;
import java.util.List;
public class UserInterfacePreferencesFragment extends PreferenceFragmentCompat {
private static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

View File

@ -41,8 +41,7 @@ public class FeedItemMenuHandler {
* @param selectedItem The FeedItem for which the menu is supposed to be prepared
* @return Returns true if selectedItem is not null.
*/
public static boolean onPrepareMenu(Menu menu,
FeedItem selectedItem) {
public static boolean onPrepareMenu(Menu menu, FeedItem selectedItem) {
if (menu == null || selectedItem == null) {
return false;
}
@ -146,15 +145,13 @@ public class FeedItemMenuHandler {
}
/**
* The same method as onPrepareMenu(MenuInterface, FeedItem, boolean, QueueAccess), but lets the
* The same method as {@link #onPrepareMenu(Menu, FeedItem)}, but lets the
* caller also specify a list of menu items that should not be shown.
*
* @param excludeIds Menu item that should be excluded
* @return true if selectedItem is not null.
*/
public static boolean onPrepareMenu(Menu menu,
FeedItem selectedItem,
int... excludeIds) {
public static boolean onPrepareMenu(Menu menu, FeedItem selectedItem, int... excludeIds) {
if (menu == null || selectedItem == null ) {
return false;
}

View File

@ -6,8 +6,6 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import org.apache.commons.lang3.Validate;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.receiver.SPAReceiver;
@ -22,7 +20,6 @@ public class SPAUtil {
private SPAUtil() {
}
/**
* Sends an ACTION_SP_APPS_QUERY_FEEDS intent to all AntennaPod Single Purpose apps.
* The receiving single purpose apps will then send their feeds back to AntennaPod via an
@ -53,17 +50,4 @@ public class SPAUtil {
return false;
}
}
/**
* Resets all preferences created by this class. Should only be used for debug purposes.
*/
public static void resetSPAPreferences(Context c) {
if (BuildConfig.DEBUG) {
Validate.notNull(c);
SharedPreferences.Editor editor = PreferenceManager
.getDefaultSharedPreferences(c.getApplicationContext()).edit();
editor.putBoolean(PREF_HAS_QUERIED_SP_APPS, false);
editor.apply();
}
}
}

View File

@ -1,9 +0,0 @@
package de.danoeh.antennapod.view;
public interface OnSwipeGesture {
boolean onSwipeLeftToRight();
boolean onSwipeRightToLeft();
}

View File

@ -11,12 +11,10 @@ import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.joanzapata.iconify.widget.IconTextView;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.view.CircularProgressBar;
public class DownloadItemViewHolder extends RecyclerView.ViewHolder {
public final View secondaryActionButton;
public final ImageView secondaryActionIcon;
public final CircularProgressBar secondaryActionProgress;
public final IconTextView icon;
public final TextView title;
public final TextView type;
@ -29,7 +27,6 @@ public class DownloadItemViewHolder extends RecyclerView.ViewHolder {
type = itemView.findViewById(R.id.txtvType);
icon = itemView.findViewById(R.id.txtvIcon);
reason = itemView.findViewById(R.id.txtvReason);
secondaryActionProgress = itemView.findViewById(R.id.secondaryActionProgress);
secondaryActionButton = itemView.findViewById(R.id.secondaryActionButton);
secondaryActionIcon = itemView.findViewById(R.id.secondaryActionIcon);
title = itemView.findViewById(R.id.txtvTitle);

View File

@ -27,10 +27,4 @@
android:focusableInTouchMode="true"
android:cursorVisible="true"/>
<CheckBox
android:id="@+id/chkSaveUsernamePassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/save_username_password_label"/>
</LinearLayout>

View File

@ -3,11 +3,10 @@ package de.danoeh.antennapod.core;
import android.app.PendingIntent;
import android.content.Context;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.service.download.DownloadRequest;
/**
* Callbacks for the DownloadService of the core module
* Callbacks for the DownloadService of the core module.
*/
public interface DownloadServiceCallbacks {
@ -42,13 +41,6 @@ public interface DownloadServiceCallbacks {
*/
PendingIntent getReportNotificationContentIntent(Context context);
/**
* Called by the FeedSyncThread after a feed has been downloaded and parsed.
*
* @param feed The non-null feed that has been parsed.
*/
void onFeedParsed(Context context, Feed feed);
/**
* Returns true if the DownloadService should create a report that shows the number of failed
* downloads when the service shuts down.

View File

@ -26,9 +26,4 @@ public interface PlaybackServiceCallbacks {
* finishes.
*/
boolean useQueue();
/**
* Returns a drawable resource that is used for the notification of the playback service.
*/
int getNotificationIconResource(Context context);
}

View File

@ -59,18 +59,6 @@ public class QueueEvent {
return new QueueEvent(Action.MOVED, item, null, newPosition);
}
public boolean contains(long id) {
if(item != null) {
return item.getId() == id;
}
for(FeedItem item : items) {
if(item.getId() == id) {
return true;
}
}
return false;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)

View File

@ -224,14 +224,6 @@ public class Feed extends FeedFile implements ImageResource {
return feed;
}
/**
* Returns the number of FeedItems.
*
*/
public int getNumOfItems() {
return items.size();
}
/**
* Returns the item at the specified index.
*

View File

@ -221,16 +221,6 @@ public class FeedMedia extends FeedFile implements Playable {
((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PLAYING));
}
/**
* Reads playback preferences to determine whether this FeedMedia object is
* currently being played and the current player status is paused.
*/
public boolean isCurrentlyPaused() {
return isPlaying() &&
((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PAUSED));
}
public boolean hasAlmostEnded() {
int smartMarkAsPlayedSecs = UserPreferences.getSmartMarkAsPlayedSecs();
return this.position >= this.duration - smartMarkAsPlayedSecs * 1000;

View File

@ -2,16 +2,13 @@ package de.danoeh.antennapod.core.service.download.handler;
import android.content.Context;
import android.util.Log;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.service.download.DownloadRequest;
import de.danoeh.antennapod.core.service.download.DownloadStatus;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.storage.DownloadRequester;
import de.danoeh.antennapod.core.syndication.handler.FeedHandlerResult;
import java.util.List;
public class FeedSyncTask {
private static final String TAG = "FeedParserTask";
@ -46,8 +43,6 @@ public class FeedSyncTask {
Log.e(TAG, "Error trying to load next page", e);
}
}
ClientConfig.downloadServiceCallbacks.onFeedParsed(context, savedFeed);
return true;
}

View File

@ -160,12 +160,12 @@ public final class DBReader {
}
/**
* Loads the list of FeedItems for a certain Feed-object. This method should NOT be used if the FeedItems are not
* used. In order to get information ABOUT the list of FeedItems, consider using {@link #getFeedStatisticsList()} instead.
* Loads the list of FeedItems for a certain Feed-object.
* This method should NOT be used if the FeedItems are not used.
*
* @param feed The Feed whose items should be loaded
* @return A list with the FeedItems of the Feed. The Feed-attribute of the FeedItems will already be set correctly.
* The method does NOT change the items-attribute of the feed.
* The method does NOT change the items-attribute of the feed.
*/
public static List<FeedItem> getFeedItemList(final Feed feed) {
Log.d(TAG, "getFeedItemList() called with: " + "feed = [" + feed + "]");
@ -273,8 +273,7 @@ public final class DBReader {
* Loads the IDs of the FeedItems in the queue. This method should be preferred over
* {@link #getQueue()} if the FeedItems of the queue are not needed.
*
* @return A list of IDs sorted by the same order as the queue. The caller can wrap the returned
* list in a {@link de.danoeh.antennapod.core.util.QueueAccess} object for easier access to the queue's properties.
* @return A list of IDs sorted by the same order as the queue.
*/
public static LongList getQueueIDList() {
Log.d(TAG, "getQueueIDList() called");
@ -307,8 +306,7 @@ public final class DBReader {
* Loads a list of the FeedItems in the queue. If the FeedItems of the queue are not used directly, consider using
* {@link #getQueueIDList()} instead.
*
* @return A list of FeedItems sorted by the same order as the queue. The caller can wrap the returned
* list in a {@link de.danoeh.antennapod.core.util.QueueAccess} object for easier access to the queue's properties.
* @return A list of FeedItems sorted by the same order as the queue.
*/
@NonNull
public static List<FeedItem> getQueue() {
@ -545,34 +543,6 @@ public final class DBReader {
}
}
/**
* Loads the FeedItemStatistics objects of all Feeds in the database. This method should be preferred over
* {@link #getFeedItemList(Feed)} if only metadata about
* the FeedItems is needed.
*
* @return A list of FeedItemStatistics objects sorted alphabetically by their Feed's title.
*/
public static List<FeedItemStatistics> getFeedStatisticsList() {
Log.d(TAG, "getFeedStatisticsList() called");
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
Cursor cursor = null;
try {
cursor = adapter.getFeedStatisticsCursor();
List<FeedItemStatistics> result = new ArrayList<>(cursor.getCount());
while (cursor.moveToNext()) {
FeedItemStatistics fis = FeedItemStatistics.fromCursor(cursor);
result.add(fis);
}
return result;
} finally {
if (cursor != null) {
cursor.close();
}
adapter.close();
}
}
/**
* Loads a specific Feed from the database.
*

View File

@ -1,81 +0,0 @@
package de.danoeh.antennapod.core.storage;
import android.database.Cursor;
import java.util.Date;
/**
* Contains information about a feed's items.
*/
public class FeedItemStatistics {
private final long feedID;
private final int numberOfItems;
private final int numberOfNewItems;
private final int numberOfInProgressItems;
private final Date lastUpdate;
private static final Date UNKNOWN_DATE = new Date(0);
/**
* Creates new FeedItemStatistics object.
*
* @param feedID ID of the feed.
* @param numberOfItems Number of items that this feed has.
* @param numberOfNewItems Number of unread items this feed has.
* @param numberOfInProgressItems Number of items that the user has started listening to.
* @param lastUpdate pubDate of the latest episode. A lastUpdate value of 0 will be interpreted as DATE_UNKOWN if
* numberOfItems is 0.
*/
private FeedItemStatistics(long feedID, int numberOfItems, int numberOfNewItems, int numberOfInProgressItems, Date lastUpdate) {
this.feedID = feedID;
this.numberOfItems = numberOfItems;
this.numberOfNewItems = numberOfNewItems;
this.numberOfInProgressItems = numberOfInProgressItems;
if (numberOfItems > 0) {
this.lastUpdate = (lastUpdate != null) ? (Date) lastUpdate.clone() : null;
} else {
this.lastUpdate = UNKNOWN_DATE;
}
}
public static FeedItemStatistics fromCursor(Cursor cursor) {
return new FeedItemStatistics(
cursor.getLong(0),
cursor.getInt(1),
cursor.getInt(2),
cursor.getInt(4),
new Date(cursor.getLong(3)));
}
public long getFeedID() {
return feedID;
}
public int getNumberOfItems() {
return numberOfItems;
}
public int getNumberOfNewItems() {
return numberOfNewItems;
}
public int getNumberOfInProgressItems() {
return numberOfInProgressItems;
}
/**
* Returns the pubDate of the latest item in the feed. Users of this method
* should check if this value is unkown or not by calling lastUpdateKnown() first.
*/
public Date getLastUpdate() {
return (lastUpdate != null) ? (Date) lastUpdate.clone() : null;
}
/**
* Returns true if the lastUpdate value is known. The lastUpdate value is unkown if the
* feed has no items.
*/
public boolean lastUpdateKnown() {
return lastUpdate != UNKNOWN_DATE;
}
}

View File

@ -36,16 +36,7 @@ public class AtomText extends SyndElement {
}
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getType() {
return type;
}
}

View File

@ -37,21 +37,6 @@ public class SyndTypeUtils {
}
}
/**
* Should be used if mime-type of enclosure tag is not supported. This
* method will check if the mime-type of the file extension is supported. If
* the type is not supported, this method will return null.
*/
public static String getValidMimeTypeFromUrl(String url) {
String type = getMimeTypeFromUrl(url);
if (enclosureTypeValid(type)) {
return type;
} else {
return null;
}
}
/**
* Should be used if mime-type of enclosure tag is not supported. This
* method will return the mime-type of the file extension.

View File

@ -8,16 +8,4 @@ public class InvalidFeedException extends Exception {
public InvalidFeedException() {
}
public InvalidFeedException(String message) {
super(message);
}
public InvalidFeedException(Throwable cause) {
super(cause);
}
public InvalidFeedException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -1,29 +0,0 @@
package de.danoeh.antennapod.core.util;
import java.util.Iterator;
import java.util.List;
import de.danoeh.antennapod.core.feed.FeedItem;
/**
* Provides methods for accessing the queue. It is possible to load only a part of the information about the queue that
* is stored in the database (e.g. sometimes the user just has to test if a specific item is contained in the List.
* QueueAccess provides an interface for accessing the queue without having to care about the type of the queue
* representation.
*/
public abstract class QueueAccess {
/**
* Returns true if the item is in the queue, false otherwise.
*/
public abstract boolean contains(long id);
/**
* Removes the item from the queue.
*
* @return true if the queue was modified by this operation.
*/
public abstract boolean remove(long id);
private QueueAccess() {
}
}

View File

@ -1,18 +0,0 @@
package de.danoeh.antennapod.core.util.exception;
import de.danoeh.antennapod.core.feed.FeedMedia;
public class MediaFileNotFoundException extends Exception {
private static final long serialVersionUID = 1L;
private final FeedMedia media;
public MediaFileNotFoundException(String msg, FeedMedia media) {
super(msg);
this.media = media;
}
public FeedMedia getMedia() {
return media;
}
}

View File

@ -3,18 +3,7 @@ package de.danoeh.antennapod.core.util.id3reader;
public class ID3ReaderException extends Exception {
private static final long serialVersionUID = 1L;
public ID3ReaderException() {
}
public ID3ReaderException(String message) {
super(message);
}
public ID3ReaderException(Throwable message) {
super(message);
}
public ID3ReaderException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -382,12 +382,6 @@ public class PlaybackController {
public void onPlaybackEnd() {}
public void repeatHandleStatus() {
if (status != null && playbackService != null) {
handleStatus();
}
}
/**
* Is called whenever the PlaybackService changes its status. This method
* should be used to update the GUI or start/cancel background threads.

View File

@ -120,10 +120,6 @@ public class ItemEnqueuePositionCalculatorTest {
return ItemEnqueuePositionCalculatorTest.getCurrentlyPlaying(idCurrentlyPlaying);
}
private static Playable externalMedia() {
return new ExternalMedia("http://example.com/episode.mp3", MediaType.AUDIO);
}
private static final long ID_CURRENTLY_PLAYING_NULL = -1L;
private static final long ID_CURRENTLY_PLAYING_NOT_FEEDMEDIA = -9999L;

View File

@ -13,61 +13,49 @@ import de.danoeh.antennapod.core.feed.FeedItem;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class FeedItemUtilTest {
private static final String FEED_LINK = "http://example.com";
private static final String ITEM_LINK = "http://example.com/feedItem1";
private final String msg;
private final String feedLink;
private final String itemLink;
private final String expected;
@RunWith(Parameterized.class)
public static class LinkWithFallbackTest {
private static final String FEED_LINK = "http://example.com";
private static final String ITEM_LINK = "http://example.com/feedItem1";
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{ "average", FEED_LINK, ITEM_LINK, ITEM_LINK },
{ "null item link - fallback to feed", FEED_LINK, null, FEED_LINK},
{ "empty item link - same as null", FEED_LINK, "", FEED_LINK},
{ "blank item link - same as null", FEED_LINK, " ", FEED_LINK},
{ "fallback, but feed link is null too", null, null, null },
{ "fallback - but empty feed link - same as null", "", null, null},
{ "fallback - but blank feed link - same as null", " ", null, null}
});
}
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{ "average",
FEED_LINK, ITEM_LINK, ITEM_LINK },
{ "null item link - fallback to feed",
FEED_LINK, null, FEED_LINK},
{ "empty item link - same as null",
FEED_LINK, "", FEED_LINK},
{ "blank item link - same as null",
FEED_LINK, " ", FEED_LINK},
{ "fallback, but feed link is null too",
null, null, null },
{ "fallback - but empty feed link - same as null",
"", null, null},
{ "fallback - but blank feed link - same as null",
" ", null, null}
});
}
public FeedItemUtilTest(String msg, String feedLink, String itemLink, String expected) {
this.msg = msg;
this.feedLink = feedLink;
this.itemLink = itemLink;
this.expected = expected;
}
private final String msg;
private final String feedLink;
private final String itemLink;
private final String expected;
@Test
public void testLinkWithFallback() {
String actual = FeedItemUtil.getLinkWithFallback(createFeedItem(feedLink, itemLink));
assertEquals(msg, expected, actual);
}
public LinkWithFallbackTest(String msg, String feedLink, String itemLink, String expected) {
this.msg = msg;
this.feedLink = feedLink;
this.itemLink = itemLink;
this.expected = expected;
}
@Test
public void testLinkWithFallback() {
String actual = FeedItemUtil.getLinkWithFallback(createFeedItem(feedLink, itemLink));
assertEquals(msg, expected, actual);
}
private static FeedItem createFeedItem(String feedLink, String itemLink) {
Feed feed = new Feed();
feed.setLink(feedLink);
FeedItem feedItem = new FeedItem();
feedItem.setLink(itemLink);
feedItem.setFeed(feed);
feed.setItems(Arrays.asList(feedItem));
return feedItem;
}
private static FeedItem createFeedItem(String feedLink, String itemLink) {
Feed feed = new Feed();
feed.setLink(feedLink);
FeedItem feedItem = new FeedItem();
feedItem.setLink(itemLink);
feedItem.setFeed(feed);
feed.setItems(Arrays.asList(feedItem));
return feedItem;
}
}