add weather location and description into settings.
authorTrillGates <williamtrillgates@gmail.com>
Fri, 23 Jul 2021 03:42:24 +0000 (11:42 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Fri, 23 Jul 2021 03:42:24 +0000 (11:42 +0800)
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/ic/protocols/protocol_anan.java
app/src/main/java/com/ic/protocols/protocol_fzd.java
app/src/main/java/com/ic/protocols/protocol_s123.java

index ced329e..ca04996 100644 (file)
@@ -465,8 +465,6 @@ public class CoreService extends Service {
 
     AbstractInvokeHandlerService invokeHandlerServiceChain;
 
-    private boolean isBinded = false;
-
     private AntiMonitorService antiservice;
     LocationClient locationClient;
 
index 36c9620..db0fbe5 100644 (file)
@@ -977,6 +977,18 @@ public class protocol_anan {
             mRuntime.getContextProxy().getResolver().insert(
                     Uri.parse(ICGlobalSettingsProvider.SETTINGS),
                     wtCodeValues);
+            ContentValues wtLocationValues = new ContentValues();
+            wtLocationValues.put(ICDatabaseHelper.sKey, "weather_location");
+            wtLocationValues.put(ICDatabaseHelper.sValue, genericWeatherInfo.getCityName());
+            mRuntime.getContextProxy().getResolver().insert(
+                    Uri.parse(ICGlobalSettingsProvider.SETTINGS),
+                    wtLocationValues);
+            ContentValues wtDescValues = new ContentValues();
+            wtDescValues.put(ICDatabaseHelper.sKey, "weather_desc");
+            wtDescValues.put(ICDatabaseHelper.sValue, genericWeatherInfo.getDescription());
+            mRuntime.getContextProxy().getResolver().insert(
+                    Uri.parse(ICGlobalSettingsProvider.SETTINGS),
+                    wtDescValues);
         } else {
             ICLogger.i(" BPTQ Format error!");
         }
index 3c9cfcf..c582e66 100644 (file)
@@ -2482,6 +2482,22 @@ public class protocol_fzd {
                         Uri.parse(ICGlobalSettingsProvider.SETTINGS),
                         tempValues
                 );
+                //城市
+                ContentValues locationValues = new ContentValues();
+                locationValues.put(ICDatabaseHelper.sKey, "weather_location");
+                locationValues.put(ICDatabaseHelper.sValue, cityName);
+                mRuntime.getContextProxy().getResolver().insert(
+                        Uri.parse(ICGlobalSettingsProvider.SETTINGS),
+                        locationValues
+                );
+                //天气描述
+                ContentValues descriptionValues = new ContentValues();
+                descriptionValues.put(ICDatabaseHelper.sKey, "weather_desc");
+                descriptionValues.put(ICDatabaseHelper.sValue, wtDesc);
+                mRuntime.getContextProxy().getResolver().insert(
+                        Uri.parse(ICGlobalSettingsProvider.SETTINGS),
+                        descriptionValues
+                );
                 if (mRuntime.mFZDWeatherCallback != null) {
                     mRuntime.mFZDWeatherCallback.onWeatherInfoLoaded(fzdWeatherInfo);
                 }
index d9abdee..841ee1b 100644 (file)
@@ -2610,7 +2610,7 @@ public class protocol_s123 {
 
             StringBuilder sb = new StringBuilder();
             StringBuilder msg = new StringBuilder();
-            String City = Util.decodeUnicode2Utf8(cmdlist[22]);
+            String cityName = Util.decodeUnicode2Utf8(cmdlist[22]);
             List<GenericWeatherInfo> weatherInfo = new ArrayList<>();
             for (int i = 0; i < 3; i++) {
                 String DayTime = cmdlist[1 + i * 7] + " " + cmdlist[2 + i * 7];
@@ -2639,13 +2639,48 @@ public class protocol_s123 {
 
                 //返回数据给UI
                 GenericWeatherInfo itemFirst = new GenericWeatherInfo(DayTime,
-                        weather_name, weather_id, temp_current, temp_low, temp_high, City);
+                        weather_name, weather_id, temp_current, temp_low, temp_high, cityName);
                 //封装数据
                 weatherInfo.add(itemFirst);
+                if (i == 0) {
+
+                    //插入天气类型
+                    ContentValues wtCodeValues = new ContentValues();
+                    wtCodeValues.put(ICDatabaseHelper.sKey, "weather_type");
+                    wtCodeValues.put(ICDatabaseHelper.sValue, weather_id);
+                    mRuntime.getContextProxy().getResolver().insert(
+                            Uri.parse(ICGlobalSettingsProvider.SETTINGS),
+                            wtCodeValues
+                    );
+                    //插入天气当前温度
+                    ContentValues tempValues = new ContentValues();
+                    tempValues.put(ICDatabaseHelper.sKey, "weather_temp");
+                    tempValues.put(ICDatabaseHelper.sValue, temp_current);
+                    mRuntime.getContextProxy().getResolver().insert(
+                            Uri.parse(ICGlobalSettingsProvider.SETTINGS),
+                            tempValues
+                    );
+                    //城市
+                    ContentValues locationValues = new ContentValues();
+                    locationValues.put(ICDatabaseHelper.sKey, "weather_location");
+                    locationValues.put(ICDatabaseHelper.sValue, cityName);
+                    mRuntime.getContextProxy().getResolver().insert(
+                            Uri.parse(ICGlobalSettingsProvider.SETTINGS),
+                            locationValues
+                    );
+                    //天气描述
+                    ContentValues descriptionValues = new ContentValues();
+                    descriptionValues.put(ICDatabaseHelper.sKey, "weather_desc");
+                    descriptionValues.put(ICDatabaseHelper.sValue, weather_name);
+                    mRuntime.getContextProxy().getResolver().insert(
+                            Uri.parse(ICGlobalSettingsProvider.SETTINGS),
+                            descriptionValues
+                    );
+                }
             }
-            ICLogger.i(City + " \n" + sb.toString());
+            ICLogger.i(cityName + " \n" + sb.toString());
 
-            msg.insert(0, City + ";");
+            msg.insert(0, cityName + ";");
             String weatherstr = msg.toString();
             if (weatherstr.endsWith(";")) {
                 weatherstr = weatherstr.substring(0, weatherstr.lastIndexOf(";"));