Bugfixes + UI-improvements

This commit is contained in:
daniel oeh 2012-06-24 22:57:29 +02:00
parent fc7d06aaf4
commit a2e0c6eecc
9 changed files with 84 additions and 22 deletions

View File

@ -79,6 +79,13 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:src="@drawable/av_download" android:src="@drawable/av_download"
android:visibility="gone" /> android:visibility="gone" />
<ImageView
android:id="@+id/imgvDownloading"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/navigation_refresh"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>

View File

@ -53,6 +53,16 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:textSize="20dp" android:textSize="20dp"
android:textStyle="bold" /> android:textStyle="bold"
android:visibility="gone" />
<ImageView
android:id="@+id/imgvRefreshing"
android:src="@drawable/navigation_refresh"
android:layout_width="55dip"
android:layout_height="55dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:visibility="gone" />
</RelativeLayout> </RelativeLayout>

View File

@ -50,6 +50,8 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
holder.downloaded = (ImageView) convertView holder.downloaded = (ImageView) convertView
.findViewById(R.id.imgvDownloaded); .findViewById(R.id.imgvDownloaded);
holder.type = (ImageView) convertView.findViewById(R.id.imgvType); holder.type = (ImageView) convertView.findViewById(R.id.imgvType);
holder.downloading = (ImageView) convertView
.findViewById(R.id.imgvDownloading);
holder.encInfo = (RelativeLayout) convertView holder.encInfo = (RelativeLayout) convertView
.findViewById(R.id.enc_info); .findViewById(R.id.enc_info);
@ -82,6 +84,13 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
holder.lenSize.setText(Converter.byteToString(item.getMedia() holder.lenSize.setText(Converter.byteToString(item.getMedia()
.getSize())); .getSize()));
} }
if (item.getMedia().isDownloading()) {
holder.downloading.setVisibility(View.VISIBLE);
} else {
holder.downloading.setVisibility(View.GONE);
}
String type = item.getMedia().getMime_type() String type = item.getMedia().getMime_type()
.substring(0, item.getMedia().getMime_type().indexOf('/')); .substring(0, item.getMedia().getMime_type().indexOf('/'));
if (type.equals("audio")) { if (type.equals("audio")) {
@ -103,6 +112,7 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
TextView lenSize; TextView lenSize;
ImageView downloaded; ImageView downloaded;
ImageView type; ImageView type;
ImageView downloading;
ImageButton butAction; ImageButton butAction;
RelativeLayout encInfo; RelativeLayout encInfo;
} }

View File

@ -6,9 +6,11 @@ import java.util.List;
import de.podfetcher.R; import de.podfetcher.R;
import de.podfetcher.feed.Feed; import de.podfetcher.feed.Feed;
import de.podfetcher.storage.DownloadRequester;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -20,6 +22,7 @@ import android.graphics.BitmapFactory;
import android.graphics.Color; import android.graphics.Color;
public class FeedlistAdapter extends ArrayAdapter<Feed> { public class FeedlistAdapter extends ArrayAdapter<Feed> {
private static final String TAG = "FeedlistAdapter";
public FeedlistAdapter(Context context, int textViewResourceId, public FeedlistAdapter(Context context, int textViewResourceId,
List<Feed> objects) { List<Feed> objects) {
@ -48,6 +51,7 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> {
.findViewById(R.id.txtvLastUpdate); .findViewById(R.id.txtvLastUpdate);
holder.numberOfEpisodes = (TextView) convertView.findViewById(R.id.txtvNumEpisodes); holder.numberOfEpisodes = (TextView) convertView.findViewById(R.id.txtvNumEpisodes);
convertView.setTag(holder); convertView.setTag(holder);
holder.refreshing = (ImageView) convertView.findViewById(R.id.imgvRefreshing);
} else { } else {
holder = (Holder) convertView.getTag(); holder = (Holder) convertView.getTag();
} }
@ -58,6 +62,11 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> {
DateFormat.SHORT, DateFormat.SHORT)); DateFormat.SHORT, DateFormat.SHORT));
holder.numberOfEpisodes.setText(feed.getItems().size() + " Episodes"); holder.numberOfEpisodes.setText(feed.getItems().size() + " Episodes");
if (DownloadRequester.getInstance().downloads.contains(feed)) {
Log.d(TAG, "Feed is downloading");
holder.newEpisodes.setVisibility(View.GONE);
holder.refreshing.setVisibility(View.VISIBLE);
} else {
int newItems = feed.getNumOfNewItems(); int newItems = feed.getNumOfNewItems();
if (newItems > 0) { if (newItems > 0) {
holder.newEpisodes.setText(Integer.toString(newItems)); holder.newEpisodes.setText(Integer.toString(newItems));
@ -65,6 +74,7 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> {
} else { } else {
holder.newEpisodes.setVisibility(View.INVISIBLE); holder.newEpisodes.setVisibility(View.INVISIBLE);
} }
}
if (feed.getImage() != null) { if (feed.getImage() != null) {
holder.image.setImageBitmap(feed.getImage().getImageBitmap()); // TODO holder.image.setImageBitmap(feed.getImage().getImageBitmap()); // TODO
@ -86,6 +96,7 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> {
TextView numberOfEpisodes; TextView numberOfEpisodes;
TextView newEpisodes; TextView newEpisodes;
ImageView image; ImageView image;
ImageView refreshing;
} }
} }

