private void FlushData() { try { if (mbtSocket != null) { mbtSocket.Close(); mbtSocket = null; } if (mBluetoothAdapter != null) { mBluetoothAdapter.CancelDiscovery(); } if (btDevices != null) { btDevices.Clear(); btDevices = null; } if (mArrayAdapter != null) { mArrayAdapter.Clear(); mArrayAdapter.NotifyDataSetChanged(); mArrayAdapter.NotifyDataSetInvalidated(); mArrayAdapter = null; } Finish(); } catch (Exception ex) { } }
public override void OnReceive(Context context, Intent intent) { String action = intent.Action; if (BluetoothDevice.ActionFound.Equals(action)) { BluetoothDevice device = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice); try { if (btDevices == null) { btDevices = new ArrayAdapter <BluetoothDevice>(Application.Context, Resource.Layout.layout_list); } if (btDevices.GetPosition(device) < 0) { btDevices.Add(device); mArrayAdapter.Add(device.Name + "\n" + device.Address + "\n"); mArrayAdapter.NotifyDataSetInvalidated(); } } catch (Exception ex) { //ex.fillInStackTrace(); } } }
// ReSharper disable once MemberCanBePrivate.Global protected void FilterContacts() { friendListAdapter.Clear(); picker.FilterContacts(searchEditText.Text); foreach (var name in picker.Names) { friendListAdapter.Add(name); } friendListAdapter.NotifyDataSetInvalidated(); }
protected override void OnStart() { NotifyService.OnServiceStart = new Action(() => { RunOnUiThread(() => { streamerListAdapter = new ArrayAdapter <StreamerData>(this, Android.Resource.Layout.SimpleListItem1, NotifyService.Detector.Streamers); streamerListView.Adapter = streamerListAdapter; }); }); NotifyService.OnCheckPerformed = new Action(() => { RunOnUiThread(() => { if (streamerListAdapter != null) { streamerListAdapter.NotifyDataSetInvalidated(); } }); }); var leftStr = GetString(Resource.String.left_second_for_refresh); NotifyService.OnTimeChanged = new Action <int>((time) => { RunOnUiThread(() => { if (leftTimeTextView != null) { switch (time) { case NotifyService.TIME_IN_REFRESH: leftTimeTextView.Text = GetString(Resource.String.left_second_for_refresh_in_refresh); break; case NotifyService.TIME_NO_ACTIVE_STREAMER: leftTimeTextView.Text = GetString(Resource.String.no_active_streamer); break; case NotifyService.TIME_WAIT_FOR_STREAMER: leftTimeTextView.Text = GetString(Resource.String.wait_read_streamer_list); break; case NotifyService.TIME_WAIT_FOR_TOKEN: leftTimeTextView.Text = GetString(Resource.String.wait_token); break; default: leftTimeTextView.Text = leftStr.Replace("/TIME/", time.ToString()); break; } } }); }); NotifyService.AskAuthHandler += new Func <bool>(() => { bool?result = null; RunOnUiThread(() => { var builder = new Android.Support.V7.App.AlertDialog.Builder(this); builder.SetTitle(Resource.String.app_name); builder.SetMessage(Resource.String.ask_for_twitch_login); builder.SetPositiveButton(Resource.String.yes, (ev, ct) => { result = true; }); builder.SetNegativeButton(Resource.String.no, (ev, ct) => { result = false; Finish(); }); builder.SetCancelable(false); builder.Show(); }); while (!result.HasValue) { } return(result.Value); }); StartService(new Android.Content.Intent(this, typeof(NotifyService))); base.OnStart(); }