don't double set the dropdown value

idion: set the default value, and then add a callback
actual: spinner posts the change to a handler: so it posts after the callback is set.

This makes it hard to count actual user interactions without counting the initialization.

Bug: 21530764
Change-Id: I3ff8319edb374d8d7c10982512054f303c69a5ec
diff --git a/src/com/android/settings/DropDownPreference.java b/src/com/android/settings/DropDownPreference.java
index 89e67a5..ce4bb2f 100644
--- a/src/com/android/settings/DropDownPreference.java
+++ b/src/com/android/settings/DropDownPreference.java
@@ -36,6 +36,7 @@
     private final ArrayList<Object> mValues = new ArrayList<Object>();
 
     private Callback mCallback;
+    private int mSelectedPosition = -1;
 
     public DropDownPreference(Context context) {
         this(context, null);
@@ -54,7 +55,7 @@
         mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
             @Override
             public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
-                setSelectedItem(position);
+                setSelectedItem(position, true);
             }
 
             @Override
@@ -91,11 +92,19 @@
     }
 
     public void setSelectedItem(int position) {
+        setSelectedItem(position, false);
+    }
+
+    public void setSelectedItem(int position, boolean fromSpinner) {
+        if (fromSpinner && position == mSelectedPosition) {
+            return;
+        }
         final Object value = mValues.get(position);
         if (mCallback != null && !mCallback.onItemSelected(position, value)) {
             return;
         }
         mSpinner.setSelection(position);
+        mSelectedPosition = mSpinner.getSelectedItemPosition();
         setSummary(mAdapter.getItem(position));
         final boolean disableDependents = value == null;
         notifyDependencyChange(disableDependents);