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:src="@drawable/av_download"
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>
</RelativeLayout>
</LinearLayout>

View File

@ -53,6 +53,16 @@
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
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>

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -48,7 +48,7 @@ public abstract class FeedFile extends FeedComponent {
}
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() {
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();

View File

@ -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

View File

@ -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();
}

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_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);
}