private async void Newtag_Click(object sender, EventArgs e) { if ((Application as BootleggerApp).IsReallyConnected) { AndHUD.Shared.Show(this, GetText(Resource.String.connecting), -1, MaskType.Black, null, null, true); try { await Bootlegger.BootleggerClient.Connect(Bootlegger.BootleggerClient.SessionCookie, new System.Threading.CancellationTokenSource().Token); Intent i = new Intent(this, typeof(Ingest)); i.PutExtra(EDIT, ""); StartActivityForResult(i, INGEST); Bootlegger.BootleggerClient.CanUpload = false; } catch (Exception ex) { LoginFuncs.ShowError(this, ex); } finally { AndHUD.Shared.Dismiss(); } } else { LoginFuncs.ShowError(this, new NoNetworkException()); } }
public override async void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); view.FindViewById <ImageButton>(Resource.Id.closebtn).Click += MusicDialog_Click; try { List <Music> music = await Bootlegger.BootleggerClient.GetMusic(); listAdapter = new MusicAdapter(CurrentMusic); listAdapter.OnPreview += ListAdapter_OnPreview; listAdapter.OnSelected += ListAdapter_OnSelected; var listview = view.FindViewById <RecyclerView>(Resource.Id.listview); listview.SetAdapter(listAdapter); listview.SetLayoutManager(new LinearLayoutManager(Activity)); listview.AddItemDecoration(new Android.Support.V7.Widget.DividerItemDecoration(Activity, Android.Support.V7.Widget.DividerItemDecoration.Vertical)); listAdapter.Update(music); } catch (Exception e) { //dismiss dialog LoginFuncs.ShowError(Activity, e); Dismiss(); } }
private async void Popup_MenuItemClick(object sender, Android.Support.V7.Widget.PopupMenu.MenuItemClickEventArgs e) { //if (e.Item.ItemId == Resource.Id.share_menu_item) //ViewHolder_Click(null, null); //if (e.Item.ItemId == Resource.Id.restart_menu_item) // ViewHolder_Click2(null, null); if (e.Item.ItemId == Resource.Id.copy_menu_item) { try { var newedit = new Edit() { media = currentedit.media, title = view.Context.GetString(Resource.String.copyof, currentedit.title), user_id = currentedit.user_id }; await Bootlegger.BootleggerClient.SaveEdit(newedit); //refresh list: adpt.OnRefresh?.Invoke(); } catch (Exception ex) { LoginFuncs.ShowError(view.Context, ex); } } if (e.Item.ItemId == Resource.Id.delete_menu_item) { ViewHolder_Click1(null, null); } }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (data?.GetBooleanExtra("needsperms", false) ?? false && requestCode == VIDEOCAP) { LoginFuncs.ShowError(this, new NeedsPermissionsException()); } if (requestCode == EDIT_RESPONSE) { //coming back from edit, if it has been processed, show message if (data != null && data.GetBooleanExtra("processed", false)) { Toast.MakeText(this, Resource.String.editready, ToastLength.Long).Show(); //jump to edits tab: } _pager.SetCurrentItem(2, false); myedits.Refresh(); } if (requestCode == VIDEOCAP) { //refresh uploads list: myclips.RefreshUploads(); } if (requestCode == INGEST) { //myingest.Refresh(); //myingest.ChooserMode = AllClipsFragment.ClipViewMode.INGEST; myingest.Refresh(); } }
private async void _adapter_OnRestart(Edit obj) { AndHUD.Shared.Show(Activity, Resources.GetString(Resource.String.connecting), -1, MaskType.Black); try { cancel = new CancellationTokenSource(); await LoginFuncs.TryLogin(Activity, cancel.Token); await Bootlegger.BootleggerClient.RestartEdit(obj); _adapter.UpdateData(Bootlegger.BootleggerClient.MyEdits, true); _adapter.NotifyDataSetChanged(); } catch (TaskCanceledException) { //do nothing } catch (Exception e) { LoginFuncs.ShowError(Context, e); } finally { AndHUD.Shared.Dismiss(); } }
private void BootleggerClient_OnCurrentUploadsFailed() { //reset UI: RunOnUiThread(() => { LoginFuncs.ShowError(this, new NoNetworkException()); myclips.RefreshUploads(); }); }
void SettingsFrag_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e) { try { Bootlegger.BootleggerClient.SetUserPrivacy(e.IsChecked, Bootlegger.BootleggerClient.CurrentEvent.id); } catch (Exception ex) { LoginFuncs.ShowError(Context, ex); } }
private void HomePageList_Click(object sender, EventArgs e) { if ((Context.ApplicationContext as BootleggerApp).IsReallyConnected) { var intent = new Intent(Context, typeof(Events)); intent.PutExtra("listtype", "all"); StartActivityForResult(intent, UI.LoginFuncs.NEW_SHOOT_REQUEST); } else { LoginFuncs.ShowError(Activity, new NoNetworkException()); } }
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 OnBackPressed() { try { if (TRIMMODE) { TRIMMODE = false; _adapter.TrimMode(null, false); preview.StopPlayback(); _adapter.UpdatePlaying(null); TrimOff(); return; } if (IsExpanded) { currentpick = null; CollapsePane(); (allclipsfragment as IImagePausable).Pause(); } else { Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(this); builder.SetMessage(Resource.String.savecancelmsg); builder.SetPositiveButton(Resource.String.savebtnshort, (e, o) => { ExitSave(); }) .SetNegativeButton(Resource.String.cancelbtn, async(e, o) => { //Reset back to old version: //CurrentEdit = OriginalVersion; ShouldAutoSave = false; await Bootlegger.BootleggerClient.SaveEdit(OriginalVersion); autosaver.Dispose(); Finish(); }); builder.Create().Show(); } } catch (Exception e) { LoginFuncs.ShowError(this, e); } }
private async void CaptureClick(object sender, EventArgs e) { var Event = Bootlegger.BootleggerClient.CurrentEvent; cancel = new CancellationTokenSource(); AndHUD.Shared.Show(this, Resources.GetString(Resource.String.connecting), -1, MaskType.Black, null, null, true, cancel.Cancel); try { await Bootlegger.BootleggerClient.OfflineConnect(Event.id, cancel.Token); StartActivityForResult(typeof(Video), VIDEOCAP); Bootlegger.BootleggerClient.CanUpload = false; } catch (RoleNotSelectedException) { //connect and start the role screen.... //only do this if we are actually online: if ((Application as BootleggerApp).IsReallyConnected) { cancel = new CancellationTokenSource(); //start roles screen: Intent i = new Intent(this, typeof(Roles)); i.PutExtra("id", Event.id); StartActivityForResult(i, 0); Bootlegger.BootleggerClient.CanUpload = false; } else { LoginFuncs.ShowError(this, new RoleNotSelectedException()); //Toast.MakeText(this, Resource.String.norolechosen, ToastLength.Long).Show(); } } catch (Exception ex) { LoginFuncs.ShowError(this, ex); //Toast.MakeText(this, Resource.String.noconnectionshort, ToastLength.Long).Show(); } finally { AndHUD.Shared.Dismiss(); } //} }
private async void HomePageList_Refresh(object sender, EventArgs e) { try { View.FindViewById <SwipeRefreshLayout>(Resource.Id.swiperefresh).Refreshing = false; //refresh featured: if ((Context.ApplicationContext as BootleggerApp).IsReallyConnected) { await nearby.RefreshMe(true); } } catch (Exception ex) { LoginFuncs.ShowError(Activity, ex); } finally { } }
async void Events_Refresh(object sender, EventArgs e) { try { try { await updater(canceller); } catch (TaskCanceledException) { //do nothing... } catch (Exception) { OnError?.Invoke(new Exception(Resources.GetString(Resource.String.noconnectionshort))); } if (parent == null) { LoadEvents(Bootlegger.BootleggerClient.GetType().GetProperty(propertyname).GetValue(Bootlegger.BootleggerClient) as List <Shoot>, null, eventviewtype); } else { LoadEvents((Bootlegger.BootleggerClient.GetType().GetProperty(propertyname).GetValue(Bootlegger.BootleggerClient) as List <Shoot>).Find(ec => ec.group == parent.group).events, parent, eventviewtype); } } catch (Exception ex) { try { LoginFuncs.ShowError(Activity, ex); } catch { //failed if fragment destroyed } } finally { theview.FindViewById <SwipeRefreshLayout>(Resource.Id.swiperefresh).Refreshing = false; } }
private void ListAdapter_OnPreview(Music obj) { listAdapter.UpdatePlaying(obj); currentPreview = obj; _audioPlayer.PlayWhenReady = false; mediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(obj.url), httpDataSourceFactory, extractorsFactory, null, null); try { _audioPlayer.Prepare(mediaSource); _audioPlayer.PlayWhenReady = true; } catch (Exception e) { LoginFuncs.ShowError(Context.ApplicationContext, e); } Bootlegger.BootleggerClient.LogUserAction("MusicPreview", new KeyValuePair <string, string>("music", obj.url), new KeyValuePair <string, string>("eventid", Bootlegger.BootleggerClient.CurrentEvent.id)); }
public bool IsPlayServicesAvailable() { int resultCode = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.Success) { if (GoogleApiAvailability.Instance.IsUserResolvableError(resultCode)) { LoginFuncs.ShowError(this, new Exception(GoogleApiAvailability.Instance.GetErrorString(resultCode))); } else { //msgText.Text = "This device is not supported"; LoginFuncs.ShowError(this, new Exception(GetString(Resource.String.googleplayerror))); Finish(); } return(false); } else { return(true); } }
public void OnError() { View.FindViewById(Resource.Id.mapprogress).Visibility = ViewStates.Gone; LoginFuncs.ShowError(Context, new UnknownNetworkException()); }
void CheckUpload() { try { if ((Application as BootleggerApp).IsReallyConnected) { if (CrossConnectivity.Current.ConnectionTypes.Contains(Plugin.Connectivity.Abstractions.ConnectionType.WiFi)) { // Do whatever new Android.Support.V7.App.AlertDialog.Builder(this).SetMessage(Resource.String.deleteclipwarning) .SetNegativeButton(Android.Resource.String.Cancel, new EventHandler <DialogClickEventArgs>((oe, eo) => { //do nothing... })) .SetPositiveButton(Resource.String.continueanyway, new EventHandler <DialogClickEventArgs>(async(oe, eo) => { try { await LoginFuncs.TryLogin(this, cancel.Token); //await Bootlegger.BootleggerClient.OfflineConnect(Bootlegger.BootleggerClient.CurrentEvent.id); Bootlegger.BootleggerClient.CanUpload = true; oktocontinueon3g = false; //myclips.Redraw(); FindViewById <Button>(Resource.Id.uploadbtn).Text = Resources.GetString(Resource.String.pause); receiver.LostWifi += Receiver_LostWifi; receiver.GotWifi += Receiver_GotWifi; } catch (Exception e) { LoginFuncs.ShowError(this, e); } })) .SetTitle(Resource.String.continuetitle) .SetCancelable(false) .Show(); } else { new Android.Support.V7.App.AlertDialog.Builder(this).SetMessage(Resource.String.datachargewithwarning) .SetNegativeButton(Resource.String.notnow, new EventHandler <DialogClickEventArgs>((oe, eo) => { //do nothing... })) .SetPositiveButton(Resource.String.continueanyway, new EventHandler <DialogClickEventArgs>(async(oe, eo) => { try { oktocontinueon3g = true; //await connection: await LoginFuncs.TryLogin(this, cancel.Token); //await Bootlegger.BootleggerClient.OfflineConnect(Bootlegger.BootleggerClient.CurrentEvent.id); Bootlegger.BootleggerClient.CanUpload = true; //myclips.Redraw(); FindViewById <Button>(Resource.Id.uploadbtn).Text = Resources.GetString(Resource.String.pause); receiver.LostWifi += Receiver_LostWifi; receiver.GotWifi += Receiver_GotWifi; } catch (Exception e) { LoginFuncs.ShowError(this, e); } })) .SetTitle(Resource.String.continuetitle) .SetCancelable(false) .Show(); } } else { LoginFuncs.ShowError(this, new NoNetworkException()); } } catch (Exception e) { LoginFuncs.ShowError(this, e); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if (Bootlegger.BootleggerClient.CurrentEvent == null) { Finish(); return; } CurrentEvent = Bootlegger.BootleggerClient.CurrentEvent; SetTheme(Resource.Style.Theme_Normal); SetContentView(Resource.Layout.Review); //AndHUD.Shared.Show(this, Resources.GetString(Resource.String.loading), -1, MaskType.Black, null, null, true); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); Window.ClearFlags(WindowManagerFlags.TranslucentStatus); if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop) { // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); // finally change the color Window.SetStatusBarColor(new Color(ContextCompat.GetColor(this, Android.Resource.Color.Transparent))); } //FindViewById<TextView>(Resource.Id.customTitle).Text = CurrentEvent.name; FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetTitle(CurrentEvent.name); FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetExpandedTitleTextAppearance(Resource.Style.ExpandedAppBar); Typeface font = ResourcesCompat.GetFont(this, Resource.Font.montserratregular); FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).CollapsedTitleTypeface = font; FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).ExpandedTitleTypeface = font; FindViewById <AppBarLayout>(Resource.Id.appbar).SetExpanded(false, false); //if (!string.IsNullOrEmpty(CurrentEvent.iconbackground) && !WhiteLabelConfig.REDUCE_BANDWIDTH) // Picasso.With(this).Load(CurrentEvent.iconbackground).CenterCrop().Fit().MemoryPolicy(MemoryPolicy.NoCache, MemoryPolicy.NoStore).Tag(this).Into(FindViewById<ImageView>(Resource.Id.defaultback), new Action(() => // { // var bitmap = ((BitmapDrawable)FindViewById<ImageView>(Resource.Id.defaultback).Drawable).Bitmap; // Palette palette = Palette.From(bitmap).Generate(); // int vibrant = palette.GetLightVibrantColor(0); // if (vibrant == 0) // vibrant = palette.GetMutedColor(0); // int dark = palette.GetVibrantColor(0); // if (dark == 0) // dark = palette.GetLightMutedColor(0); // //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetContentScrimColor(vibrant); // //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetStatusBarScrimColor(dark); // }), null); //else //{ //Picasso.With(this).Load(Resource.Drawable.user_back).CenterCrop().Fit().Into(FindViewById<ImageView>(Resource.Id.defaultback)); //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetContentScrimColor(Color.Transparent); //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetStatusBarScrimColor(dark); //} FindViewById <TextView>(Resource.Id.organisedby).Text = CurrentEvent.organisedby; Picasso.With(this).Load(CurrentEvent.organiserprofile.Replace("sz=50", "")).Tag(this).Fit().Transform(new CircleTransform()).Into(FindViewById <ImageView>(Resource.Id.imgGravatar)); FindViewById <TextView>(Resource.Id.contributors).Text = Java.Lang.String.Format("%d", CurrentEvent.numberofcontributors); FindViewById <TextView>(Resource.Id.contributions).Text = Java.Lang.String.Format("%d", CurrentEvent.numberofclips); _pager = FindViewById <ViewPager>(Resource.Id.tabpager); capture = FindViewById <FloatingActionButton>(Resource.Id.capture); newedit = FindViewById <FloatingActionButton>(Resource.Id.newedit); newtag = FindViewById <FloatingActionButton>(Resource.Id.newtag); capture.Click += CaptureClick; newedit.Click += Review_Click; newtag.Click += Newtag_Click; var dip16 = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 16, Resources.DisplayMetrics); capture.LayoutParameters = new CoordinatorLayout.LayoutParams(capture.LayoutParameters) { Behavior = new MyFABAwareScrollingViewBehavior(this, capture, 0, _pager), Gravity = (int)(GravityFlags.End | GravityFlags.Right | GravityFlags.Bottom), MarginEnd = dip16, BottomMargin = dip16 }; newtag.LayoutParameters = new CoordinatorLayout.LayoutParams(newtag.LayoutParameters) { Behavior = new MyFABAwareScrollingViewBehavior(this, newtag, 1, _pager), Gravity = (int)(GravityFlags.End | GravityFlags.Right | GravityFlags.Bottom), MarginEnd = dip16, BottomMargin = dip16 }; newedit.LayoutParameters = new CoordinatorLayout.LayoutParams(newedit.LayoutParameters) { Behavior = new MyFABAwareScrollingViewBehavior(this, newedit, 2, _pager), Gravity = (int)(GravityFlags.End | GravityFlags.Right | GravityFlags.Bottom), MarginEnd = dip16, BottomMargin = dip16 }; _tabs = FindViewById <Android.Support.Design.Widget.TabLayout>(Resource.Id.tabs); _tabs.TabGravity = 0; _tabs.TabMode = 1; _adapter = new ReviewPageAdapter(SupportFragmentManager, this); _pager.Adapter = _adapter; if (savedInstanceState == null) { myclips = new MyClipsFragment(this); myclips.OnPreview += Myclips_OnPreview; myclips.OnRefresh += Myclips_OnRefresh; myclips.OnEventInfoUpdate += Myclips_OnEventInfoUpdate; myclips.OnStartUpload += Myclips_OnStartUpload; myedits = new MyEditsFragment(); myedits.OnOpenEdit += Myedits_OnOpenEdit; myedits.OnPreview += Myedits_OnPreview; myingest = new AllClipsFragment(AllClipsFragment.ClipViewMode.LIST); myingest.OnPreview += Myingest_OnPreview; } else { myclips = SupportFragmentManager.FindFragmentByTag("android:switcher:" + Resource.Id.tabpager + ":0") as MyClipsFragment; myclips.OnPreview += Myclips_OnPreview; myclips.OnRefresh += Myclips_OnRefresh; myclips.OnEventInfoUpdate += Myclips_OnEventInfoUpdate; myclips.OnStartUpload += Myclips_OnStartUpload; myingest = SupportFragmentManager.FindFragmentByTag("android:switcher:" + Resource.Id.tabpager + ":1") as AllClipsFragment; myingest.ChooserMode = AllClipsFragment.ClipViewMode.LIST; myingest.OnPreview += Myingest_OnPreview; myedits = SupportFragmentManager.FindFragmentByTag("android:switcher:" + Resource.Id.tabpager + ":2") as MyEditsFragment; if (myedits == null) { myedits = new MyEditsFragment(); } myedits.OnOpenEdit += Myedits_OnOpenEdit; myedits.OnPreview += Myedits_OnPreview; } //myedits.Reattach(); _adapter.AddTab(GetString(Resource.String.videos), myclips, ReviewPageAdapter.TabType.CLIPS); _adapter.AddTab(GetString(Resource.String.tagging), myingest, ReviewPageAdapter.TabType.INGEST); _adapter.AddTab(GetString(Resource.String.edits), myedits, ReviewPageAdapter.TabType.EDITS); _pager.Post(() => { _tabs.SetupWithViewPager(_pager); }); _pager.PageSelected += _pager_PageSelected; if (Intent?.GetBooleanExtra("needsperms", false) ?? false) { LoginFuncs.ShowError(this, new NeedsPermissionsException()); } }
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... } } }); } } }
private async void Myedits_OnOpenEdit(Edit obj) { cancel = new CancellationTokenSource(); AndHUD.Shared.Show(this, Resources.GetString(Resource.String.connecting), -1, MaskType.Black, null, null, true, () => { cancel.Cancel(); }); if ((Application as BootleggerApp).IsReallyConnected && !CrossConnectivity.Current.ConnectionTypes.Contains(Plugin.Connectivity.Abstractions.ConnectionType.WiFi)) { var diag = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle(Resource.String.datausagetitle) .SetMessage(Resource.String.datacharge) .SetPositiveButton(Resource.String.continuebtn, async(o, e) => { try { await LoginFuncs.TryLogin(this, cancel.Token); await Bootlegger.BootleggerClient.Connect(Bootlegger.BootleggerClient.SessionCookie, new System.Threading.CancellationTokenSource().Token); await Bootlegger.BootleggerClient.ConnectForReview(WhiteLabelConfig.REDUCE_BANDWIDTH, new Shoot() { id = obj.media[0].event_id }, cancel.Token); Intent i = new Intent(this, typeof(Editor)); i.PutExtra(Review.EDIT, obj.id); StartActivityForResult(i, Review.EDIT_RESPONSE); Bootlegger.BootleggerClient.CanUpload = false; } catch (TaskCanceledException) { //nothing, it was cancelled } catch { LoginFuncs.ShowError(this, new Exception(Resources.GetString(Resource.String.noconnectionshort))); } finally { AndHUD.Shared.Dismiss(); } }) .SetCancelable(false) .SetNegativeButton(Android.Resource.String.Cancel, (o, e) => { AndHUD.Shared.Dismiss(); }) .Show(); } else { try { await LoginFuncs.TryLogin(this, cancel.Token); await Bootlegger.BootleggerClient.Connect(Bootlegger.BootleggerClient.SessionCookie, new System.Threading.CancellationTokenSource().Token); await Bootlegger.BootleggerClient.ConnectForReview(WhiteLabelConfig.REDUCE_BANDWIDTH, new Shoot() { id = obj.media[0].event_id }, cancel.Token); Intent i = new Intent(this, typeof(Editor)); i.PutExtra(Review.EDIT, obj.id); StartActivityForResult(i, Review.EDIT_RESPONSE); Bootlegger.BootleggerClient.CanUpload = false; } catch (TaskCanceledException) { //nothing, it was cancelled } catch (Exception e) { LoginFuncs.ShowError(this, e); } finally { AndHUD.Shared.Dismiss(); } } }
void RefreshOnline(bool data) { try { loading = true; if (data) { theview.FindViewById <ProgressBar>(Resource.Id.progressBar).Post(() => { theview.FindViewById <ProgressBar>(Resource.Id.progressBar).Visibility = ViewStates.Visible; }); cancel = new CancellationTokenSource(); Bootlegger.BootleggerClient.GetEveryonesMedia(cancel.Token); } if (ChooserMode == ClipViewMode.INGEST) { listAdapter.UpdateData(Bootlegger.BootleggerClient.QueryMedia(sortFilter, sortDirection)); } else if (ChooserMode == ClipViewMode.EDITING) { var dat = Bootlegger.BootleggerClient.QueryMediaByTopic(tagfilter.Select((arg) => arg.id).ToList()) .GroupBy(n => n.Contributor) .OrderBy(a => (a.Key == Bootlegger.BootleggerClient.CurrentUser.displayName) ? 1 : 2) .ToDictionary(n => n.Key, n => n.ToList()); listAdapter.UpdateData(dat); } else { listAdapter.UpdateData(new Dictionary <string, List <MediaItem> >() { { "all", Bootlegger.BootleggerClient.QueryMediaByTopic(new List <string>()) } }); } if (!data) { theview.FindViewById <ProgressBar>(Resource.Id.progressBar).Post(() => { theview.FindViewById <ProgressBar>(Resource.Id.progressBar).Visibility = ViewStates.Gone; }); if (listAdapter.ItemCount == ((ChooserMode == ClipViewMode.LIST) ? 1 : 0)) { theview.FindViewById <View>(Resource.Id.emptytext).Visibility = ViewStates.Visible; } else { theview.FindViewById <View>(Resource.Id.emptytext).Visibility = ViewStates.Gone; } } } catch (Exception e) { LoginFuncs.ShowError(Activity, e); } finally { if (!data) { loading = false; } } //if doing a hard-reload, dont hide progress }
public async void TrimVideo(MediaItem meta) { //fade out current... FindViewById(Resource.Id.trackcontrols).Visibility = ViewStates.Visible; FindViewById <View>(Resource.Id.progress).Visibility = ViewStates.Visible; _playerView.Visibility = ViewStates.Visible; //_audioPlayer.Volume = 0; _audioPlayer.PlayWhenReady = false; try { var uri = await Bootlegger.BootleggerClient.GetVideoUrl(meta); currentitem = meta; //Console.WriteLine("ci ip: " + meta.inpoint); currentmode = PLAYBACK_MODE.TRIM_CLIP; switch (currentitem?.MediaType ?? Shot.ShotTypes.VIDEO) { case Shot.ShotTypes.VIDEO: case Shot.ShotTypes.AUDIO: PrepareSingleSource(uri, meta); _player.PlayWhenReady = false; _player.SeekTo((long)currentitem.inpoint.TotalMilliseconds); _player.PlayWhenReady = true; _player.RepeatMode = Player.RepeatModeOne; break; case Shot.ShotTypes.TITLE: try { _player.Prepare(mediaSource); } catch (Exception e) { //Toast.MakeText(Context, Resource.String.noconnectionshort, ToastLength.Short).Show(); LoginFuncs.ShowToast(Context, e); //LoginFuncs.ShowError(Context, new Exception(e.Message)); } break; } seeker.Visibility = ViewStates.Invisible; //Console.WriteLine(uri); _playerView.Post(() => { //video.Start(); //FindViewById<ImageView>(Resource.Id.pausebtn).Visibility = ViewStates.Gone; try { if (WhiteLabelConfig.SHOW_META_EDITING) { if (meta != null) { FindViewById <TextView>(Resource.Id.username).Text = meta.Contributor.ToString(); FindViewById <TextView>(Resource.Id.role).Text = meta.meta.role_ex["name"].ToString(); FindViewById <TextView>(Resource.Id.phase).Text = meta.meta.phase_ex["name"].ToString(); FindViewById <TextView>(Resource.Id.shot).Text = meta.meta.shot_ex["name"].ToString(); } else { FindViewById <TextView>(Resource.Id.username).Text = "unknown"; FindViewById <TextView>(Resource.Id.role).Text = "unknown"; FindViewById <TextView>(Resource.Id.phase).Text = "unknown"; FindViewById <TextView>(Resource.Id.shot).Text = "unknown"; } } } catch { } }); source = uri; } catch (Exception e) { LoginFuncs.ShowError(Context, e); } }
private async void Refresh(bool manually) { cancel = new CancellationTokenSource(); try { if (manually) { if (!Bootlegger.BootleggerClient.Connected && (Context.ApplicationContext as BootleggerApp).IsReallyConnected) { //AndHUD.Shared.Show(Activity, Resources.GetString(Resource.String.connecting), -1, MaskType.Black); try { await LoginFuncs.TryLogin(Activity, cancel.Token); } catch (TaskCanceledException) { //do nothing } catch (Exception) { //LoginFuncs.ShowError(Context, Resource.String.cantconnect); throw new Exception(); //return; } } if ((Context.ApplicationContext as BootleggerApp).IsReallyConnected) { await Bootlegger.BootleggerClient.GetMyEdits(cancel.Token, false); //if we are in the review screen if (Bootlegger.BootleggerClient.CurrentEvent != null) { try { Bootlegger.BootleggerClient.RegisterForEditUpdates(); } catch { //not online, so dont register for updates } } } } _adapter.UpdateData(Bootlegger.BootleggerClient.MyEdits, true); theview.FindViewById <View>(Resource.Id.emptytext).Visibility = ViewStates.Gone; if (_adapter.ItemCount == 1) { theview.FindViewById <View>(Resource.Id.emptytext).Visibility = ViewStates.Visible; } //if (Bootlegger.BootleggerClient.CurrentEvent != null && _adapter.ItemCount == 0) //{ // theview.FindViewById<View>(Resource.Id.emptytext).Visibility = ViewStates.Visible; //} } catch (TaskCanceledException) { //user cancelled } catch (Exception e) { if (Activity != null) { LoginFuncs.ShowError(Activity, e); } } finally { theview.Post(() => { theview.FindViewById <ProgressBar>(Resource.Id.progressBar).Visibility = ViewStates.Gone; }); AndHUD.Shared.Dismiss(); } //} //else //{ // theview.Post(() => { theview.FindViewById<ProgressBar>(Resource.Id.progressBar).Visibility = ViewStates.Gone; }); //} }
private async void Tab_OnRoleSelected(Role selected) { if (!selectingrole) { selectingrole = true; //if its the initial connection: if (!dark) { //Shoot selected = obj; cancel = new CancellationTokenSource(); AndHUD.Shared.Show(Activity, Resources.GetString(Resource.String.connecting), -1, MaskType.Black, null, null, true, () => { cancel.Cancel(); selectingrole = false; }); try { cancel = new CancellationTokenSource(); await AskPermissions(Activity, CurrentEvent); await Bootlegger.BootleggerClient.ConnectToEvent(CurrentEvent, false, cancel.Token); } catch (ServerErrorException) { AndHUD.Shared.Dismiss(); //show dialog: new Android.Support.V7.App.AlertDialog.Builder(Activity).SetMessage(Resources.GetString(Resource.String.role_repeat)) .SetNegativeButton(Android.Resource.String.No, new EventHandler <DialogClickEventArgs>((oe, eo) => { })) .SetPositiveButton(Android.Resource.String.Yes, new EventHandler <DialogClickEventArgs>(async(oe, eo) => { AndHUD.Shared.Show(Activity, Resources.GetString(Resource.String.connecting), -1, MaskType.Black, null, null, true, () => { cancel.Cancel(); }); cancel = new CancellationTokenSource(); await Bootlegger.BootleggerClient.ConnectToEvent(CurrentEvent, true, cancel.Token); await AskPermissions(Activity, CurrentEvent); selectingrole = false; })) .SetTitle(Resource.String.areyousure) .SetCancelable(false) .Show(); } catch (NotGivenPermissionException e) { AndHUD.Shared.Dismiss(); selectingrole = false; try { LoginFuncs.ShowError(this.Activity, e); //Toast.MakeText(Activity, Resource.String.acceptperms, ToastLength.Long).Show(); } catch { } return; } catch (Exception e) { AndHUD.Shared.Dismiss(); selectingrole = false; try { //Toast.MakeText(Activity, Resource.String.problemconnecting, ToastLength.Long).Show(); LoginFuncs.ShowError(this.Activity, e); } catch { } return; } } //ROLE SELECTION WHEN SHOOTING: //AndHUD.Shared.Show(Activity, Resources.GetString(Resource.String.loading), -1, MaskType.Black, null, null, true, () => //{ // cancel.Cancel(); // selectingrole = false; //}); //await Task.Delay(100); try { cancel = new CancellationTokenSource(); var res = await Bootlegger.BootleggerClient.SelectRole(selected, false, cancel.Token); if (res.State == API.Model.RoleStatus.RoleState.OK) { OnRoleChanged?.Invoke(); rolelist?.Update(); map?.Update(); //AndHUD.Shared.Dismiss(); selectingrole = false; } else if (res.State == API.Model.RoleStatus.RoleState.CONFIRM) { new Android.Support.V7.App.AlertDialog.Builder(Activity).SetMessage(res.Message) .SetNegativeButton(Android.Resource.String.No, new EventHandler <DialogClickEventArgs>(async(oe, eo) => { cancel = new CancellationTokenSource(); var ress = await Bootlegger.BootleggerClient.SelectRole(selected as Role, true, cancel.Token); //listview.Enabled = true; if (ress.State == API.Model.RoleStatus.RoleState.OK) { OnRoleChanged?.Invoke(); rolelist?.Update(); map?.Update(); //AndHUD.Shared.Dismiss(); selectingrole = false; } else { //you are live -- so cant do this anyway //AndHUD.Shared.Dismiss(); selectingrole = false; } })) .SetPositiveButton(Android.Resource.String.Yes, new EventHandler <DialogClickEventArgs>((oe, eo) => { //AndHUD.Shared.Dismiss(); selectingrole = false; })) .SetTitle(Resource.String.roledescision) .SetCancelable(false) .Show(); } else if (res.State == API.Model.RoleStatus.RoleState.NO) { //you are live and cant do it //AndHUD.Shared.Dismiss(); selectingrole = false; try { LoginFuncs.ShowError(this.Activity, new RoleNotSelectedException()); } catch { } } } catch (Exception e) { //AndHUD.Shared.Dismiss(); selectingrole = false; try { LoginFuncs.ShowError(this.Activity, e); } catch { } } } }
public override async void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); var shootid = Arguments.GetString("eventid"); //show loader view.FindViewById <TextView>(Resource.Id.contributors).Text = ""; view.FindViewById <TextView>(Resource.Id.contributions).Text = ""; view.FindViewById <TextView>(Resource.Id.organiser).Text = ""; view.FindViewById <TextView>(Resource.Id.datetime).Text = ""; view.FindViewById <TextView>(Resource.Id.title).Text = ""; view.FindViewById <TextView>(Resource.Id.description).Text = ""; view.FindViewById(Resource.Id.loading).Visibility = ViewStates.Visible; try { var item = await Bootleg.API.Bootlegger.BootleggerClient.GetEventInfo(shootid, cancel.Token); currentshoot = item; view.FindViewById(Resource.Id.loading).Visibility = ViewStates.Gone; //hide loader switch (currentshoot.MyParticipation) { case Shoot.Participation.INVITED: view.FindViewById <ImageView>(Resource.Id.accessimg).SetImageResource(Resource.Drawable.ic_email_black_48dp); break; case Shoot.Participation.OWNER: view.FindViewById <ImageView>(Resource.Id.accessimg).SetImageResource(Resource.Drawable.ic_edit_black_24dp); break; case Shoot.Participation.PUBLIC: view.FindViewById <ImageView>(Resource.Id.accessimg).SetImageResource(Resource.Drawable.ic_lock_open_black_48dp); break; } view.FindViewById <TextView>(Resource.Id.contributors).Text = Java.Lang.String.Format("%d", currentshoot.numberofcontributors); view.FindViewById <TextView>(Resource.Id.contributions).Text = Java.Lang.String.Format("%d", currentshoot.numberofclips); view.FindViewById <TextView>(Resource.Id.organiser).Text = item.organisedby; if (item.RealEnds != null) { view.FindViewById <TextView>(Resource.Id.datetime).Text = item.RealEnds?.LocalizeTimeDiff(); } else { view.FindViewById <TextView>(Resource.Id.datetime).Text = item.starts + " - " + item.ends; } view.FindViewById <Button>(Resource.Id.navigateto).Click += (o, e) => { String url = "https://www.google.com/maps/dir/?api=1&origin=" + item.location; Intent i = new Intent(Intent.ActionView); i.SetData(Android.Net.Uri.Parse(url)); StartActivity(i); }; if (string.IsNullOrEmpty(item.iconbackground)) { Picasso.With(view.Context).Load(Resource.Drawable.user_back).CenterCrop().Fit().Into(view.FindViewById <ImageView>(Resource.Id.event_background)); } else { Picasso.With(view.Context).Load(item.iconbackground).Placeholder(Resource.Drawable.user_back).CenterCrop().Fit().Into(view.FindViewById <ImageView>(Resource.Id.event_background)); } view.FindViewById <TextView>(Resource.Id.title).Text = item.name; view.FindViewById <TextView>(Resource.Id.description).Text = item.description; //} if (!string.IsNullOrEmpty(item.icon)) { Picasso.With(view.Context).Load(item.icon).Fit().Config(Bitmap.Config.Argb4444).Transform(new CircleTransform()).Into(view.FindViewById <ImageView>(Resource.Id.event_icon)); } else { if (!string.IsNullOrEmpty(item.organiserprofile)) { Picasso.With(view.Context).Load(item.organiserprofile).Fit().Transform(new CircleTransform()).Into(view.FindViewById <ImageView>(Resource.Id.event_icon)); } else { view.FindViewById <ImageView>(Resource.Id.event_icon).SetImageDrawable(null); } } view.FindViewById(Resource.Id.shootclosed).Visibility = ViewStates.Gone; if (DateTime.Now < (item.RealStarts ?? DateTime.MaxValue) || DateTime.Now > (item.RealEnds ?? DateTime.MaxValue)) { view.FindViewById(Resource.Id.shootclosed).Visibility = ViewStates.Visible; view.FindViewById <Button>(Resource.Id.startshooting).Enabled = false; view.FindViewById <Button>(Resource.Id.startshooting).Text = Resources.GetString(Resource.String.closed); } else if (Bootlegger.BootleggerClient.CurrentUser == null) { //view.FindViewById<Button>(Resource.Id.startshooting).Click += ShootInfo_Click1; view.FindViewById <Button>(Resource.Id.startshooting).Text = Resources.GetString(Resource.String.logintocontribute); } else { view.FindViewById <Button>(Resource.Id.startshooting).Text = Resources.GetString(Resource.String.startshooting); } view.FindViewById <Button>(Resource.Id.startshooting).Click += ShootInfo_Click; if (currentshoot.location != null) { view.FindViewById <View>(Resource.Id.locationinfo).Visibility = ViewStates.Visible; //TODO: distance to shoot //view.FindViewById<TextView>(Resource.Id.distance).Text = currentshoot.distance; } else { view.FindViewById <View>(Resource.Id.locationinfo).Visibility = ViewStates.Gone; } } catch (Exception e) { //dismiss dialog LoginFuncs.ShowError(view.Context, e); Dismiss(); } }