View File

@ -48,7 +48,7 @@ public abstract class FeedFile extends FeedComponent {
} }
public boolean isDownloading() { public boolean isDownloading() {
return downloaded == false && file_url != null; return downloadId != 0;
} }

View File

@ -98,7 +98,9 @@ public class FeedlistFragment extends SherlockListFragment {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED);
filter.addAction(DownloadService.ACTION_FEED_SYNC_COMPLETED); filter.addAction(DownloadService.ACTION_FEED_SYNC_COMPLETED);
filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED);
pActivity.registerReceiver(contentUpdate, filter); pActivity.registerReceiver(contentUpdate, filter);
fla.notifyDataSetChanged(); fla.notifyDataSetChanged();

View File

@ -2,7 +2,10 @@ package de.podfetcher.fragment;
import java.util.ArrayList; import java.util.ArrayList;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@ -20,17 +23,13 @@ import de.podfetcher.activity.ItemviewActivity;
import de.podfetcher.adapter.FeedItemlistAdapter; import de.podfetcher.adapter.FeedItemlistAdapter;
import de.podfetcher.feed.FeedItem; import de.podfetcher.feed.FeedItem;
import de.podfetcher.feed.FeedManager; import de.podfetcher.feed.FeedManager;
import de.podfetcher.service.DownloadService;
import de.podfetcher.storage.DownloadRequester; import de.podfetcher.storage.DownloadRequester;
import de.podfetcher.util.FeedItemMenuHandler; import de.podfetcher.util.FeedItemMenuHandler;
/** Displays a list of FeedItems. */ /** Displays a list of FeedItems. */
public class ItemlistFragment extends SherlockListFragment { public class ItemlistFragment extends SherlockListFragment {
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
this.getListView().setItemsCanFocus(true);
}
private static final String TAG = "FeedItemlistFragment"; private static final String TAG = "FeedItemlistFragment";
public static final String EXTRA_SELECTED_FEEDITEM = "extra.de.podfetcher.activity.selected_feeditem"; public static final String EXTRA_SELECTED_FEEDITEM = "extra.de.podfetcher.activity.selected_feeditem";
public static final String ARGUMENT_FEED_ID = "argument.de.podfetcher.feed_id"; public static final String ARGUMENT_FEED_ID = "argument.de.podfetcher.feed_id";
@ -77,11 +76,21 @@ public class ItemlistFragment extends SherlockListFragment {
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
getActivity().unregisterReceiver(contentUpdate);
if (mActionMode != null) { if (mActionMode != null) {
mActionMode.finish(); 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 @Override
@ -95,6 +104,14 @@ public class ItemlistFragment extends SherlockListFragment {
startActivity(showItem); 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() { private final OnClickListener onButActionClicked = new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -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() { private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
@Override @Override

View File

@ -281,12 +281,11 @@ public class DownloadService extends Service {
requester.removeDownload(feed); requester.removeDownload(feed);
cleanup(); cleanup();
// Save information of feed in DB
manager.updateFeed(service, feed);
long statusId = manager.addDownloadStatus(service, new DownloadStatus(feed, 0, true)); long statusId = manager.addDownloadStatus(service, new DownloadStatus(feed, 0, true));
sendDownloadHandledIntent(feed.getDownloadId(), statusId, hasImage, imageId); sendDownloadHandledIntent(feed.getDownloadId(), statusId, hasImage, imageId);
feed.setDownloadId(0); feed.setDownloadId(0);
manager.setFeed(service, feed); // Save information of feed in DB
manager.updateFeed(service, feed);
queryDownloads(); queryDownloads();
} }

View File

@ -30,9 +30,8 @@ public class DownloadRequester {
public static String EXTRA_DOWNLOAD_ID = "extra.de.podfetcher.storage.download_id"; 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 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_DOWNLOAD_QUEUED = "action.de.podfetcher.storage.downloadQueued";
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";
private static boolean STORE_ON_SD = true; private static boolean STORE_ON_SD = true;
public static String IMAGE_DOWNLOADPATH = "images/"; public static String IMAGE_DOWNLOADPATH = "images/";
@ -81,6 +80,7 @@ public class DownloadRequester {
item.setDownloadId(downloadId); item.setDownloadId(downloadId);
item.setFile_url(dest.toString()); item.setFile_url(dest.toString());
context.startService(new Intent(context, DownloadService.class)); context.startService(new Intent(context, DownloadService.class));
context.sendBroadcast(new Intent(ACTION_DOWNLOAD_QUEUED));
return downloadId; return downloadId;
} }
@ -118,6 +118,7 @@ public class DownloadRequester {
if (f != null) { if (f != null) {
downloads.remove(f); downloads.remove(f);
f.setFile_url(null); f.setFile_url(null);
f.setDownloadId(0);
} }
notifyDownloadService(context); notifyDownloadService(context);
} }