diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/TagListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/TagListAdapter.java new file mode 100644 index 000000000..b4eadefb5 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/TagListAdapter.java @@ -0,0 +1,54 @@ +package de.danoeh.antennapod.adapter.gpodnet; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +import java.util.List; + +import de.danoeh.antennapod.R; +import de.danoeh.antennapod.core.gpoddernet.model.GpodnetTag; + +/** + * Adapter for displaying a list of GPodnetPodcast-Objects. + */ +public class TagListAdapter extends ArrayAdapter { + + public TagListAdapter(Context context, int resource, List objects) { + super(context, resource, objects); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + Holder holder; + + GpodnetTag tag = getItem(position); + + // Inflate Layout + if (convertView == null) { + holder = new Holder(); + LayoutInflater inflater = (LayoutInflater) getContext() + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + convertView = inflater.inflate(R.layout.gpodnet_tag_listitem, parent, false); + holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); + holder.usage = (TextView) convertView.findViewById(R.id.txtvUsage); + convertView.setTag(holder); + } else { + holder = (Holder) convertView.getTag(); + } + + holder.title.setText(tag.getTitle()); + holder.usage.setText(String.valueOf(tag.getUsage())); + + return convertView; + } + + static class Holder { + TextView title; + TextView usage; + } +} diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java index c8cdbcfed..e2450f03d 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java @@ -24,11 +24,11 @@ public class TagFragment extends PodcastListFragment { private GpodnetTag tag; - public static TagFragment newInstance(String tagName) { - Validate.notNull(tagName); + public static TagFragment newInstance(GpodnetTag tag) { + Validate.notNull(tag); TagFragment fragment = new TagFragment(); Bundle args = new Bundle(); - args.putString("tag", tagName); + args.putParcelable("tag", tag); fragment.setArguments(args); return fragment; } @@ -38,14 +38,14 @@ public class TagFragment extends PodcastListFragment { super.onCreate(savedInstanceState); Bundle args = getArguments(); - Validate.isTrue(args != null && args.getString("tag") != null, "args invalid"); - tag = new GpodnetTag(args.getString("tag")); + Validate.isTrue(args != null && args.getParcelable("tag") != null, "args invalid"); + tag = args.getParcelable("tag"); } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - ((MainActivity) getActivity()).getMainActivtyActionBar().setTitle(tag.getName()); + ((MainActivity) getActivity()).getMainActivtyActionBar().setTitle(tag.getTitle()); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java index 24e0e4caa..cc87407b4 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java @@ -10,14 +10,13 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.View; import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.TextView; -import java.util.ArrayList; import java.util.List; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; +import de.danoeh.antennapod.adapter.gpodnet.TagListAdapter; import de.danoeh.antennapod.core.gpoddernet.GpodnetService; import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetTag; @@ -67,15 +66,21 @@ public class TagListFragment extends ListFragment { getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - String selectedTag = (String) getListAdapter().getItem(position); + GpodnetTag tag = (GpodnetTag) getListAdapter().getItem(position); MainActivity activity = (MainActivity) getActivity(); - activity.loadChildFragment(TagFragment.newInstance(selectedTag)); + activity.loadChildFragment(TagFragment.newInstance(tag)); } }); startLoadTask(); } + @Override + public void onResume() { + super.onResume(); + ((MainActivity) getActivity()).getMainActivtyActionBar().setTitle(R.string.add_feed_label); + } + @Override public void onDestroyView() { super.onDestroyView(); @@ -121,11 +126,7 @@ public class TagListFragment extends ListFragment { final Context context = getActivity(); if (context != null) { if (gpodnetTags != null) { - List tagNames = new ArrayList(); - for (GpodnetTag tag : gpodnetTags) { - tagNames.add(tag.getName()); - } - setListAdapter(new ArrayAdapter(context, android.R.layout.simple_list_item_1, tagNames)); + setListAdapter(new TagListAdapter(context, android.R.layout.simple_list_item_1, gpodnetTags)); } else if (exception != null) { TextView txtvError = new TextView(getActivity()); txtvError.setText(exception.getMessage()); diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/CustomEditTextPreference.java b/app/src/main/java/de/danoeh/antennapod/preferences/CustomEditTextPreference.java new file mode 100644 index 000000000..898a56004 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/preferences/CustomEditTextPreference.java @@ -0,0 +1,33 @@ +package de.danoeh.antennapod.preferences; + +import android.app.AlertDialog; +import android.content.Context; +import android.os.Build; +import android.preference.EditTextPreference; +import android.util.AttributeSet; + +import de.danoeh.antennapod.R; + +public class CustomEditTextPreference extends EditTextPreference { + + public CustomEditTextPreference(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public CustomEditTextPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public CustomEditTextPreference(Context context) { + super(context); + } + + @Override + protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + builder.setInverseBackgroundForced(true); + getEditText().setTextColor(getContext().getResources().getColor(R.color.black)); + } + } + +} diff --git a/app/src/main/res/layout/gpodnet_podcast_listitem.xml b/app/src/main/res/layout/gpodnet_podcast_listitem.xml index 8890f1b77..84c6c280e 100644 --- a/app/src/main/res/layout/gpodnet_podcast_listitem.xml +++ b/app/src/main/res/layout/gpodnet_podcast_listitem.xml @@ -79,15 +79,4 @@ tools:text="http://www.example.com/feed" tools:background="@android:color/holo_green_dark"/> - diff --git a/app/src/main/res/layout/gpodnet_tag_listitem.xml b/app/src/main/res/layout/gpodnet_tag_listitem.xml new file mode 100644 index 000000000..9e545e59d --- /dev/null +++ b/app/src/main/res/layout/gpodnet_tag_listitem.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 9da2d75e6..6d14349d5 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -88,14 +88,13 @@ android:key="prefAutoUpdateIntervall" android:summary="@string/pref_autoUpdateIntervall_sum" android:title="@string/pref_autoUpdateIntervall_title"/> - - { - - @Override - public int compare(GpodnetTag o1, GpodnetTag o2) { - return o1.usage - o2.usage; - } - + @Override + public int describeContents() { + return 0; } + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(title); + dest.writeString(tag); + dest.writeInt(usage); + } + + }