diff --git a/res/values/strings.xml b/res/values/strings.xml index 6f11049c4..631b721b5 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -252,6 +252,7 @@ CATEGORIES TOP PODCASTS + SUGGESTIONS Search gpodder.net Login Welcome to the gpodder.net login process. First, type in your login information: diff --git a/src/de/danoeh/antennapod/activity/gpoddernet/GpodnetMainActivity.java b/src/de/danoeh/antennapod/activity/gpoddernet/GpodnetMainActivity.java index d85ae4202..17b46ae9d 100644 --- a/src/de/danoeh/antennapod/activity/gpoddernet/GpodnetMainActivity.java +++ b/src/de/danoeh/antennapod/activity/gpoddernet/GpodnetMainActivity.java @@ -7,7 +7,9 @@ import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.ViewPager; import de.danoeh.antennapod.R; import de.danoeh.antennapod.fragment.gpodnet.PodcastTopListFragment; +import de.danoeh.antennapod.fragment.gpodnet.SuggestionListFragment; import de.danoeh.antennapod.fragment.gpodnet.TagListFragment; +import de.danoeh.antennapod.preferences.GpodnetPreferences; /** * Created by daniel on 22.08.13. @@ -17,6 +19,7 @@ public class GpodnetMainActivity extends GpodnetActivity { private static final int POS_TAGS = 0; private static final int POS_TOPLIST = 1; + private static final int POS_SUGGESTIONS = 2; @Override protected void onCreate(Bundle savedInstanceState) { @@ -29,10 +32,13 @@ public class GpodnetMainActivity extends GpodnetActivity { private class PagerAdapter extends FragmentStatePagerAdapter { - private static final int NUM_PAGES = 2; + private static final int NUM_PAGES_LOGGED_OUT = 2; + private static final int NUM_PAGES_LOGGED_IN = 3; + private final int NUM_PAGES; public PagerAdapter(FragmentManager fm) { super(fm); + NUM_PAGES = NUM_PAGES_LOGGED_OUT; } @Override @@ -42,6 +48,8 @@ public class GpodnetMainActivity extends GpodnetActivity { return new TagListFragment(); case POS_TOPLIST: return new PodcastTopListFragment(); + case POS_SUGGESTIONS: + return new SuggestionListFragment(); default: return null; } @@ -54,6 +62,8 @@ public class GpodnetMainActivity extends GpodnetActivity { return getString(R.string.gpodnet_taglist_header); case POS_TOPLIST: return getString(R.string.gpodnet_toplist_header); + case POS_SUGGESTIONS: + return getString(R.string.gpodnet_suggestions_header); default: return super.getPageTitle(position); } diff --git a/src/de/danoeh/antennapod/fragment/gpodnet/SuggestionListFragment.java b/src/de/danoeh/antennapod/fragment/gpodnet/SuggestionListFragment.java new file mode 100644 index 000000000..45fe25580 --- /dev/null +++ b/src/de/danoeh/antennapod/fragment/gpodnet/SuggestionListFragment.java @@ -0,0 +1,26 @@ +package de.danoeh.antennapod.fragment.gpodnet; + +import de.danoeh.antennapod.gpoddernet.GpodnetService; +import de.danoeh.antennapod.gpoddernet.GpodnetServiceException; +import de.danoeh.antennapod.gpoddernet.model.GpodnetPodcast; +import de.danoeh.antennapod.preferences.GpodnetPreferences; + +import java.util.ArrayList; +import java.util.List; + +/** + * Displays suggestions from gpodder.net + */ +public class SuggestionListFragment extends PodcastListFragment { + private static final int SUGGESTIONS_COUNT = 50; + + @Override + protected List loadPodcastData(GpodnetService service) throws GpodnetServiceException { + if (GpodnetPreferences.loggedIn()) { + service.authenticate(GpodnetPreferences.getUsername(), GpodnetPreferences.getPassword()); + return service.getSuggestions(SUGGESTIONS_COUNT); + } else { + return new ArrayList(); + } + } +}