private void readCurrentMapNames(MapDownloadResource currentMap, JsonReader reader)
        {
            string currentMapName = null;

            reader.BeginObject();
            while (reader.HasNext)
            {
                string key = reader.NextName();
                if (key != null)
                {
                    if (key.Equals(TL_NAME_ID))
                    {
                        currentMapName = reader.NextString();
                    }
                    else if (key.Equals(LNG_CODE_ID))
                    {
                        if (currentMapName != null)
                        {
                            currentMap.setName(currentMapName, reader.NextString());
                        }
                    }
                }
            }
            reader.EndObject();
        }
Пример #2
0
 /**
  * read maps packages list
  * @param maps a list of maps objects that will be read from JSON file
  * @param packagesArray packages array
  */
 private void readMapsPackages(List <MapDownloadResource> maps, JSONArray packagesArray)
 {
     for (int i = 0; i < packagesArray.Length(); i++)
     {
         JSONObject currentPackageObject = null;
         try
         {
             currentPackageObject = packagesArray.GetJSONObject(i);
         }
         catch (JSONException ex)
         {
             SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
         }
         if (currentPackageObject != null)
         {
             MapDownloadResource currentMap = new MapDownloadResource();
             try
             {
                 currentMap.Code = (currentPackageObject.GetString(PACKAGE_CODE_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setSubType(GetMapType(currentPackageObject.GetInt(TYPE_ID)));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 JSONArray currentMapNames = currentPackageObject.GetJSONArray(LANGUAGES_ID);
                 if (currentMapNames != null)
                 {
                     for (int j = 0; j < currentMapNames.Length(); j++)
                     {
                         JSONObject currentMapNameObject = currentMapNames.GetJSONObject(j);
                         if (currentMapNameObject != null)
                         {
                             String currentMapName = currentMapNameObject.GetString(TL_NAME_ID);
                             if (currentMapName != null)
                             {
                                 currentMap.setName(currentMapName, currentMapNameObject.GetString(LNG_CODE_ID));
                             }
                         }
                     }
                 }
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 JSONObject currentMapBoundingBox = currentPackageObject.GetJSONObject(BBOX_ID);
                 if (currentMapBoundingBox != null)
                 {
                     currentMap.setBbLatMax(currentMapBoundingBox.GetDouble(LAT_MAX_ID));
                     currentMap.setBbLatMin(currentMapBoundingBox.GetDouble(LAT_MIN_ID));
                     currentMap.setBbLongMax(currentMapBoundingBox.GetDouble(LONG_MAX_ID));
                     currentMap.setBbLongMin(currentMapBoundingBox.GetDouble(LONG_MIN_ID));
                 }
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setSkmFileSize(currentPackageObject.GetLong(SKM_SIZE_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setSkmFilePath(currentPackageObject.GetString(FILE_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setZipFilePath(currentPackageObject.GetString(NB_ZIP_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setUnzippedFileSize(currentPackageObject.GetLong(UNZIP_SIZE_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 JSONObject currentMapTXGDetails = currentPackageObject.GetJSONObject(TEXTURE_ID);
                 if (currentMapTXGDetails != null)
                 {
                     currentMap.setTXGFilePath(currentMapTXGDetails.GetString(TEXTURES_BIG_FILE_ID));
                     currentMap.setTXGFileSize(currentMapTXGDetails.GetLong(SIZE_BIG_FILE_ID));
                 }
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setSkmAndZipFilesSize(currentPackageObject.GetLong(SIZE_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             if ((currentMap.Code != null) && (currentMap.getSubType() != null))
             {
                 removeNullValuesIfExist(currentMap);
                 maps.Add(currentMap);
             }
         }
     }
 }