Permalink
Browse files

Corrected a few issues with the atom feed examples.

  • Loading branch information...
1 parent 00fe672 commit 37779d56d220c270a46aec06ff16cfe5414e7ff6 @royclarkson royclarkson committed Sep 9, 2011
@@ -15,7 +15,7 @@
<properties>
<android-platform>7</android-platform>
<android-emulator>7</android-emulator>
- <maven-android-plugin-version>2.9.0-beta-5</maven-android-plugin-version>
+ <maven-android-plugin-version>2.8.4</maven-android-plugin-version>
<maven-compiler-plugin-version>2.3.2</maven-compiler-plugin-version>
<maven-eclipse-plugin-version>2.8</maven-eclipse-plugin-version>
<android-version>2.1_r1</android-version>
@@ -18,7 +18,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.feed.AtomFeedHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
@@ -113,11 +112,8 @@ protected Feed doInBackground(Void... params) {
// Configure the ATOM message converter
AtomFeedHttpMessageConverter converter = new AtomFeedHttpMessageConverter();
- List<MediaType> mediaTypes = new ArrayList<MediaType>();
- mediaTypes.add(MediaType.APPLICATION_XML);
- converter.setSupportedMediaTypes(mediaTypes);
- // Add the ATOM message converter to the RestTemplate instance
+ // Add the ATOM message converter to the RestTemplate instance, since it is not automatically available
List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
messageConverters.add(converter);
restTemplate.setMessageConverters(messageConverters);
@@ -22,6 +22,7 @@
import android.widget.BaseAdapter;
import android.widget.TextView;
+import com.google.code.rome.android.repackaged.com.sun.syndication.feed.atom.Content;
import com.google.code.rome.android.repackaged.com.sun.syndication.feed.atom.Entry;
import com.google.code.rome.android.repackaged.com.sun.syndication.feed.atom.Feed;
@@ -64,8 +65,11 @@ public View getView(int position, View convertView, ViewGroup parent) {
t = (TextView) convertView.findViewById(R.id.synd_feed_date);
t.setText(entry.getPublished().toString());
- t = (TextView) convertView.findViewById(R.id.synd_feed_description);
- t.setText(entry.getSummary().getValue());
+ Content summary = entry.getSummary();
+ if (summary != null) {
+ t = (TextView) convertView.findViewById(R.id.synd_feed_description);
+ t.setText(summary.getValue());
+ }
}
return convertView;
@@ -15,12 +15,6 @@
*/
package org.springframework.android.reader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.feed.SyndFeedHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import android.content.Intent;
@@ -111,21 +105,11 @@ protected SyndFeed doInBackground(Void... params) {
// Create a new RestTemplate instance
RestTemplate restTemplate = new RestTemplate();
- // Configure the SyndFeed message converter.
- SyndFeedHttpMessageConverter converter = new SyndFeedHttpMessageConverter();
- List<MediaType> mediaTypes = new ArrayList<MediaType>();
- mediaTypes.add(MediaType.APPLICATION_XML);
- converter.setSupportedMediaTypes(mediaTypes);
-
- // Add the SyndFeed message converter to the RestTemplate instance
- List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
- messageConverters.add(converter);
- restTemplate.setMessageConverters(messageConverters);
-
// The URL for making the request
final String url = getString(R.string.atom_feed_url);
- // Initiate the request and return the results
+ // Initiate the request and return the results. The SyndFeedHttpMessageConverter is automatically
+ // available to a restTemplate instance
return restTemplate.getForObject(url, SyndFeed.class);
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
@@ -22,6 +22,7 @@
import android.widget.BaseAdapter;
import android.widget.TextView;
+import com.google.code.rome.android.repackaged.com.sun.syndication.feed.synd.SyndContent;
import com.google.code.rome.android.repackaged.com.sun.syndication.feed.synd.SyndEntry;
import com.google.code.rome.android.repackaged.com.sun.syndication.feed.synd.SyndFeed;
@@ -65,8 +66,11 @@ public View getView(int position, View convertView, ViewGroup parent) {
t = (TextView) convertView.findViewById(R.id.synd_feed_date);
t.setText(syndEntry.getPublishedDate().toString());
- t = (TextView) convertView.findViewById(R.id.synd_feed_description);
- t.setText(syndEntry.getDescription().getValue());
+ SyndContent description = syndEntry.getDescription();
+ if (description != null) {
+ t = (TextView) convertView.findViewById(R.id.synd_feed_description);
+ t.setText(description.getValue());
+ }
}
return convertView;

0 comments on commit 37779d5

Please sign in to comment.