Updated references, deleted GreenDroid lib from project
This commit is contained in:
parent
d0cb7c7f36
commit
b1d9a536e0
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lint>
|
||||
</lint>
|
|
@ -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 *;
|
||||
#}
|
|
@ -8,5 +8,5 @@
|
|||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-10
|
||||
android.library.reference.1=libs/GreenDroid/GreenDroid
|
||||
target=android-14
|
||||
android.library.reference.1=/home/daniel/src/android/actionbarsherlock/library/
|
||||
|
|
|
@ -6,22 +6,20 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.view.View;
|
||||
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 */
|
||||
public class AddFeedActivity extends Activity {
|
||||
|
||||
private EditText etxtFeedurl;
|
||||
private Button butConfirm;
|
||||
private FeedManager manager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.addfeed);
|
||||
|
||||
manager = FeedManager.getInstance();
|
||||
|
||||
etxtFeedurl = (EditText) findViewById(R.id.etxtFeedurl);
|
||||
butConfirm = (Button) findViewById(R.id.butConfirm);
|
||||
|
||||
|
@ -38,7 +36,9 @@ public class AddFeedActivity extends Activity {
|
|||
|
||||
private void addNewFeed() {
|
||||
String url = etxtFeedurl.getText().toString();
|
||||
manager.addFeed(this, url);
|
||||
Feed feed = new Feed(url);
|
||||
DownloadRequester req = DownloadRequester.getInstance();
|
||||
req.downloadFeed(this, feed);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -37,24 +37,14 @@ public class FeedManager {
|
|||
return singleton;
|
||||
}
|
||||
|
||||
/** Add and Download a new Feed */
|
||||
public void addFeed(Context context, String url) {
|
||||
// TODO Check if URL is correct
|
||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||
Feed feed = new Feed(url);
|
||||
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;
|
||||
private void addNewFeed(Context context, Feed feed) {
|
||||
feeds.add(feed);
|
||||
feed.setId(setFeed(context, feed));
|
||||
for(FeedItem item : feed.getItems()) {
|
||||
setFeedItem(context, item);
|
||||
}
|
||||
DownloadRequester req = DownloadRequester.getInstance();
|
||||
req.downloadFeed(context, feed);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Adds a new Feeditem if its not in the list */
|
||||
public void addFeedItem(Context context, FeedItem item) {
|
||||
|
@ -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 */
|
||||
private Feed searchFeedByLink(String link) {
|
||||
for(Feed feed : feeds) {
|
||||
|
@ -95,9 +109,14 @@ public class FeedManager {
|
|||
}
|
||||
|
||||
/** 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);
|
||||
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 */
|
||||
|
|
|
@ -106,8 +106,6 @@ public class DownloadService extends Service {
|
|||
requester.removeFeed(feed);
|
||||
// Get Feed Information
|
||||
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
|
||||
if(feed.getImage() != null) {
|
||||
Log.d(this.toString(), "Feed has image; Downloading....");
|
||||
|
@ -142,13 +140,8 @@ public class DownloadService extends Service {
|
|||
feed = handler.parseFeed(feed);
|
||||
Log.d(this.toString(), feed.getTitle() + " parsed");
|
||||
// Save information of feed in DB
|
||||
Log.d(this.toString(), "Passing new Feed to DB");
|
||||
manager.setFeed(service, feed);
|
||||
// Add Feeditems to the database
|
||||
manager.updateFeed(service, feed);
|
||||
Log.d(this.toString(), "Walking through " + feed.getItems().size() + " feeditems");
|
||||
for(FeedItem item : feed.getItems()) {
|
||||
manager.addFeedItem(service, item);
|
||||
}
|
||||
Log.d(this.toString(), "Done.");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue