From daed066d4dcc8873d3463ae65e16fa2e7fbcafe5 Mon Sep 17 00:00:00 2001 From: Vasu Nori Date: Wed, 23 Feb 2011 16:49:09 -0800 Subject: bug:3308769 add CAB options to downloads app Change-Id: I9bb1374b7ca0053210274e5d6981b2f2dcf6bfca --- .../providers/downloads/ui/DownloadAdapter.java | 28 ++++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'ui/src/com/android/providers/downloads/ui/DownloadAdapter.java') diff --git a/ui/src/com/android/providers/downloads/ui/DownloadAdapter.java b/ui/src/com/android/providers/downloads/ui/DownloadAdapter.java index c0a916c9..e8bea08a 100644 --- a/ui/src/com/android/providers/downloads/ui/DownloadAdapter.java +++ b/ui/src/com/android/providers/downloads/ui/DownloadAdapter.java @@ -35,8 +35,6 @@ import android.widget.CursorAdapter; import android.widget.ImageView; import android.widget.TextView; -import com.android.providers.downloads.ui.DownloadItem.DownloadSelectListener; - import java.text.DateFormat; import java.util.Calendar; import java.util.Date; @@ -47,9 +45,8 @@ import java.util.List; * List adapter for Cursors returned by {@link DownloadManager}. */ public class DownloadAdapter extends CursorAdapter { - private Context mContext; + private final DownloadList mDownloadList; private Cursor mCursor; - private DownloadSelectListener mDownloadSelectionListener; private Resources mResources; private DateFormat mDateFormat; private DateFormat mTimeFormat; @@ -63,13 +60,11 @@ public class DownloadAdapter extends CursorAdapter { private int mDateColumnId; private int mIdColumnId; - public DownloadAdapter(Context context, Cursor cursor, - DownloadSelectListener selectionListener) { - super(context, cursor); - mContext = context; + public DownloadAdapter(DownloadList downloadList, Cursor cursor) { + super(downloadList, cursor); + mDownloadList = downloadList; mCursor = cursor; - mResources = mContext.getResources(); - mDownloadSelectionListener = selectionListener; + mResources = mDownloadList.getResources(); mDateFormat = DateFormat.getDateInstance(DateFormat.SHORT); mTimeFormat = DateFormat.getTimeInstance(DateFormat.SHORT); @@ -85,19 +80,20 @@ public class DownloadAdapter extends CursorAdapter { } public View newView() { - DownloadItem view = (DownloadItem) LayoutInflater.from(mContext) + DownloadItem view = (DownloadItem) LayoutInflater.from(mDownloadList) .inflate(R.layout.download_list_item, null); - view.setSelectListener(mDownloadSelectionListener); + view.setDownloadListObj(mDownloadList); return view; } - public void bindView(View convertView) { + public void bindView(View convertView, int position) { if (!(convertView instanceof DownloadItem)) { return; } long downloadId = mCursor.getLong(mIdColumnId); - ((DownloadItem) convertView).setDownloadId(downloadId); + ((DownloadItem) convertView).setData(downloadId, position); + // Retrieve the icon for this download retrieveAndSetIcon(convertView); @@ -113,7 +109,7 @@ public class DownloadAdapter extends CursorAdapter { setTextForView(convertView, R.id.last_modified_date, getDateString()); CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.download_checkbox); - checkBox.setChecked(mDownloadSelectionListener.isDownloadSelected(downloadId)); + checkBox.setChecked(mDownloadList.isDownloadSelected(downloadId)); } private String getDateString() { @@ -207,6 +203,6 @@ public class DownloadAdapter extends CursorAdapter { @Override public void bindView(View view, Context context, Cursor cursor) { - bindView(view); + bindView(view, cursor.getPosition()); } } -- cgit v1.2.3