protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     if (requestCode == RecoveryDialogRequest)
     {
         // Retry initialization if user performed a recovery action
         if (errorDialog != null && errorDialog.IsShowing)
         {
             errorDialog.Dismiss();
         }
         errorDialog = null;
         playerFragment.Initialize(DeveloperKey.Key, this);
         thumbnailView.Initialize(DeveloperKey.Key, this);
     }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            state = State.Uninitialized;

            var viewFrame = new FrameLayout(this);

            var displayMetrics         = Resources.DisplayMetrics;
            int maxAllowedNumberOfRows = (int)Math.Floor((displayMetrics.HeightPixels / displayMetrics.Density) / PlayerViewMinimumHeight);
            int numberOfRows           = Math.Min(maxAllowedNumberOfRows, MaxRowCount);
            int interImagePaddingPx    = (int)displayMetrics.Density * ImagePadding;
            int imageHeight            = (displayMetrics.HeightPixels / numberOfRows) - interImagePaddingPx;
            int imageWidth             = (int)(imageHeight * ThumbnailAspectRatio);

            imageWallView = new ImageWallView(this, imageWidth, imageHeight, interImagePaddingPx);
            viewFrame.AddView(imageWallView, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            thumbnailView = new YouTubeThumbnailView(this);
            thumbnailView.Initialize(DeveloperKey.Key, this);

            flippingView          = new FlippingView(this, imageWidth, imageHeight);
            flippingView.Flipped += OnFlipped;
            flippingView.SetFlipDuration(InitialFlipDuration);
            viewFrame.AddView(flippingView, imageWidth, imageHeight);

            playerView            = new FrameLayout(this);
            playerView.Id         = Resource.Id.player_view;
            playerView.Visibility = ViewStates.Invisible;
            viewFrame.AddView(playerView, imageWidth, imageHeight);

            playerFragment = YouTubePlayerFragment.NewInstance();
            playerFragment.Initialize(DeveloperKey.Key, this);
            FragmentManager.BeginTransaction().Add(Resource.Id.player_view, playerFragment).Commit();

            flipDelayHandler = new Handler(msg =>
            {
                FlipNext();
                flipDelayHandler.SendEmptyMessageDelayed(0, FlipPeriod);
            });

            SetContentView(viewFrame);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            state = State.UNINITIALIZED;
            ViewGroup      viewFrame              = new FrameLayout(this);
            DisplayMetrics displayMetrics         = Resources.DisplayMetrics;
            int            maxAllowedNumberOfRows = (int)Math.Floor(
                (displayMetrics.HeightPixels / displayMetrics.Density) / PLAYER_VIEW_MINIMUM_HEIGHT_DP);
            int numberOfRows        = Math.Min(maxAllowedNumberOfRows, MAX_NUMBER_OF_ROWS_WANTED);
            int interImagePaddingPx = (int)displayMetrics.Density * INTER_IMAGE_PADDING_DP;
            int imageHeight         = (displayMetrics.HeightPixels / numberOfRows) - interImagePaddingPx;
            int imageWidth          = (int)(imageHeight * THUMBNAIL_ASPECT_RATIO);

            imageWallView = new ImageWallView(this, imageWidth, imageHeight, interImagePaddingPx);
            viewFrame.AddView(imageWallView, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            thumbnailView = new YouTubeThumbnailView(this);
            thumbnailView.Initialize(DeveloperKey.DEVELOPER_KEY, this);

            flippingView = new FlippingView(this, this, imageWidth, imageHeight);
            flippingView.SetFlipDuration(INITIAL_FLIP_DURATION_MILLIS);
            viewFrame.AddView(flippingView, imageWidth, imageHeight);

            playerView            = new FrameLayout(this);
            playerView.Id         = Resource.Id.player_view;
            playerView.Visibility = ViewStates.Invisible;
            viewFrame.AddView(playerView, imageWidth, imageHeight);

            playerFragment = YouTubePlayerFragment.NewInstance();
            playerFragment.Initialize(DeveloperKey.DEVELOPER_KEY, this);
            FragmentManager.BeginTransaction().Add(Resource.Id.player_view, playerFragment).Commit();
            flipDelayHandler = new FlipDelayHandler()
            {
                HandleMessageAction = (msg) =>
                {
                    FlipNext();
                }
            };
            SetContentView(viewFrame);
        }
Esempio n. 4
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View       view  = convertView;
            VideoEntry entry = entries[position];

            // There are three cases here
            if (view == null)
            {
                // 1) The view has not yet been created - we need to initialize the YouTubeThumbnailView.
                view = inflater.Inflate(Resource.Layout.video_list_item, parent, false);
                YouTubeThumbnailView thumbnail = (YouTubeThumbnailView)view.FindViewById(Resource.Id.thumbnail);
                thumbnail.Tag = (entry.videoId);
                thumbnail.Initialize(DeveloperKey.DEVELOPER_KEY, thumbnailListener);
            }
            else
            {
                YouTubeThumbnailView    thumbnail = (YouTubeThumbnailView)view.FindViewById(Resource.Id.thumbnail);
                IYouTubeThumbnailLoader loader    = thumbnailViewToLoaderMap[thumbnail];
                if (loader == null)
                {
                    // 2) The view is already created, and is currently being initialized. We store the
                    //    current videoId in the tag.
                    thumbnail.Tag = (entry.videoId);
                }
                else
                {
                    // 3) The view is already created and already initialized. Simply Set the right videoId
                    //    on the loader.
                    thumbnail.SetImageResource(Resource.Drawable.loading_thumbnail);
                    loader.SetVideo(entry.videoId);
                }
            }
            TextView label = ((TextView)view.FindViewById(Resource.Id.text));

            label.Text       = (entry.text);
            label.Visibility = (labelsVisible ? ViewStates.Visible : ViewStates.Gone);
            return(view);
        }
            public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
            {
                base.OnCreateView(inflater, container, savedInstanceState);

                var view = this.BindingInflate(Resource.Layout.video_list_demo, null);

                // ToggleButton togglebutton = view.FindViewById<ToggleButton>(Resource.Id.FavoriteButton);


                videoBox    = view.FindViewById(Resource.Id.video_box);
                closeButton = view.FindViewById(Resource.Id.close_button);

                videoBox.Visibility = ViewStates.Visible; //invisible

                text = view.FindViewById <TextView>(Resource.Id.titletext);

                thumbnail_channel = view.FindViewById <YouTubeThumbnailView>(Resource.Id.thumbnail_channel);
                thumbnail_channel.Initialize(DeveloperKey.Key, this);


                var adapter = new VideoListAdapter((IMvxAndroidBindingContext)this.BindingContext);

                MvxRecyclerView m = view.FindViewById <MvxRecyclerView>(Resource.Id.rvItems);

                m.Adapter = adapter;
                adapter.NotifyDataSetChanged();
                adapter.ViewModel  = ViewModel;
                adapter.mcon       = Context;
                adapter.ToogleIcon = Resource.Drawable.button_favorite;

                var set1 = this.CreateBindingSet <PlayVideoFragment, PlayVideoViewModel>();

                set1.Bind(adapter).For(x => x.ItemsSource).To(x => x.YoutubeItems);
                set1.Apply();

                return(view);
            }