internal async void Refresh() { _adapter.FireSyncStatusChanged(MyClipsAdapter.ViewHolder.SyncStatus.DOWNLOADING, 0); try { cancel = new CancellationTokenSource(); var info = await Bootlegger.BootleggerClient.GetEventInfo(Bootlegger.BootleggerClient.CurrentEvent.id, new System.Threading.CancellationToken()); OnEventInfoUpdate?.Invoke(info); await Bootlegger.BootleggerClient.GetMyMedia(cancel.Token); //if I can edit everyones media: if (Bootlegger.BootleggerClient.CurrentEvent.publicedit) { //load everyones media: Bootlegger.BootleggerClient.GetEveryonesMedia(cancel.Token); } _adapter.UpdateData(Bootlegger.BootleggerClient.UploadQueueEditing, Bootlegger.BootleggerClient.MyMediaEditing); _adapter.FireSyncStatusChanged(MyClipsAdapter.ViewHolder.SyncStatus.OK, 0); OnRefresh?.Invoke(); } catch (TaskCanceledException) { //do nothing, moving screens } catch (Exception e) { try { LoginFuncs.ShowError(Activity, e); _adapter.FireSyncStatusChanged(MyClipsAdapter.ViewHolder.SyncStatus.OK, 0); } catch { //fails as the fragment is lost. } } finally { //if not waiting for everyones media to download: //_adapter.FireSyncStatusChanged(MyClipsAdapter.ViewHolder.SyncStatus.OK,0); } }
public override void OnResume() { base.OnResume(); Bootlegger.BootleggerClient.OnMediaLoadingComplete += BootleggerClient_OnMediaLoadingComplete; RefreshUploads(); //Bootlegger.BootleggerClient.OnMoreMediaLoaded += BootleggerClient_OnMoreMediaLoaded; var listView = theview.FindViewById <RecyclerView>(Resource.Id.myclips); if (firstload) { firstload = false; //show summary of the data: if (!doing_work) { doing_work = true; _adapter.FireSyncStatusChanged(MyClipsAdapter.ViewHolder.SyncStatus.SYNCING, 0); theview.Post(async() => { try { var info = await Bootlegger.BootleggerClient.GetEventInfo(Bootlegger.BootleggerClient.CurrentEvent.id, new System.Threading.CancellationToken()); OnEventInfoUpdate?.Invoke(info); var mediahave = Bootlegger.BootleggerClient.MyMediaEditing.Count; //update ui: if (info.numberofclips > mediahave) { //if can see the clips: if (Bootlegger.BootleggerClient.CurrentEvent.publicedit) { //if (Bootlegger.publicedit || ) _adapter.FireSyncStatusChanged(MyClipsAdapter.ViewHolder.SyncStatus.MISSING, (info.numberofclips - mediahave)); } else { _adapter.FireSyncStatusChanged(MyClipsAdapter.ViewHolder.SyncStatus.OK, 0); } } else { _adapter.FireSyncStatusChanged(MyClipsAdapter.ViewHolder.SyncStatus.OK, 0); } doing_work = false; } catch (Exception e) { try { if ((Context.ApplicationContext as BootleggerApp).IsReallyConnected) { LoginFuncs.ShowError(Context, e); } _adapter.FireSyncStatusChanged(MyClipsAdapter.ViewHolder.SyncStatus.OK, 0); } catch { //unknown error... } } }); } } }