Merge branch 'revert-revert-681-feature/downloader-if-modified-since' into feature/downloader-if-modified-since
This commit is contained in:
commit
1020c04b9e
|
@ -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<GpodnetTag> {
|
||||||
|
|
||||||
|
public TagListAdapter(Context context, int resource, List<GpodnetTag> 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,11 +24,11 @@ public class TagFragment extends PodcastListFragment {
|
||||||
|
|
||||||
private GpodnetTag tag;
|
private GpodnetTag tag;
|
||||||
|
|
||||||
public static TagFragment newInstance(String tagName) {
|
public static TagFragment newInstance(GpodnetTag tag) {
|
||||||
Validate.notNull(tagName);
|
Validate.notNull(tag);
|
||||||
TagFragment fragment = new TagFragment();
|
TagFragment fragment = new TagFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString("tag", tagName);
|
args.putParcelable("tag", tag);
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
@ -38,14 +38,14 @@ public class TagFragment extends PodcastListFragment {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
Validate.isTrue(args != null && args.getString("tag") != null, "args invalid");
|
Validate.isTrue(args != null && args.getParcelable("tag") != null, "args invalid");
|
||||||
tag = new GpodnetTag(args.getString("tag"));
|
tag = args.getParcelable("tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
((MainActivity) getActivity()).getMainActivtyActionBar().setTitle(tag.getName());
|
((MainActivity) getActivity()).getMainActivtyActionBar().setTitle(tag.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,14 +10,13 @@ import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.activity.MainActivity;
|
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.GpodnetService;
|
||||||
import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException;
|
import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException;
|
||||||
import de.danoeh.antennapod.core.gpoddernet.model.GpodnetTag;
|
import de.danoeh.antennapod.core.gpoddernet.model.GpodnetTag;
|
||||||
|
@ -67,15 +66,21 @@ public class TagListFragment extends ListFragment {
|
||||||
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
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();
|
MainActivity activity = (MainActivity) getActivity();
|
||||||
activity.loadChildFragment(TagFragment.newInstance(selectedTag));
|
activity.loadChildFragment(TagFragment.newInstance(tag));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
startLoadTask();
|
startLoadTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
((MainActivity) getActivity()).getMainActivtyActionBar().setTitle(R.string.add_feed_label);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
@ -121,11 +126,7 @@ public class TagListFragment extends ListFragment {
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
if (gpodnetTags != null) {
|
if (gpodnetTags != null) {
|
||||||
List<String> tagNames = new ArrayList<String>();
|
setListAdapter(new TagListAdapter(context, android.R.layout.simple_list_item_1, gpodnetTags));
|
||||||
for (GpodnetTag tag : gpodnetTags) {
|
|
||||||
tagNames.add(tag.getName());
|
|
||||||
}
|
|
||||||
setListAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, tagNames));
|
|
||||||
} else if (exception != null) {
|
} else if (exception != null) {
|
||||||
TextView txtvError = new TextView(getActivity());
|
TextView txtvError = new TextView(getActivity());
|
||||||
txtvError.setText(exception.getMessage());
|
txtvError.setText(exception.getMessage());
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -79,15 +79,4 @@
|
||||||
tools:text="http://www.example.com/feed"
|
tools:text="http://www.example.com/feed"
|
||||||
tools:background="@android:color/holo_green_dark"/>
|
tools:background="@android:color/holo_green_dark"/>
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:inputType="textPersonName"
|
|
||||||
android:text="Name"
|
|
||||||
android:ems="10"
|
|
||||||
android:id="@+id/editText"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_marginTop="231dp"/>
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
tools:background="@android:color/darker_gray">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtvTitle"
|
||||||
|
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/listitem_threeline_horizontalpadding"
|
||||||
|
android:layout_marginTop="@dimen/listitem_threeline_verticalpadding"
|
||||||
|
android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding"
|
||||||
|
android:lines="1"
|
||||||
|
tools:text="Tag Title"
|
||||||
|
tools:background="@android:color/holo_green_dark" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtvUsage"
|
||||||
|
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_marginRight="@dimen/listitem_threeline_horizontalpadding"
|
||||||
|
android:layout_marginTop="@dimen/listitem_threeline_verticalpadding"
|
||||||
|
android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding"
|
||||||
|
tools:text="301"
|
||||||
|
tools:background="@android:color/holo_green_dark"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -88,14 +88,13 @@
|
||||||
android:key="prefAutoUpdateIntervall"
|
android:key="prefAutoUpdateIntervall"
|
||||||
android:summary="@string/pref_autoUpdateIntervall_sum"
|
android:summary="@string/pref_autoUpdateIntervall_sum"
|
||||||
android:title="@string/pref_autoUpdateIntervall_title"/>
|
android:title="@string/pref_autoUpdateIntervall_title"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:key="prefMobileUpdate"
|
android:key="prefMobileUpdate"
|
||||||
android:summary="@string/pref_mobileUpdate_sum"
|
android:summary="@string/pref_mobileUpdate_sum"
|
||||||
android:title="@string/pref_mobileUpdate_title"/>
|
android:title="@string/pref_mobileUpdate_title"/>
|
||||||
<EditTextPreference
|
<de.danoeh.antennapod.preferences.CustomEditTextPreference
|
||||||
android:defaultValue="6"
|
android:defaultValue="6"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:key="prefParallelDownloads"
|
android:key="prefParallelDownloads"
|
||||||
|
|
|
@ -135,8 +135,8 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
|
||||||
if (other.media != null) {
|
if (other.media != null) {
|
||||||
if (media == null) {
|
if (media == null) {
|
||||||
setMedia(other.media);
|
setMedia(other.media);
|
||||||
} else if (media.compareWithOther(other)) {
|
} else if (media.compareWithOther(other.media)) {
|
||||||
media.updateFromOther(other);
|
media.updateFromOther(other.media);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (other.paymentLink != null) {
|
if (other.paymentLink != null) {
|
||||||
|
|
|
@ -172,9 +172,10 @@ public class GpodnetService {
|
||||||
jsonTagList.length());
|
jsonTagList.length());
|
||||||
for (int i = 0; i < jsonTagList.length(); i++) {
|
for (int i = 0; i < jsonTagList.length(); i++) {
|
||||||
JSONObject jObj = jsonTagList.getJSONObject(i);
|
JSONObject jObj = jsonTagList.getJSONObject(i);
|
||||||
String name = jObj.getString("tag");
|
String title = jObj.getString("title");
|
||||||
|
String tag = jObj.getString("tag");
|
||||||
int usage = jObj.getInt("usage");
|
int usage = jObj.getInt("usage");
|
||||||
tagList.add(new GpodnetTag(name, usage));
|
tagList.add(new GpodnetTag(title, tag, usage));
|
||||||
}
|
}
|
||||||
return tagList;
|
return tagList;
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -194,7 +195,7 @@ public class GpodnetService {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
URL url = new URI(BASE_SCHEME, BASE_HOST, String.format(
|
||||||
"/api/2/tag/%s/%d.json", tag.getName(), count), null).toURL();
|
"/api/2/tag/%s/%d.json", tag.getTag(), count), null).toURL();
|
||||||
Request.Builder request = new Request.Builder().url(url);
|
Request.Builder request = new Request.Builder().url(url);
|
||||||
String response = executeRequest(request);
|
String response = executeRequest(request);
|
||||||
|
|
||||||
|
|
|
@ -1,46 +1,60 @@
|
||||||
package de.danoeh.antennapod.core.gpoddernet.model;
|
package de.danoeh.antennapod.core.gpoddernet.model;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
import java.util.Comparator;
|
public class GpodnetTag implements Parcelable {
|
||||||
|
|
||||||
public class GpodnetTag {
|
private final String title;
|
||||||
|
private final String tag;
|
||||||
|
private final int usage;
|
||||||
|
|
||||||
private String name;
|
public GpodnetTag(String title, String tag, int usage) {
|
||||||
private int usage;
|
Validate.notNull(title);
|
||||||
|
Validate.notNull(tag);
|
||||||
|
|
||||||
public GpodnetTag(String name, int usage) {
|
this.title = title;
|
||||||
Validate.notNull(name);
|
this.tag = tag;
|
||||||
|
|
||||||
this.name = name;
|
|
||||||
this.usage = usage;
|
this.usage = usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GpodnetTag(String name) {
|
public static GpodnetTag createFromParcel(Parcel in) {
|
||||||
super();
|
final String title = in.readString();
|
||||||
this.name = name;
|
final String tag = in.readString();
|
||||||
|
final int usage = in.readInt();
|
||||||
|
return new GpodnetTag(title, tag, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "GpodnetTag [name=" + name + ", usage=" + usage + "]";
|
return "GpodnetTag [title="+title+", tag=" + tag + ", usage=" + usage + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getTitle() {
|
||||||
return name;
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTag() {
|
||||||
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUsage() {
|
public int getUsage() {
|
||||||
return usage;
|
return usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UsageComparator implements Comparator<GpodnetTag> {
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
@Override
|
return 0;
|
||||||
public int compare(GpodnetTag o1, GpodnetTag o2) {
|
|
||||||
return o1.usage - o2.usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeString(title);
|
||||||
|
dest.writeString(tag);
|
||||||
|
dest.writeInt(usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue