Merge "Fix crash issue when NetworkSelectSettings UI goes OFF and then ON" am: b086fed657

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/1581223

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic7975ae92fa2be360b20dfc4d18f4ad9af789ebe
diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
index ff641e9..c8121c4 100644
--- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java
+++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
@@ -343,16 +343,6 @@
                     mPreferenceCategory.getPreference(numberOfPreferences));
         }
 
-        // update selected preference instance by index
-        for (int index = 0; index < mCellInfoList.size(); index++) {
-            final CellInfo cellInfo = mCellInfoList.get(index);
-
-            if ((mSelectedPreference != null) && mSelectedPreference.isSameCell(cellInfo)) {
-                mSelectedPreference = (NetworkOperatorPreference)
-                        (mPreferenceCategory.getPreference(index));
-            }
-        }
-
         // update the content of preference
         NetworkOperatorPreference connectedPref = null;
         for (int index = 0; index < mCellInfoList.size(); index++) {
@@ -386,6 +376,16 @@
             }
         }
 
+        // update selected preference instance by index
+        for (int index = 0; index < mCellInfoList.size(); index++) {
+            final CellInfo cellInfo = mCellInfoList.get(index);
+
+            if ((mSelectedPreference != null) && mSelectedPreference.isSameCell(cellInfo)) {
+                mSelectedPreference = (NetworkOperatorPreference)
+                        (mPreferenceCategory.getPreference(index));
+            }
+        }
+
         return connectedPref;
     }