/// <summary> /// adds the entry output data to the intent to be sent to a plugin /// </summary> public static void AddEntryToIntent(Intent intent, PwEntryOutput entry) { /*//add the entry XML not yet implemented. What to do with attachments? MemoryStream memStream = new MemoryStream(); KdbxFile.WriteEntries(memStream, new[] {entry}); string entryData = StrUtil.Utf8.GetString(memStream.ToArray()); intent.PutExtra(Strings.ExtraEntryData, entryData); */ //add the output string array (placeholders replaced taking into account the db context) Dictionary<string, string> outputFields = entry.OutputStrings.ToDictionary(pair => StrUtil.SafeXmlString(pair.Key), pair => pair.Value.ReadString()); JSONObject jsonOutput = new JSONObject(outputFields); var jsonOutputStr = jsonOutput.ToString(); intent.PutExtra(Strings.ExtraEntryOutputData, jsonOutputStr); JSONArray jsonProtectedFields = new JSONArray( (System.Collections.ICollection)entry.OutputStrings .Where(pair => pair.Value.IsProtected) .Select(pair => pair.Key) .ToArray()); intent.PutExtra(Strings.ExtraProtectedFieldsList, jsonProtectedFields.ToString()); intent.PutExtra(Strings.ExtraEntryId, entry.Uuid.ToHexString()); }
public static Recipe FromJson(Context context, JSONObject json) { var recipe = new Recipe (); try { recipe.TitleText = json.GetString(Constants.RecipeFieldTitle); recipe.SummaryText = json.GetString(Constants.RecipeFieldSummary); if (json.Has(Constants.RecipeFieldImage)) { recipe.RecipeImage = json.GetString(Constants.RecipeFieldImage); } JSONArray ingredients = json.GetJSONArray(Constants.RecipeFieldIngredients); recipe.IngredientsText = ""; for (int i = 0; i < ingredients.Length(); i++) { recipe.IngredientsText += " - " + ingredients.GetJSONObject(i).GetString(Constants.RecipeFieldText) + "\n"; } JSONArray steps = json.GetJSONArray(Constants.RecipeFieldSteps); for (int i = 0; i < steps.Length(); i++) { var step = steps.GetJSONObject(i); var recipeStep = new RecipeStep(); recipeStep.StepText = step.GetString(Constants.RecipeFieldText); if (step.Has(Constants.RecipeFieldName)) { recipeStep.StepImage = step.GetString(Constants.RecipeFieldImage); } recipe.RecipeSteps.Add(recipeStep); } } catch (Exception ex) { Log.Error (Tag, "Error loading recipe: " + ex); return null; } return recipe; }
public void OnCompleted(Org.Json.JSONObject json, GraphResponse response) { string data = json.ToString(); email = json.GetString("email"); var result = JsonConvert.DeserializeObject(data); }
/// <summary> /// Call the FAA Airport service to get status information for airport with the given code. /// </summary> public static AirportStatus GetStatus(string iataCode) { var content = PerformRequest(iataCode); if (content == null) return null; var status = new JSONObject(content); return new AirportStatus(status); }
private void InitView() { //设置标题栏 var img_header_back = FindViewById<ImageView> (Resource.Id.img_header_back); img_header_back.Click += (sender, e) => { this.Finish(); OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight); }; var tv_back = FindViewById<TextView> (Resource.Id.tv_back); tv_back.Text = "报警记录"; var tv_desc = FindViewById<TextView> (Resource.Id.tv_desc); tv_desc.Text = "报警详细"; var bundle = Intent.Extras; var alarmOrigin = bundle.GetString ("alarmOrigin"); if (alarmOrigin == "Jpush") { var title = bundle.GetString (JPushInterface.ExtraNotificationTitle); var content = bundle.GetString (JPushInterface.ExtraAlert); var extras = bundle.GetString (JPushInterface.ExtraExtra); JSONObject extrasJson = new JSONObject(extras); alarmId = extrasJson.OptString("aid"); } else if(alarmOrigin == "alarmList") { alarmId = bundle.GetString ("alarmId");//报警id } tv_detail_alamTime = FindViewById<TextView>(Resource.Id.tv_detail_alamTime); tv_detail_alarmPosition = FindViewById<TextView> (Resource.Id.tv_detail_alarmPosition); tv_detail_trueName = FindViewById<TextView> (Resource.Id.tv_detail_trueName); tv_detail_alarmContent = FindViewById<TextView> (Resource.Id.tv_detail_alarmContent); tv_detail_deviceElectricity = FindViewById<TextView> (Resource.Id.tv_detail_deviceElectricity); tv_detail_alarmDeviceId = FindViewById<TextView> (Resource.Id.tv_detail_alarmDeviceId); tv_detail_remark = FindViewById<TextView> (Resource.Id.tv_detail_remark); tv_detail_status = FindViewById<TextView> (Resource.Id.tv_detail_status); tv_detail_alarmWay = FindViewById<TextView> (Resource.Id.tv_detail_alarmWay); tv_detail_handleUserType = FindViewById<TextView> (Resource.Id.tv_detail_handleUserType); tv_detail_cTrueName = FindViewById<TextView> (Resource.Id.tv_detail_cTrueName); tv_detail_cphoneNumberOne = FindViewById<TextView> (Resource.Id.tv_detail_cphoneNumberOne); lv_handleDetail = FindViewById<ListView> (Resource.Id.lv_handleDetail); ll_maplocation = FindViewById<LinearLayout> (Resource.Id.ll_maplocation); //查看地图 ll_maplocation.Click += (object sender, EventArgs e) => { if(string.IsNullOrEmpty(alarmPosition) || !alarmPosition.Contains(",")) return; var intent = new Intent(this,typeof(AlarmLocationActivity)); var alarmbundle = new Bundle(); alarmbundle.PutString("alarmPosition",alarmPosition); intent.PutExtras(alarmbundle); StartActivity(intent); //StartActivity(typeof(AlarmLocationActivity)); OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight); }; //LoadDetailData (); new Handler ().PostDelayed (LoadDetailData, 1000); }
/// <summary> /// Default ctor /// </summary> internal AirportStatus(JSONObject source) { Delay = source.GetBoolean("delay"); IataCode = source.GetString("IATA"); State= source.GetString("state"); City = source.GetString("city"); Name = source.GetString("name"); var weather = source.GetJSONObject("weather"); Temperature = weather.GetString("temp"); Wind = weather.GetString("wind"); }
public void OnSuccess(global::Java.Lang.Object result) { var str = result.JavaCast<Java.Lang.String>().ToString(); using (var helper = new OuyaEncryptionHelper()) { var response = new JSONObject(str); var id = helper.DecryptPurchaseResponse(response, _publicKey); if (id != _uniquePurchaseId) OnFailure(OuyaErrorCodes.ThrowDuringOnSuccess, "Received purchase ID does not match what we expected to receive", Bundle.Empty); _tcs.SetResult(true); } }
private void getCategories(Action<List<LevelCategory>> callback) { List<LevelCategory> categories = new List<LevelCategory>(); var client = new RestClient("http://webmat.cs.aau.dk/api/"); var request = new RestRequest(Method.POST); request.AddParameter("action", "get_levels"); request.AddParameter("token", token); string data; try { data = client.Execute(request).Content; } catch (TimeoutException) { getCategories(callback); return; } JSONObject json = new JSONObject(data); JSONArray jsonArray = json.GetJSONArray("data"); for (int index = 0; index < jsonArray.Length(); index++) { LevelCategory levelCategory = new LevelCategory(jsonArray.GetJSONObject(index).GetString("name")); var levelsData = jsonArray.GetJSONObject(index).GetJSONArray("levels"); for (int i = 0; i < levelsData.Length(); i++) { List<string> starExpressions = new List<string>(); var starArray = levelsData.GetJSONObject(i).GetJSONArray("star_expressions"); for (int y = 0; y < starArray.Length(); y++) { starExpressions.Add(starArray.GetString(y)); } Level level = new Level( levelsData.GetJSONObject(i).GetInt("id"), levelsData.GetJSONObject(i).GetString("initial_expression"), levelsData.GetJSONObject(i).GetInt("stars"), levelsData.GetJSONObject(i).GetString("current_expression"), starExpressions.ToArray()); levelCategory.Add(level); } categories.Add(levelCategory); } callback(categories); }
private void getMoviePosterPaths (string popularMovies, GridView view){ var pathsJson = new JSONObject(popularMovies); var pathArray = pathsJson.GetJSONArray("results"); paths.Clear(); for (var i = 0; i < pathArray.Length(); i++) { var posterPath = pathArray.GetJSONObject(i); paths.Add(posterPath.GetString("poster_path")); movieIds.Add(posterPath.GetInt("id")); } var imgAdapter = new ImageAdapter(Activity, paths, movieIds); view.Adapter = imgAdapter; }
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup layoutRoot = (ViewGroup)inflater.Inflate(Resource.Layout.fragment_data_form_json_edit, container, false); RadDataForm dataForm = new RadDataForm(Activity); String json = LoadJSONFromAsset ("Person.json"); try { JSONObject jsonObject = new JSONObject (json); dataForm.SetEntity(jsonObject); } catch(JSONException e) { Log.Error ("json", "error parsing json", e); } layoutRoot.AddView(dataForm); return layoutRoot; }
public void doOnMessageReceive(String message) { string me = GetString (Resource.String.on_message); me = me.Replace("%s", message); mGeneralStatus.Text = me; // mGeneralStatus.SetText(GetString(Resource.String.on_message, message)); // Parse custom JSON data string. // You can set background color with custom JSON data in the following format: { "r" : "10", "g" : "200", "b" : "100" } // Or open specific screen of the app with custom page ID (set ID in the { "id" : "2" } format) try { JSONObject messageJson = new JSONObject(message); JSONObject customJson = new JSONObject(messageJson.GetString("u")); if (customJson.Has("r") && customJson.Has("g") && customJson.Has("b")) { int r = customJson.GetInt("r"); int g = customJson.GetInt("g"); int b = customJson.GetInt("b"); Window.DecorView.FindViewById<View>(Android.Resource.Id.Content).SetBackgroundColor(Android.Graphics.Color.Rgb(r, g, b)); } if (customJson.Has("id")) { Intent intent = new Intent(this, typeof(SecondActivity)); intent.PutExtra(PushManager.PushReceiveEvent, messageJson.ToString()); StartActivity(intent); } } catch (JSONException e) { e.PrintStackTrace (); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // build post data for http request JSONObject postDataJSON = new JSONObject(); try { postDataJSON.Put("apiKey", GetString(1)); postDataJSON.Put("affId", GetString(2)); //don't have an affId yet postDataJSON.Put("transaction", "refillByScan"); postDataJSON.Put("act", "mweb5Url"); postDataJSON.Put("view", "mweb5UrlJSON"); postDataJSON.Put("devinf", "Android,2.3.3"); postDataJSON.Put("appver", "3.1"); } catch (JSONException e) { //(TAG, "error building json request", e); } // Create your application here }
List<Item> ParseJson(JSONObject json) { List<Item> result = new List<Item> (); try { JSONArray items = json.GetJSONArray(Constants.RecipeFieldList); for (int i = 0; i < items.Length(); i ++) { JSONObject item = items.GetJSONObject(i); Item parsed = new Item(); parsed.Name = item.GetString(Constants.RecipeFieldName); parsed.Title = item.GetString(Constants.RecipeFieldTitle); if (item.Has(Constants.RecipeFieldImage)) { String imageFile = item.GetString(Constants.RecipeFieldImage); parsed.Image = AssetUtils.LoadBitmapAsset(context, imageFile); } parsed.Summary = item.GetString(Constants.RecipeFieldSummary); result.Add(parsed); } } catch (Exception ex) { Log.Error (Tag, "Failed to parse recipe list: " + ex); } return result; }
public void OnCreateSuccess(SessionDescription origSdp) { outerInstance.RunOnUiThread(() => { outerInstance.logAndToast("Sending " + origSdp.Type); SessionDescription sdp = new SessionDescription(origSdp.Type, outerInstance.preferISAC(origSdp.Description)); JSONObject json = new JSONObject(); jsonPut(json, "type", sdp.Type.CanonicalForm()); jsonPut(json, "sdp", sdp.Description); outerInstance.sendMessage(json); outerInstance.pc.SetLocalDescription(outerInstance.sdpObserver, sdp); }); }
public void onMessage(string data) { try { JSONObject json = new JSONObject(data); string type = (string)json.Get("type"); if (type.Equals("candidate")) { IceCandidate candidate = new IceCandidate((string)json.Get("id"), json.GetInt("label"), (string)json.Get("candidate")); if (outerInstance.queuedRemoteCandidates != null) { outerInstance.queuedRemoteCandidates.AddLast(candidate); } else { outerInstance.pc.AddIceCandidate(candidate); } } else if (type.Equals("answer") || type.Equals("offer")) { SessionDescription sdp = new SessionDescription(SessionDescription.SessionDescriptionType.FromCanonicalForm(type), outerInstance.preferISAC((string)json.Get("sdp"))); outerInstance.pc.SetRemoteDescription(outerInstance.sdpObserver, sdp); } else if (type.Equals("bye")) { outerInstance.logAndToast("Remote end hung up; dropping PeerConnection"); outerInstance.disconnectAndExit(); } else { throw new Exception("Unexpected message: " + data); } } catch (JSONException e) { throw new Exception("Error", e); } }
public void OnIceCandidate(IceCandidate candidate) { outerInstance.RunOnUiThread(() => { JSONObject json = new JSONObject(); jsonPut(json, "type", "candidate"); jsonPut(json, "label", candidate.SdpMLineIndex); jsonPut(json, "id", candidate.SdpMid); jsonPut(json, "candidate", candidate.Sdp); outerInstance.sendMessage(json); }); }
// Put a |key|->|value| mapping in |json|. private static void jsonPut(JSONObject json, string key, Java.Lang.Object value) { try { json.Put(key, value); } catch (JSONException e) { throw new Exception("Error", e); } }
// Send |json| to the underlying AppEngine Channel. private void sendMessage(JSONObject json) { appRtcClient.sendMessage(json.ToString()); }
public static Question FromJSon (JSONObject questionObject, int questionIndex) { try { string question = questionObject.GetString (JsonUtils.JSON_FIELD_QUESTION); JSONArray answersJsonArray = questionObject.GetJSONArray (JsonUtils.JSON_FIELD_ANSWERS); string[] answers = new string[JsonUtils.NUM_ANSWER_CHOICES]; for (int j = 0; j < answersJsonArray.Length (); j++) { answers [j] = answersJsonArray.GetString (j); } int correctIndex = questionObject.GetInt (JsonUtils.JSON_FIELD_CORRECT_INDEX); return new Question (question, questionIndex, answers, correctIndex); } catch (JSONException) { return null; } }
private List<string> getMoveInfo(long movieId) { var httpClient = new HttpClient(); List<string> jsonValue = new List<string>(); Task<string> getJSON = httpClient.GetStringAsync("http://api.themoviedb.org/3/movie/"+movieId+"?api_key={Your API Key}"); var movieInfoStringBuilder = new StringBuilder(); movieInfoStringBuilder.Append( getJSON.Result); var JSONString = movieInfoStringBuilder.ToString(); try { JSONObject movieInfoJson = new JSONObject (JSONString); jsonValue.Add( movieInfoJson.GetString("original_title")); jsonValue.Add( movieInfoJson.GetString("poster_path")); jsonValue.Add(movieInfoJson.GetString("overview")); jsonValue.Add(movieInfoJson.GetString("vote_average")); jsonValue.Add(movieInfoJson.GetString("release_date")); } catch (Exception ex) { Log.Error("DetailActivityJSON",ex.Message); } return jsonValue; }
// Encrypt the receipts and save them to file. void ToCache(IList<Receipt> receipts) { OuyaFacade.Log("Caching receipts"); var json = new JSONObject(); var array = new JSONArray(); foreach (var receipt in receipts) { var r = new JSONObject(); r.Put("identifier", receipt.Identifier); r.Put("priceInCents", receipt.PriceInCents); r.Put("purchaseDate", receipt.PurchaseDate.ToGMTString()); r.Put("generatedDate", receipt.GeneratedDate.ToGMTString()); r.Put("gamerUuid", receipt.Gamer); r.Put("uuid", receipt.Uuid); array.Put(r); } json.Accumulate("receipts", array); var text = json.ToString(); var encryptedReceipts = CryptoHelper.Encrypt(text, _gamerUuid); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (var writer = new StreamWriter(store.OpenFile(receiptsFileName, FileMode.OpenOrCreate))) { writer.Write(encryptedReceipts); } } }
public Task <List<PolylineOptions>> Filling (string data) { return Task.Run(() => { var polyLineOptions = new PolylineOptions (); var ListPolylineOptions = new List<PolylineOptions>(); var jsonData = ""; jsonData = data; var jObject = new JSONObject (jsonData); var parser = new PathJsonParser (); var ListCoords = parser.parse (jObject); if(ListCoords.Count > 0){ for (int j = 0; j < ListCoords.Count; j++) { var listCoord = ListCoords[j]; foreach(var list in listCoord) { polyLineOptions.Add (list); } polyLineOptions.InvokeWidth (5); polyLineOptions.InvokeColor (Color.Red); } ListPolylineOptions.Add(polyLineOptions); } return ListPolylineOptions; }); }
/// <summary> /// Requests that the specified Purchasable be purchased on behalf of the current user. /// The IAP client service is responsible for identifying the user and requesting credentials as appropriate, /// as well as providing all of the UI for the purchase flow. When purchases are successful, a Product object /// is returned that describes the product that was purchased. /// </summary> /// <param name="product">The Purchasable object that describes the item to be purchased.</param> /// <returns>Returns true if the purchase was successful.</returns> public async Task<bool> RequestPurchaseAsync(Product product) { if (ReferenceEquals(product, null)) throw new ArgumentNullException("product"); var tcs = new TaskCompletionSource<bool>(); // Create the Purchasable object from the supplied product var sr = SecureRandom.GetInstance("SHA1PRNG"); // This is an ID that allows you to associate a successful purchase with // it's original request. The server does nothing with this string except // pass it back to you, so it only needs to be unique within this instance // of your app to allow you to pair responses with requests. var uniqueId = sr.NextLong().ToString("X"); JSONObject purchaseRequest = new JSONObject(); purchaseRequest.Put("uuid", uniqueId); purchaseRequest.Put("identifier", product.Identifier); var purchaseRequestJson = purchaseRequest.ToString(); byte[] keyBytes = new byte[16]; sr.NextBytes(keyBytes); var key = new SecretKeySpec(keyBytes, "AES"); byte[] ivBytes = new byte[16]; sr.NextBytes(ivBytes); var iv = new IvParameterSpec(ivBytes); Cipher cipher = Cipher.GetInstance("AES/CBC/PKCS5Padding", "BC"); cipher.Init(CipherMode.EncryptMode, key, iv); var payload = cipher.DoFinal(Encoding.UTF8.GetBytes(purchaseRequestJson)); cipher = Cipher.GetInstance("RSA/ECB/PKCS1Padding", "BC"); cipher.Init(CipherMode.EncryptMode, _publicKey); var encryptedKey = cipher.DoFinal(keyBytes); var purchasable = new Purchasable( product.Identifier, Convert.ToBase64String(encryptedKey, Base64FormattingOptions.None), Convert.ToBase64String(ivBytes, Base64FormattingOptions.None), Convert.ToBase64String(payload, Base64FormattingOptions.None)); var listener = new PurchaseListener(tcs, _publicKey, product, uniqueId); RequestPurchase(purchasable, listener); // No timeout for purchase as it shows a user dialog return await tcs.Task; }
protected override void OnNewIntent (Intent intent) { base.OnNewIntent (intent); var bundle = intent.Extras; var alarmOrigin = bundle.GetString ("alarmOrigin"); if (alarmOrigin == "Jpush") { var title = bundle.GetString (JPushInterface.ExtraNotificationTitle); var content = bundle.GetString (JPushInterface.ExtraAlert); var extras = bundle.GetString (JPushInterface.ExtraExtra); JSONObject extrasJson = new JSONObject(extras); alarmId = extrasJson.OptString("aid"); } else if(alarmOrigin == "alarmList") { alarmId = bundle.GetString ("alarmId");//报警id } LoadDetailData (); }
// Load the cached receipts from file and return the decrypted result. internal static IList<Receipt> FromCache(string gamerUuid) { OuyaFacade.Log("Returning cached receipts"); IList<Receipt> receipts = null; string encryptedReceipts = string.Empty; using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { if (store.FileExists(receiptsFileName)) { using (var reader = new StreamReader(store.OpenFile(receiptsFileName, FileMode.Open))) { encryptedReceipts = reader.ReadToEnd(); } } } if (!string.IsNullOrEmpty(encryptedReceipts)) { var decryptedReceipts = CryptoHelper.Decrypt(encryptedReceipts, gamerUuid); var json = new JSONObject(decryptedReceipts); var list = json.OptJSONArray("receipts"); if (list != null) { receipts = new List<Receipt>(list.Length()); for (int i = 0; i < list.Length(); ++i) { var node = list.GetJSONObject(i); var identifier = node.GetString("identifier"); var priceInCents = node.GetInt("priceInCents"); var purchaseDate = new Java.Util.Date(node.GetString("purchaseDate")); var generatedDate = new Java.Util.Date(node.GetString("generatedDate")); var gamer = node.GetString("gamerUuid"); var uuid = node.GetString("uuid"); // Cater for reading old receipts written with pre-1.0.8 double localPrice = priceInCents / 100.0; string currencyCode = "USD"; try { localPrice = node.GetDouble("localPrice"); currencyCode = node.GetString("currencyCode"); } catch (JSONException) { OuyaFacade.Log("Older receipt found. Assuming USD price."); } var receipt = new Receipt(identifier, priceInCents, purchaseDate, generatedDate, gamer, uuid, localPrice, currencyCode); receipts.Add(receipt); } } } // Return an empty list if nothing was found if (receipts == null) receipts = new List<Receipt>(); return receipts; }
private Weather CallbackResponse(string responseObj) { Weather weather = null; Org.Json.JSONObject weatherMain = new Org.Json.JSONObject(responseObj); Org.Json.JSONArray weatherArray = new Org.Json.JSONArray(); weatherArray.Put(weatherMain); for (int i = 0; i < weatherArray.Length(); i++) { try { Org.Json.JSONObject weatherObject = weatherArray.GetJSONObject(i); JSONObject objectLocation = weatherObject.GetJSONObject("location"); JSONObject objectCurrent = weatherObject.GetJSONObject("current"); //JSONObject objectrequest = objectCurrent.GetJSONObject("request"); //"request":{ "type":"City","query":"Tel Aviv-Yafo, Israel","language":"en","unit":"m"} weather = new Weather(); weather.setTemperature(objectCurrent.GetString("temperature")); weather.setDescription(objectCurrent.GetString("weather_descriptions")); weather.setWind_kph(objectCurrent.GetString("wind_speed")); string icon = objectCurrent.GetString("weather_icons"); icon = icon.Replace("[\"" + "https:\\/\\/assets", @"https://assets"); icon = icon.Replace("[", ""); icon = icon.Replace("]", ""); icon = icon.Replace("\"", ""); icon = icon.Replace(@"\/", "//"); icon = icon.Replace(@"\\", "//"); //Android.Net.Uri uri = Android.Net.Uri.Parse(icon); //Android.Net.Uri uri = Android.Net.Uri.Parse(icon); //icon = uri.Path; //icon = uri.AbsolutePath; weather.setPoster(icon); weather.setIs_day(objectCurrent.GetString("is_day").ToString()); weather.setCloud(objectCurrent.GetString("cloudcover")); weather.setLast_update(objectLocation.GetString("localtime")); weather.setCountry(objectLocation.GetString("country")); icon = objectLocation.GetString("name").Trim(); icon = icon.Replace(@"[", ""); icon = icon.Replace("[", ""); icon = icon.Replace(@"]", ""); icon = icon.Replace("]", ""); icon = icon.Replace("\"", ""); icon = icon.Replace("\"", ""); icon = icon.Replace("[\"", ""); //icon = icon.Replace('\'', (char)32); weather.setCity(icon.Trim()); // "type":"City","query":"Tel Aviv-Yafo, Israel" weather.setRegion(objectLocation.GetString("region")); weather.setLocal_time(objectLocation.GetString("localtime")); weather.setTz_id(objectLocation.GetString("timezone_id")); //"localtime_epoch":1583177400,"utc_offset":"2.0" //wind_degree":311,"wind_dir":"NW","pressure":1021,"precip":0,"humidity":60,"cloudcover":7,"feelslike":17 try { //weather.setImageView(Utils.GetImageViewFromhUrl(weather.getPoster())); //weather.setImageView(new ImageView(Application.Context)); //Android.Net.Uri uri = Android.Net.Uri.Parse(weather.getPoster()); //weather.getImageView().SetImageURI(uri); } catch { } if (WeatherList.Count < 4) { WeatherList.Add(weather); } else { WeatherList[currentListIndex] = weather; } } catch (JSONException ex) { MH_Utils.Utils.WriteToLog(ex.Message); //Log.d("Error: ", ex.getMessage()); //ex.printStackTrace(); } } return(weather); }
/*Consumiendo servicio*/ /* * public void mClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { //Cargando la informacion * * RunOnUiThread(() => * { * string json = Encoding.UTF8.GetString(e.Result); * usuarios = JsonConvert.DeserializeObject<List<Usuario>>(json); * Toast.MakeText(this, "Informacion cargada ", ToastLength.Long).Show(); * // Console.ReadKey(); * }); * * } */ public void OnCompleted(Org.Json.JSONObject json, GraphResponse response) { string data = json.ToString(); FacebookResult result = JsonConvert.DeserializeObject <FacebookResult>(data); }
public void OnFailure (JSONObject jsonObject) { Dictionary<string, object> dict = null; if (jsonObject != null) dict = Json.Deserialize (jsonObject.ToString ()) as Dictionary<string, object>; OneSignal.onPostNotificationFailed (dict); }
// Encrypt the receipts and save them to file. static void ToCache(IList<Receipt> receipts, string gamerUuid) { OuyaFacade.Log("Caching receipts"); var json = new JSONObject(); var array = new JSONArray(); foreach (var receipt in receipts) { var r = new JSONObject(); r.Put("identifier", receipt.Identifier); // PriceInCents is now deprecated. Use LocalPrice and CurrencyCode instead. // Retain field for compatibility. r.Put("priceInCents", 0); r.Put("purchaseDate", receipt.PurchaseDate.ToGMTString()); r.Put("generatedDate", receipt.GeneratedDate.ToGMTString()); r.Put("gamerUuid", receipt.Gamer); r.Put("uuid", receipt.Uuid); r.Put("localPrice", receipt.LocalPrice); r.Put("currencyCode", receipt.Currency); array.Put(r); } json.Accumulate("receipts", array); var text = json.ToString(); var encryptedReceipts = CryptoHelper.Encrypt(text, gamerUuid); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (var writer = new StreamWriter(store.OpenFile(receiptsFileName, FileMode.OpenOrCreate))) { writer.Write(encryptedReceipts); } } }
private TimeSpan JsonToTimeSpan(JSONObject time) { var days = time.GetInt("days"); var hours = time.GetInt("hours"); var minutes = time.GetInt("minutes"); var seconds = time.GetInt("seconds"); var milliseconds = time.GetInt("milliseconds"); return new TimeSpan(days, hours, minutes, seconds, milliseconds); }
IList<Receipt> ReceiptsFromResponse(string receiptsResponse) { IList<Receipt> receipts = null; using (var helper = new OuyaEncryptionHelper()) { using (var response = new JSONObject(receiptsResponse)) { OuyaFacade.Log("Decrypting receipts response"); receipts = helper.DecryptReceiptResponse(response, _publicKey); } } return receipts; }
JSONObject getJsonObject(String name,String type,double count) { JSONObject obj= new JSONObject(); obj.Put ("Name", name); obj.Put ("Type", type); return obj; }
// Load the cached receipts from file and return the decrypted result. IList<Receipt> FromCache() { OuyaFacade.Log("Returning cached receipts"); IList<Receipt> receipts = null; string encryptedReceipts = string.Empty; using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { if (store.FileExists(receiptsFileName)) { using (var reader = new StreamReader(store.OpenFile(receiptsFileName, FileMode.Open))) { encryptedReceipts = reader.ReadToEnd(); } } } if (!string.IsNullOrEmpty(encryptedReceipts)) { var decryptedReceipts = CryptoHelper.Decrypt(encryptedReceipts, _gamerUuid); var json = new JSONObject(decryptedReceipts); var list = json.OptJSONArray("receipts"); if (list != null) { receipts = new List<Receipt>(list.Length()); for (int i = 0; i < list.Length(); ++i) { var node = list.GetJSONObject(i); var identifier = node.GetString("identifier"); var priceInCents = node.GetInt("priceInCents"); var purchaseDate = new Java.Util.Date(node.GetString("purchaseDate")); var generatedDate = new Java.Util.Date(node.GetString("generatedDate")); var gamerUuid = node.GetString("gamerUuid"); var uuid = node.GetString("uuid"); var receipt = new Receipt(identifier, priceInCents, purchaseDate, generatedDate, gamerUuid, uuid); receipts.Add(receipt); } } } return receipts; }