Canceling running queries before starting new ones.

Change-Id: Icd7837cf44d7f33a6027961640205f23d0158a72
diff --git a/src/com/android/contacts/list/ContactEntryListFragment.java b/src/com/android/contacts/list/ContactEntryListFragment.java
index 0fbd2b5..9f398c0 100644
--- a/src/com/android/contacts/list/ContactEntryListFragment.java
+++ b/src/com/android/contacts/list/ContactEntryListFragment.java
@@ -338,6 +338,7 @@
         } else {
             mAdapter.configureLoader(loader, partition.getDirectoryId());
             if (forceLoad) {
+                loader.cancelLoad();
                 loader.forceLoad();
             }
         }
@@ -346,6 +347,21 @@
     protected void reloadData() {
         mAdapter.onDataReload();
         if (mDirectoryPartitions.size() > 0) {
+            // We need to cancel _all_ current queries and then launch
+            // a new query for the 0th partition.
+
+            CursorLoader directoryLoader = (CursorLoader)getLoader(DIRECTORY_LOADER_ID);
+            if (directoryLoader != null) {
+                directoryLoader.cancelLoad();
+            }
+            int size = mDirectoryPartitions.size();
+            for (int i = 0; i < size; i++) {
+                CursorLoader loader = (CursorLoader)getLoader(i);
+                if (loader != null) {
+                    loader.cancelLoad();
+                }
+            }
+
             startLoading(mDirectoryPartitions.get(0), true);
         }
     }