Added suggestions list

Turned off at the moment
This commit is contained in:
daniel oeh 2013-09-01 16:27:01 +02:00
parent d45b0e2ea9
commit 730ba3cc26
3 changed files with 38 additions and 1 deletions

View File

@ -252,6 +252,7 @@
<!-- gpodder.net -->
<string name="gpodnet_taglist_header">CATEGORIES</string>
<string name="gpodnet_toplist_header">TOP PODCASTS</string>
<string name="gpodnet_suggestions_header">SUGGESTIONS</string>
<string name="gpodnet_search_hint">Search gpodder.net</string>
<string name="gpodnetauth_login_title">Login</string>
<string name="gpodnetauth_login_descr">Welcome to the gpodder.net login process. First, type in your login information:</string>

View File

@ -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);
}

View File

@ -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<GpodnetPodcast> loadPodcastData(GpodnetService service) throws GpodnetServiceException {
if (GpodnetPreferences.loggedIn()) {
service.authenticate(GpodnetPreferences.getUsername(), GpodnetPreferences.getPassword());
return service.getSuggestions(SUGGESTIONS_COUNT);
} else {
return new ArrayList<GpodnetPodcast>();
}
}
}