private void FilterSwitch_Toggled(object sender, RoutedEventArgs e) { if (!FilterSwitch.IsOn) { listView.Items.Clear(); RequestHandle handler = new RequestHandle(); string res = Task.Run(() => handler.incoming(p.id)).Result; if (res != null) { while (res.IndexOf("senderPhoneNum") != -1 && res.IndexOf("},") != -1) { int num = res.IndexOf("senderPhoneNum") + 17; Person name = Task.Run(() => handler.lookup(res.Substring(num, 10))).Result; num = res.IndexOf("amount") + 9; string ams = res.Substring(num, 4); num = res.IndexOf("id") + 5; listView.Items.Add("From: " + name.name + "\nAmount: " + ams + "\nTransfer Id: " + res.Substring(num, 24)); res = res.Substring(res.IndexOf("},")); res = res.Remove(0, 2); } } } else { listView.Items.Clear(); RequestHandle handler = new RequestHandle(); string res = Task.Run(() => handler.outgoing(p.id)).Result; if (res != null) { while (res.IndexOf("senderPhoneNum") != -1 && res.IndexOf("},") != -1) { int num = res.IndexOf("senderPhoneNum") + 17; Person name = Task.Run(() => handler.lookup(res.Substring(num, 10))).Result; num = res.IndexOf("amount") + 9; string ams = res.Substring(num, 4); num = res.IndexOf("id") + 5; listView.Items.Add("From: " + name.name + "\nAmount: " + ams + "\nTransfer Id: " + res.Substring(num, 24)); res = res.Substring(res.IndexOf("},")); res = res.Remove(0, 2); } } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { p = e.Parameter as Person; listView.Items.Clear(); RequestHandle handler = new RequestHandle(); string res = Task.Run(() => handler.incoming(p.id)).Result; if (res != null) { while (res.IndexOf("senderPhoneNum") != -1 && res.IndexOf("},") != -1) { int num = res.IndexOf("senderPhoneNum") + 17; Person name = Task.Run(() => handler.lookup(res.Substring(num, 10))).Result; num = res.IndexOf("amount") + 9; string ams = res.Substring(num, 4); num = res.IndexOf("id") + 5; listView.Items.Add("From: " + name.name + "\nAmount: " + ams + "\nTransfer Id: "+ res.Substring(num, 24)); res = res.Substring(res.IndexOf("},")); res = res.Remove(0, 2); } } }