Ejemplo n.º 1
0
            public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
            {
                base.OnCreateView(inflater, container, savedInstanceState);

                var view = inflater.Inflate(Resource.Layout.uTorrent_Main, container, false);

                _listView = view.FindViewById<ListView>(Resource.Id.utorrent_downloads);

                _dataAdapter = new TorrentDownloadDataAdapter(Activity, SharedServices.Torrent.TorrentService.GetDownloadItems(SharedPreferencesManager.App.Token).ToArray());
                
                _listView.Adapter = _dataAdapter;

                Task.Run(async () => await GetData());

                return view;
            }
Ejemplo n.º 2
0
            private async Task GetData()
            {
                while (!_tokenSource.Token.IsCancellationRequested)
                {
                    _dataAdapter = new TorrentDownloadDataAdapter(Activity,
                            SharedServices.Torrent.TorrentService.GetDownloadItems(SharedPreferencesManager.App.Token)
                                .ToArray());

                    Activity.RunOnUiThread(() =>
                    {
                        _listView.Adapter = _dataAdapter;
                        (_listView.Adapter as TorrentDownloadDataAdapter).NotifyDataSetChanged();
                    });
                    
                    await Task.Delay(TimeSpan.FromSeconds(3), _tokenSource.Token);
                }
            }