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); }