losion.liu@sikey.com.cn 11 сар өмнө
parent
commit
9fd59e08c6

+ 1 - 0
app/src/main/java/com/xplora/xpsettings/Activity/ApnListActivity.java

@@ -33,6 +33,7 @@ public class ApnListActivity extends BaseActivity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        Log.d(TAG, "onCreate: ");
         setContentView(R.layout.activity_list);
         moveApn();
         initApn();

+ 16 - 14
app/src/main/java/com/xplora/xpsettings/Data/ApnManager.java

@@ -27,14 +27,20 @@ public class ApnManager {
     public static List<ApnModel> getAPNList(Context context, List<ApnModel> modelList){
         Log.d(TAG, "getAPNList: " + modelList.size());
         List<ApnModel> list = new ArrayList<ApnModel>();
-        ContentResolver resolver = context.getContentResolver();
-
-        String[] dbList = new String[modelList.size()];
-        for (int i = 0; i < modelList.size(); i++) {
-            dbList[i] = modelList.get(i)._id;
+        for (ApnModel model: modelList) {
+            ApnModel apnModel = getAPNListOne(context, model._id, model.apn_id);
+            if (apnModel != null) {
+                list.add(apnModel);
+            }
         }
+        return list;
+    }
+
+    public static ApnModel getAPNListOne(Context context, String _id, String apn_id){
+        List<ApnModel> list = new ArrayList<ApnModel>();
+        ContentResolver resolver = context.getContentResolver();
 
-        Cursor cr = resolver.query(APN_URI, new String[]{"_id"},  "_id" + "=?", dbList, null);
+        Cursor cr = resolver.query(APN_URI, null,  "_id =?", new String[]{ _id } , null);
         while(cr!=null && cr.moveToNext()){
             ApnModel a = new ApnModel();
             a._id = getCursorColumnValue(cr,"_id");
@@ -57,17 +63,13 @@ public class ApnManager {
             a.bearer = getCursorColumnValue(cr,"bearer");
             a.mvno_type = getCursorColumnValue(cr,"mvno_type");
             a.mvno_match_data = getCursorColumnValue(cr,"mvno_match_data");
-            for (ApnModel model: modelList) {
-                if (model._id.equals(a._id)) {
-                    a.apn_id = model.apn_id;
-                    break;
-                }
-            }
-            list.add(a);
+            a.apn_id = apn_id;
+            cr.close();
+            return a;
         }
         if(cr!=null)
             cr.close();
-        return list;
+        return null;
     }
 
     public static int insertAPN(Context context, ApnModel apnModel) {

+ 1 - 1
app/src/main/java/com/xplora/xpsettings/Data/DatabaseHelper.java

@@ -125,7 +125,7 @@ public class DatabaseHelper {
                 ApnModel bean = new ApnModel();
                 bean.apn_id = cursor.getString(cursor.getColumnIndex("apn_id"));
                 bean._id = cursor.getString(cursor.getColumnIndex("_id"));
-                Log.d(TAG, "getCustomApnList: _id: " + bean._id + " mcc: " + bean.mcc + " mnc:" + bean.mnc);
+                Log.d(TAG, "getCustomApnList: apn_id: " + bean.apn_id + " _id:" + bean._id);
                 arrayList.add(bean);
             } while (cursor.moveToNext());
             cursor.close();