diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-06-24 22:57:29 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-06-24 22:57:29 +0200 |
commit | a2e0c6eecc7430ec9399be8694be7e5dc9ffb614 (patch) | |
tree | 08abf8896b452911e51ff97c05481c2d4e7692f6 /src/de | |
parent | fc7d06aaf429a0a1ab30b38a7fdc103144a6c20e (diff) | |
download | AntennaPod-a2e0c6eecc7430ec9399be8694be7e5dc9ffb614.zip |
Bugfixes + UI-improvements
Diffstat (limited to 'src/de')
-rw-r--r-- | src/de/podfetcher/adapter/FeedItemlistAdapter.java | 10 | ||||
-rw-r--r-- | src/de/podfetcher/adapter/FeedlistAdapter.java | 25 | ||||
-rw-r--r-- | src/de/podfetcher/feed/FeedFile.java | 2 | ||||
-rw-r--r-- | src/de/podfetcher/fragment/FeedlistFragment.java | 2 | ||||
-rw-r--r-- | src/de/podfetcher/fragment/ItemlistFragment.java | 34 | ||||
-rw-r--r-- | src/de/podfetcher/service/DownloadService.java | 7 | ||||
-rw-r--r-- | src/de/podfetcher/storage/DownloadRequester.java | 7 |
7 files changed, 66 insertions, 21 deletions
diff --git a/src/de/podfetcher/adapter/FeedItemlistAdapter.java b/src/de/podfetcher/adapter/FeedItemlistAdapter.java index 21678b244..eca0a5a7a 100644 --- a/src/de/podfetcher/adapter/FeedItemlistAdapter.java +++ b/src/de/podfetcher/adapter/FeedItemlistAdapter.java @@ -50,6 +50,8 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { holder.downloaded = (ImageView) convertView .findViewById(R.id.imgvDownloaded); holder.type = (ImageView) convertView.findViewById(R.id.imgvType); + holder.downloading = (ImageView) convertView + .findViewById(R.id.imgvDownloading); holder.encInfo = (RelativeLayout) convertView .findViewById(R.id.enc_info); @@ -82,6 +84,13 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { holder.lenSize.setText(Converter.byteToString(item.getMedia() .getSize())); } + + if (item.getMedia().isDownloading()) { + holder.downloading.setVisibility(View.VISIBLE); + } else { + holder.downloading.setVisibility(View.GONE); + } + String type = item.getMedia().getMime_type() .substring(0, item.getMedia().getMime_type().indexOf('/')); if (type.equals("audio")) { @@ -103,6 +112,7 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { TextView lenSize; ImageView downloaded; ImageView type; + ImageView downloading; ImageButton butAction; RelativeLayout encInfo; } diff --git a/src/de/podfetcher/adapter/FeedlistAdapter.java b/src/de/podfetcher/adapter/FeedlistAdapter.java index 8f9860ce1..e229a55f3 100644 --- a/src/de/podfetcher/adapter/FeedlistAdapter.java +++ b/src/de/podfetcher/adapter/FeedlistAdapter.java @@ -6,9 +6,11 @@ import java.util.List; import de.podfetcher.R; import de.podfetcher.feed.Feed; +import de.podfetcher.storage.DownloadRequester; import android.content.Context; import android.net.Uri; import android.text.format.DateUtils; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -20,7 +22,8 @@ import android.graphics.BitmapFactory; import android.graphics.Color; public class FeedlistAdapter extends ArrayAdapter<Feed> { - + private static final String TAG = "FeedlistAdapter"; + public FeedlistAdapter(Context context, int textViewResourceId, List<Feed> objects) { super(context, textViewResourceId, objects); @@ -48,6 +51,7 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> { .findViewById(R.id.txtvLastUpdate); holder.numberOfEpisodes = (TextView) convertView.findViewById(R.id.txtvNumEpisodes); convertView.setTag(holder); + holder.refreshing = (ImageView) convertView.findViewById(R.id.imgvRefreshing); } else { holder = (Holder) convertView.getTag(); } @@ -58,14 +62,20 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> { DateFormat.SHORT, DateFormat.SHORT)); holder.numberOfEpisodes.setText(feed.getItems().size() + " Episodes"); - int newItems = feed.getNumOfNewItems(); - if (newItems > 0) { - holder.newEpisodes.setText(Integer.toString(newItems)); - holder.newEpisodes.setVisibility(View.VISIBLE); + if (DownloadRequester.getInstance().downloads.contains(feed)) { + Log.d(TAG, "Feed is downloading"); + holder.newEpisodes.setVisibility(View.GONE); + holder.refreshing.setVisibility(View.VISIBLE); } else { - holder.newEpisodes.setVisibility(View.INVISIBLE); + int newItems = feed.getNumOfNewItems(); + if (newItems > 0) { + holder.newEpisodes.setText(Integer.toString(newItems)); + holder.newEpisodes.setVisibility(View.VISIBLE); + } else { + holder.newEpisodes.setVisibility(View.INVISIBLE); + } } - + if (feed.getImage() != null) { holder.image.setImageBitmap(feed.getImage().getImageBitmap()); // TODO // select @@ -86,6 +96,7 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> { TextView numberOfEpisodes; TextView newEpisodes; ImageView image; + ImageView refreshing; } } diff --git a/src/de/podfetcher/feed/FeedFile.java b/src/de/podfetcher/feed/FeedFile.java index f06f79a62..2a1c4eb2a 100644 --- a/src/de/podfetcher/feed/FeedFile.java +++ b/src/de/podfetcher/feed/FeedFile.java @@ -48,7 +48,7 @@ public abstract class FeedFile extends FeedComponent { } public boolean isDownloading() { - return downloaded == false && file_url != null; + return downloadId != 0; } diff --git a/src/de/podfetcher/fragment/FeedlistFragment.java b/src/de/podfetcher/fragment/FeedlistFragment.java index 2b42c8548..f1e160295 100644 --- a/src/de/podfetcher/fragment/FeedlistFragment.java +++ b/src/de/podfetcher/fragment/FeedlistFragment.java @@ -98,7 +98,9 @@ public class FeedlistFragment extends SherlockListFragment { public void onResume() { super.onResume(); IntentFilter filter = new IntentFilter(); + filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED); filter.addAction(DownloadService.ACTION_FEED_SYNC_COMPLETED); + filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED); pActivity.registerReceiver(contentUpdate, filter); fla.notifyDataSetChanged(); diff --git a/src/de/podfetcher/fragment/ItemlistFragment.java b/src/de/podfetcher/fragment/ItemlistFragment.java index a7633f19f..9e4cefeb8 100644 --- a/src/de/podfetcher/fragment/ItemlistFragment.java +++ b/src/de/podfetcher/fragment/ItemlistFragment.java @@ -2,7 +2,10 @@ package de.podfetcher.fragment; import java.util.ArrayList; +import android.content.BroadcastReceiver; +import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.os.Bundle; import android.util.Log; import android.view.View; @@ -20,16 +23,12 @@ import de.podfetcher.activity.ItemviewActivity; import de.podfetcher.adapter.FeedItemlistAdapter; import de.podfetcher.feed.FeedItem; import de.podfetcher.feed.FeedManager; +import de.podfetcher.service.DownloadService; import de.podfetcher.storage.DownloadRequester; import de.podfetcher.util.FeedItemMenuHandler; /** Displays a list of FeedItems. */ public class ItemlistFragment extends SherlockListFragment { - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - this.getListView().setItemsCanFocus(true); - } private static final String TAG = "FeedItemlistFragment"; public static final String EXTRA_SELECTED_FEEDITEM = "extra.de.podfetcher.activity.selected_feeditem"; @@ -77,12 +76,22 @@ public class ItemlistFragment extends SherlockListFragment { @Override public void onPause() { super.onPause(); + getActivity().unregisterReceiver(contentUpdate); if (mActionMode != null) { mActionMode.finish(); } } - + @Override + public void onResume() { + super.onResume(); + IntentFilter filter = new IntentFilter(); + filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED); + filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED); + + getActivity().registerReceiver(contentUpdate, filter); + } + @Override public void onListItemClick(ListView l, View v, int position, long id) { @@ -94,6 +103,14 @@ public class ItemlistFragment extends SherlockListFragment { startActivity(showItem); } + + private BroadcastReceiver contentUpdate = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + Log.d(TAG, "Received contentUpdate Intent."); + fila.notifyDataSetChanged(); + } + }; private final OnClickListener onButActionClicked = new OnClickListener() { @Override @@ -117,6 +134,11 @@ public class ItemlistFragment extends SherlockListFragment { } }; + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + this.getListView().setItemsCanFocus(true); + } + private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() { @Override diff --git a/src/de/podfetcher/service/DownloadService.java b/src/de/podfetcher/service/DownloadService.java index 79c9e5217..9f78bd1f5 100644 --- a/src/de/podfetcher/service/DownloadService.java +++ b/src/de/podfetcher/service/DownloadService.java @@ -280,13 +280,12 @@ public class DownloadService extends Service { } requester.removeDownload(feed); - cleanup(); - // Save information of feed in DB - manager.updateFeed(service, feed); + cleanup(); long statusId = manager.addDownloadStatus(service, new DownloadStatus(feed, 0, true)); sendDownloadHandledIntent(feed.getDownloadId(), statusId, hasImage, imageId); feed.setDownloadId(0); - manager.setFeed(service, feed); + // Save information of feed in DB + manager.updateFeed(service, feed); queryDownloads(); } diff --git a/src/de/podfetcher/storage/DownloadRequester.java b/src/de/podfetcher/storage/DownloadRequester.java index 6680ebda5..2707f8844 100644 --- a/src/de/podfetcher/storage/DownloadRequester.java +++ b/src/de/podfetcher/storage/DownloadRequester.java @@ -30,9 +30,8 @@ public class DownloadRequester { public static String EXTRA_DOWNLOAD_ID = "extra.de.podfetcher.storage.download_id"; public static String EXTRA_ITEM_ID = "extra.de.podfetcher.storage.item_id"; - public static String ACTION_FEED_DOWNLOAD_COMPLETED = "action.de.podfetcher.storage.feed_download_completed"; - public static String ACTION_MEDIA_DOWNLOAD_COMPLETED = "action.de.podfetcher.storage.media_download_completed"; - public static String ACTION_IMAGE_DOWNLOAD_COMPLETED = "action.de.podfetcher.storage.image_download_completed"; + public static String ACTION_DOWNLOAD_QUEUED = "action.de.podfetcher.storage.downloadQueued"; + private static boolean STORE_ON_SD = true; public static String IMAGE_DOWNLOADPATH = "images/"; @@ -81,6 +80,7 @@ public class DownloadRequester { item.setDownloadId(downloadId); item.setFile_url(dest.toString()); context.startService(new Intent(context, DownloadService.class)); + context.sendBroadcast(new Intent(ACTION_DOWNLOAD_QUEUED)); return downloadId; } @@ -118,6 +118,7 @@ public class DownloadRequester { if (f != null) { downloads.remove(f); f.setFile_url(null); + f.setDownloadId(0); } notifyDownloadService(context); } |