//private void Preview_Click(object sender, EventArgs e) //{ // Intent sharingIntent = new Intent(Intent.ActionSend); // sharingIntent.SetType("text/plain"); // sharingIntent.PutExtra(Intent.ExtraSubject, shareedit.title); // sharingIntent.PutExtra(Intent.ExtraText, Bootlegger.BootleggerClient.server + "/v/" + shareedit.shortlink); // StartActivity(Intent.CreateChooser(sharingIntent, new Java.Lang.String(Resources.GetString(Resource.String.sharevia)))); //} public async void PlayVideo(MediaItem media) { Bootlegger.BootleggerClient.LogUserAction("Preview", new KeyValuePair <string, string>("mediaid", media.id)); if (Intent.GetBooleanExtra(Review.INGEST_MODE, false)) { var rv = FindViewById <RecyclerView>(Resource.Id.list); rv.SetLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false)); var _readonly = Intent.GetBooleanExtra(Review.READ_ONLY, false); var chips = new ChipAdapter(this, _readonly); //var prev = Resources.GetStringArray(Resource.Array.default_edit_topics).ToList(); //if (string.IsNullOrEmpty(Bootlegger.BootleggerClient.CurrentEvent.topics)) // Bootlegger.BootleggerClient.CurrentEvent.topics = string.Join(",", prev); //else //prev = Bootlegger.BootleggerClient.CurrentEvent.topics.Split(',').ToList(); if (_readonly) { chips.Update(null, media); } else { chips.Update(Bootlegger.BootleggerClient.CurrentEvent.topics.ToList(), media); } rv.SetAdapter(chips); FindViewById(Resource.Id.videometadata).Visibility = ViewStates.Gone; } FindViewById <ImageView>(Resource.Id.imageplayer).SetImageDrawable(null); try { FindViewById <TextView>(Resource.Id.metadata).Text = media.meta.shot_ex["name"].ToString() + " at " + media.meta.role_ex["name"].ToString() + " during " + media.meta.phase_ex["name"].ToString(); } catch { FindViewById <TextView>(Resource.Id.metadata).Text = ""; } try { FindViewById <TextView>(Resource.Id.timemeta).Text = media.CreatedAt.LocalizeFormat("ha E d MMM yy"); } catch { FindViewById <TextView>(Resource.Id.timemeta).Text = media.Static_Meta["captured_at"].ToString(); } FindViewById <TextView>(Resource.Id.description).Visibility = ViewStates.Gone; switch (media.MediaType) { case Shot.ShotTypes.VIDEO: case Shot.ShotTypes.AUDIO: //FindViewById<View>(Resource.Id.videoplayer).Visibility = ViewStates.Visible; try { //set other fields: string url = await Bootlegger.BootleggerClient.GetVideoUrl(media); if (url.StartsWith("file://")) { DefaultDataSourceFactory httpDataSourceFactory = new DefaultDataSourceFactory(this, "BootleggerPreview"); var extractorsFactory = new DefaultExtractorsFactory(); mediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(url), httpDataSourceFactory, extractorsFactory, null, null); } else { var client = new OkHttpClient.Builder() .Cache((Application as BootleggerApp).FilesCache) .Build(); OkHttpDataSourceFactory httpDataSourceFactory = new OkHttpDataSourceFactory(client, "BootleggerPreview"); var extractorsFactory = new DefaultExtractorsFactory(); mediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(url), httpDataSourceFactory, extractorsFactory, null, null); } _player.Prepare(mediaSource); } catch (Exception e) { //Toast.MakeText(this, Resource.String.cannotloadvideo, ToastLength.Short).Show(); LoginFuncs.ShowToast(this, e); } break; case Shot.ShotTypes.PHOTO: //FindViewById<View>(Resource.Id.videoplayer).Visibility = ViewStates.Gone; if (media.Status == MediaItem.MediaStatus.DONE && !string.IsNullOrEmpty(media.path)) { //string url = await (Application as BootleggerApp).Comms.(videofile); Picasso.With(this).Load(media.Thumb + "?s=300").Fit().CenterInside().Into(FindViewById <ImageView>(Resource.Id.imageplayer)); } else { Picasso.With(this).Load("file://" + media.Filename).Fit().CenterInside().Into(FindViewById <ImageView>(Resource.Id.imageplayer)); } break; } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view; if (ChooserMode == ClipViewMode.INGEST) { view = inflater.Inflate(Resource.Layout.clips_list_themes, container, false); } else { view = inflater.Inflate(Resource.Layout.clips_list, container, false); } view.FindViewById <SwipeRefreshLayout>(Resource.Id.swiperefresh).Refresh += MyEditsFragment_Refresh; var cols = Activity.Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape ? 3 : 2; if (ChooserMode == ClipViewMode.EDITING) { cols = 3; } listAdapter = new ClipAdapter(Activity, new Dictionary <string, List <MediaItem> >(), ChooserMode, Bootlegger.BootleggerClient.CurrentEvent.topics.ToList()); listAdapter.OnPreview += _adatper_OnPreview; listAdapter.OnChosen += ListAdapter_OnChosen; var mLayoutManager = new GridLayoutManager(Activity, cols); spanLookup = new MySpanSizeLookup(listAdapter, cols); mLayoutManager.SetSpanSizeLookup(spanLookup); view.FindViewById <View>(Resource.Id.emptytext).Visibility = ViewStates.Gone; var listView = view.FindViewById <RecyclerView>(Resource.Id.allclips); listView.SetLayoutManager(mLayoutManager); listView.SetAdapter(listAdapter); listView.SetItemAnimator(null); listView = view.FindViewById <RecyclerView>(Resource.Id.allclips); listView.HasFixedSize = true; theview = view; if (ChooserMode == ClipViewMode.INGEST) { view.FindViewById <FloatingActionButton>(Resource.Id.continuebtn).Click += AllClipsFragment_Click; } else if (ChooserMode == ClipViewMode.EDITING) { //setup filters for topics: var rv = view.FindViewById <RecyclerView>(Resource.Id.list); rv.SetLayoutManager(new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false)); var chips = new ChipAdapter(Activity, false); chips.Update(Bootlegger.BootleggerClient.CurrentEvent.topics.ToList(), null); rv.SetAdapter(chips); chips.OnTopicFilterChanged += Chips_OnTopicFilterChanged; view.FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.filtertoolbar).SetTitle(Resource.String.selectavideotoinsert); view.FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.filtertoolbar).InflateMenu(Resource.Menu.selectclip); view.FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.filtertoolbar).MenuItemClick += AllClipsFragment_MenuItemClick; } else { view.FindViewById(Resource.Id.filtertoolbar).Visibility = ViewStates.Gone; } listView.AddOnScrollListener(new PausableScrollListener(Context, listAdapter)); return(view); }
internal void SetItem(HeaderMediaItem item) { if (item.IsHeader) { media = null; view.FindViewById <TextView>(Resource.Id.header).Text = (item.HeaderText == BootleggerClient.CurrentUser.displayName)?view.Context.GetString(Resource.String.me): item.HeaderText; if (view.FindViewById <TextView>(Resource.Id.subheader) != null) { view.FindViewById <TextView>(Resource.Id.subheader).Text = item.SubText; } } else { media = item.MediaItem; Picasso.With(adpt.context). Load(item.MediaItem.Thumb + "?s=" + WhiteLabelConfig.THUMBNAIL_SIZE). Tag(adpt). Config(Android.Graphics.Bitmap.Config.Rgb565). Fit(). CenterCrop(). Into(view.FindViewById <ImageView>(Resource.Id.image)); if (chips != null) { chips.Update(null, item.MediaItem); chips.NotifyDataSetChanged(); } view.FindViewById <TextView>(Resource.Id.cliplength).Text = item.MediaItem.ClipLength.ToString(@"mm\:ss"); if (adpt.chooser_mode == ClipViewMode.EDITING) { try { //if (item.MediaItem.CreatedAt!=null) // view.FindViewById<TextView>(Resource.Id.title).Text = item.MediaItem.CreatedAt.ToString("hhtt ddd dd MMM yy"); view.FindViewById <TextView>(Resource.Id.title).Text = item.MediaItem.CreatedAt.LocalizeTimeDiff(); //("ha E d MMM yy"); } catch { view.FindViewById <TextView>(Resource.Id.title).Text = item.MediaItem.Static_Meta["captured_at"].ToString(); } view.FindViewById <TextView>(Resource.Id.date).Text = (item.MediaItem.created_by == Bootlegger.BootleggerClient.CurrentUser.id) ? view.Context.GetString(Resource.String.me) : item.MediaItem.Contributor; view.FindViewById <TextView>(Resource.Id.date).Visibility = ViewStates.Gone; view.FindViewById <ImageButton>(Resource.Id.choosebtn).Visibility = ViewStates.Visible; //if it is in the timeline: if (adpt.IsInEdit(item.MediaItem)) { view.FindViewById(Resource.Id.usedtick).Visibility = ViewStates.Visible; } else { view.FindViewById(Resource.Id.usedtick).Visibility = ViewStates.Gone; } try { var mtopics = item.MediaItem.Static_Meta[$"{((!WhiteLabelConfig.PUBLIC_TOPICS) ? BootleggerClient.CurrentUser?.id : "")}-{MetaDataFields.Topics}"].TrimStart(',').Split(','); if (mtopics.Length > 0) { //var index = topics.IndexOf(mtopics.First()); //var index = Array.IndexOf(BootleggerClient.CurrentEvent.topics.Split(','), mtopics.First()); //view.FindViewById<View>(Resource.Id.colorbar).SetBackgroundColor(SliverEditAdapter.GetColorForIndex(view.Context,index)); var index = BootleggerClient.CurrentEvent.topics.Find((t) => t.id == mtopics.First()); view.FindViewById <View>(Resource.Id.colorbar).SetBackgroundColor(Color.ParseColor(index.color)); } else { view.FindViewById <View>(Resource.Id.colorbar).SetBackgroundColor(Color.Silver); } } catch { view.FindViewById <View>(Resource.Id.colorbar).SetBackgroundColor(Color.Silver); } } //show chips: } }