summaryrefslogtreecommitdiffstats
path: root/ui/src/com/android/providers/downloads/ui
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2011-03-02 17:34:04 -0800
committerVasu Nori <vnori@google.com>2011-03-02 17:34:04 -0800
commit2622e40de0fa300a00d815f084ea6098f70f93e9 (patch)
tree19a05e5b423835bbb7181c569be42b435ff6c39d /ui/src/com/android/providers/downloads/ui
parentd58f7c299ec6e1164e3b5e9e2e3fe5e0e57e63b9 (diff)
downloadandroid_packages_providers_DownloadProvider-2622e40de0fa300a00d815f084ea6098f70f93e9.tar.gz
android_packages_providers_DownloadProvider-2622e40de0fa300a00d815f084ea6098f70f93e9.tar.bz2
android_packages_providers_DownloadProvider-2622e40de0fa300a00d815f084ea6098f70f93e9.zip
when moving from landscape to portrait, selections are getting lost
when moving from landscape/portait to portrait/landscape mode, losing all the selections (and checkboxes too) Change-Id: Iefb1e0db00229fca68fc1080accb57b0ae3ca26e
Diffstat (limited to 'ui/src/com/android/providers/downloads/ui')
-rw-r--r--ui/src/com/android/providers/downloads/ui/DownloadItem.java3
-rw-r--r--ui/src/com/android/providers/downloads/ui/DownloadList.java27
2 files changed, 21 insertions, 9 deletions
diff --git a/ui/src/com/android/providers/downloads/ui/DownloadItem.java b/ui/src/com/android/providers/downloads/ui/DownloadItem.java
index 2ab38ff5..4cbcd332 100644
--- a/ui/src/com/android/providers/downloads/ui/DownloadItem.java
+++ b/ui/src/com/android/providers/downloads/ui/DownloadItem.java
@@ -72,6 +72,9 @@ public class DownloadItem extends RelativeLayout implements Checkable {
mPosition = position;
mFileName = fileName;
mMimeType = mimeType;
+ if (mDownloadList.isDownloadSelected(downloadId)) {
+ setChecked(true);
+ }
}
public void setDownloadListObj(DownloadList downloadList) {
diff --git a/ui/src/com/android/providers/downloads/ui/DownloadList.java b/ui/src/com/android/providers/downloads/ui/DownloadList.java
index ec24325e..b932b115 100644
--- a/ui/src/com/android/providers/downloads/ui/DownloadList.java
+++ b/ui/src/com/android/providers/downloads/ui/DownloadList.java
@@ -190,6 +190,8 @@ public class DownloadList extends Activity {
public void onClick(View v) {
// flip the view
mIsSortedBySize = !mIsSortedBySize;
+ // clear all selections
+ mSelectedIds.clear();
chooseListToShow();
}
});
@@ -312,14 +314,17 @@ public class DownloadList extends Activity {
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
boolean checked) {
- ListView lv = mDownloadList.getCurrentView();
- int numChecked = lv.getCheckedItemCount();
- if (numChecked > 0) {
- mode.setTitle(String.format(mDownloadList.mSelectedCountFormat, numChecked,
- mDownloadList.mCurrentCursor.getCount()));
- } else {
- mode.setTitle("");
- }
+ mDownloadList.setActionModeTitle(mode);
+ }
+ }
+
+ void setActionModeTitle(ActionMode mode) {
+ int numSelected = mSelectedIds.size();
+ if (numSelected > 0) {
+ mode.setTitle(String.format(mSelectedCountFormat, numSelected,
+ mCurrentCursor.getCount()));
+ } else {
+ mode.setTitle("");
}
}
@@ -366,6 +371,7 @@ public class DownloadList extends Activity {
SelectionObjAttrs obj = mSelectedIds.get(id);
fileNames[i] = obj.getFileName();
mimeTypes[i] = obj.getMimeType();
+ i++;
}
outState.putLongArray(BUNDLE_SAVED_DOWNLOAD_IDS, selectedIds);
outState.putStringArray(BUNDLE_SAVED_FILENAMES, fileNames);
@@ -403,7 +409,10 @@ public class DownloadList extends Activity {
lv.setVisibility(View.VISIBLE);
lv.invalidateViews(); // ensure checkboxes get updated
}
- mSelectedIds.clear();
+ // restore the ActionMode title if there are selections
+ if (mActionMode != null) {
+ setActionModeTitle(mActionMode);
+ }
}
ListView getCurrentView() {