Updated references, deleted GreenDroid lib from project

This commit is contained in:
Daniel Oeh 2012-04-10 15:59:23 +02:00
parent d0cb7c7f36
commit b1d9a536e0
6 changed files with 69 additions and 34 deletions

3
lint.xml Normal file
View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>

20
proguard-project.txt Normal file
View File

@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -8,5 +8,5 @@
# project structure. # project structure.
# Project target. # Project target.
target=android-10 target=android-14
android.library.reference.1=libs/GreenDroid/GreenDroid android.library.reference.1=/home/daniel/src/android/actionbarsherlock/library/

View File

@ -6,22 +6,20 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.view.View; import android.view.View;
import de.podfetcher.R; import de.podfetcher.R;
import de.podfetcher.feed.FeedManager; import de.podfetcher.feed.Feed;
import de.podfetcher.storage.DownloadRequester;
/** Activity for adding/editing a Feed */ /** Activity for adding/editing a Feed */
public class AddFeedActivity extends Activity { public class AddFeedActivity extends Activity {
private EditText etxtFeedurl; private EditText etxtFeedurl;
private Button butConfirm; private Button butConfirm;
private FeedManager manager;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.addfeed); setContentView(R.layout.addfeed);
manager = FeedManager.getInstance();
etxtFeedurl = (EditText) findViewById(R.id.etxtFeedurl); etxtFeedurl = (EditText) findViewById(R.id.etxtFeedurl);
butConfirm = (Button) findViewById(R.id.butConfirm); butConfirm = (Button) findViewById(R.id.butConfirm);
@ -38,7 +36,9 @@ public class AddFeedActivity extends Activity {
private void addNewFeed() { private void addNewFeed() {
String url = etxtFeedurl.getText().toString(); String url = etxtFeedurl.getText().toString();
manager.addFeed(this, url); Feed feed = new Feed(url);
DownloadRequester req = DownloadRequester.getInstance();
req.downloadFeed(this, feed);
} }

View File

@ -37,25 +37,15 @@ public class FeedManager {
return singleton; return singleton;
} }
/** Add and Download a new Feed */ private void addNewFeed(Context context, Feed feed) {
public void addFeed(Context context, String url) { feeds.add(feed);
// TODO Check if URL is correct feed.setId(setFeed(context, feed));
PodDBAdapter adapter = new PodDBAdapter(context); for(FeedItem item : feed.getItems()) {
Feed feed = new Feed(url); setFeedItem(context, item);
feed.download_url = url;
feed.id = adapter.setFeed(feed);
// Add Feed to Feedlist if not available
Feed foundFeed = getFeed(feed.id);
if(foundFeed == null) {
feeds.add(feed);
}else {
feed = foundFeed;
} }
DownloadRequester req = DownloadRequester.getInstance();
req.downloadFeed(context, feed);
} }
/** Adds a new Feeditem if its not in the list */ /** Adds a new Feeditem if its not in the list */
public void addFeedItem(Context context, FeedItem item) { public void addFeedItem(Context context, FeedItem item) {
PodDBAdapter adapter = new PodDBAdapter(context); PodDBAdapter adapter = new PodDBAdapter(context);
@ -74,6 +64,30 @@ public class FeedManager {
} }
} }
public void updateFeed(Context context, Feed newFeed) {
// Look up feed in the feedslist
Feed savedFeed = searchFeedByLink(newFeed.getLink());
if(savedFeed == null) {
// Add a new Feed
addNewFeed(context, newFeed);
}else {
// Look for new or updated Items
for(FeedItem item : newFeed.getItems()) {
FeedItem oldItem = searchFeedItemByLink(savedFeed, item.getLink());
if(oldItem != null) {
FeedItem newItem = searchFeedItemByLink(newFeed, item.getLink());
if(newItem != null) {
newItem.setRead(oldItem.isRead());
}
}
}
newFeed.setId(savedFeed.getId());
savedFeed = newFeed;
setFeed(context, newFeed);
}
}
/** Get a Feed by its link */ /** Get a Feed by its link */
private Feed searchFeedByLink(String link) { private Feed searchFeedByLink(String link) {
for(Feed feed : feeds) { for(Feed feed : feeds) {
@ -95,9 +109,14 @@ public class FeedManager {
} }
/** Updates Information of an existing Feed */ /** Updates Information of an existing Feed */
public void setFeed(Context context, Feed feed) { public long setFeed(Context context, Feed feed) {
PodDBAdapter adapter = new PodDBAdapter(context); PodDBAdapter adapter = new PodDBAdapter(context);
adapter.setFeed(feed); return adapter.setFeed(feed);
}
public long setFeedItem(Context context, FeedItem item) {
PodDBAdapter adapter = new PodDBAdapter(context);
return adapter.setFeedItem(item);
} }
/** Get a Feed by its id */ /** Get a Feed by its id */

View File

@ -106,8 +106,6 @@ public class DownloadService extends Service {
requester.removeFeed(feed); requester.removeFeed(feed);
// Get Feed Information // Get Feed Information
feed.setFile_url((new File(requester.getFeedfilePath(context), requester.getFeedfileName(feed.getId()))).toString()); feed.setFile_url((new File(requester.getFeedfilePath(context), requester.getFeedfileName(feed.getId()))).toString());
// Update Information in Database
manager.setFeed(context, feed);
// Download Feed Image if provided // Download Feed Image if provided
if(feed.getImage() != null) { if(feed.getImage() != null) {
Log.d(this.toString(), "Feed has image; Downloading...."); Log.d(this.toString(), "Feed has image; Downloading....");
@ -142,13 +140,8 @@ public class DownloadService extends Service {
feed = handler.parseFeed(feed); feed = handler.parseFeed(feed);
Log.d(this.toString(), feed.getTitle() + " parsed"); Log.d(this.toString(), feed.getTitle() + " parsed");
// Save information of feed in DB // Save information of feed in DB
Log.d(this.toString(), "Passing new Feed to DB"); manager.updateFeed(service, feed);
manager.setFeed(service, feed);
// Add Feeditems to the database
Log.d(this.toString(), "Walking through " + feed.getItems().size() + " feeditems"); Log.d(this.toString(), "Walking through " + feed.getItems().size() + " feeditems");
for(FeedItem item : feed.getItems()) {
manager.addFeedItem(service, item);
}
Log.d(this.toString(), "Done."); Log.d(this.toString(), "Done.");
} }