summaryrefslogtreecommitdiffstats
path: root/src/com/android/calendar/Utils.java
diff options
context:
space:
mode:
authorErik <roboerik@android.com>2010-03-29 18:20:32 -0700
committerErik <roboerik@android.com>2010-03-31 14:14:26 -0700
commita144f86b41170e8ee7fe8d966cc51c5fc90cd44a (patch)
tree75f9ae35fac03ed0a6c073f71667b2ff60f4b746 /src/com/android/calendar/Utils.java
parent10b4b67d45c1e706b3323c1dacf390f783e6bc9f (diff)
downloadandroid_packages_apps_Calendar-a144f86b41170e8ee7fe8d966cc51c5fc90cd44a.tar.gz
android_packages_apps_Calendar-a144f86b41170e8ee7fe8d966cc51c5fc90cd44a.tar.bz2
android_packages_apps_Calendar-a144f86b41170e8ee7fe8d966cc51c5fc90cd44a.zip
b/2555049 Will only query accounts once when entering Calendars screen
There was noticeable jitter on entering the Calendars screen including misregistering taps due to the cursor requerying repeatedly during a sync. This change makes it so we only query on accounts once and then will requery every five seconds for about a minute. The view will only be updated if a change has occurred. Change-Id: I53610836e78d970d452d4c9724a2d3525cd85482
Diffstat (limited to 'src/com/android/calendar/Utils.java')
-rw-r--r--src/com/android/calendar/Utils.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/com/android/calendar/Utils.java b/src/com/android/calendar/Utils.java
index 8b2660de..adba8214 100644
--- a/src/com/android/calendar/Utils.java
+++ b/src/com/android/calendar/Utils.java
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
+import android.database.MatrixCursor;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
@@ -91,6 +92,53 @@ public class Utils {
return time;
}
+ public static MatrixCursor matrixCursorFromCursor(Cursor cursor) {
+ MatrixCursor newCursor = new MatrixCursor(cursor.getColumnNames());
+ int numColumns = cursor.getColumnCount();
+ String data[] = new String[numColumns];
+ cursor.moveToPosition(-1);
+ while (cursor.moveToNext()) {
+ for (int i = 0; i < numColumns; i++) {
+ data[i] = cursor.getString(i);
+ }
+ newCursor.addRow(data);
+ }
+ return newCursor;
+ }
+
+ /**
+ * Compares two cursors to see if they contain the same data.
+ *
+ * @return Returns true of the cursors contain the same data and are not null, false
+ * otherwise
+ */
+ public static boolean compareCursors(Cursor c1, Cursor c2) {
+ if(c1 == null || c2 == null) {
+ return false;
+ }
+
+ int numColumns = c1.getColumnCount();
+ if (numColumns != c2.getColumnCount()) {
+ return false;
+ }
+
+ if (c1.getCount() != c2.getCount()) {
+ return false;
+ }
+
+ c1.moveToPosition(-1);
+ c2.moveToPosition(-1);
+ while(c1.moveToNext() && c2.moveToNext()) {
+ for(int i = 0; i < numColumns; i++) {
+ if(!c1.getString(i).equals(c2.getString(i))) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
/**
* If the given intent specifies a time (in milliseconds since the epoch),
* then that time is returned. Otherwise, the current time is returned.