protected override void OnCreate(Bundle bundle) { Console.WriteLine("PlayerActivity - OnCreate"); _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>(); base.OnCreate(bundle); SetContentView(Resource.Layout.Player); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); _navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>(); _fragments = new List<Fragment>(); _viewPager = FindViewById<ViewPager>(Resource.Id.player_pager); _viewPager.OffscreenPageLimit = 4; _viewPagerAdapter = new ViewPagerAdapter(FragmentManager, _fragments, _viewPager); _viewPagerAdapter.OnPageChanged += ViewPagerAdapterOnOnPageChanged; _viewPager.Adapter = _viewPagerAdapter; _viewPager.SetOnPageChangeListener(_viewPagerAdapter); _waveFormScrollView = FindViewById<WaveFormScrollView>(Resource.Id.player_waveFormScrollView); _imageViewAlbumArt = FindViewById<SquareImageView>(Resource.Id.player_imageViewAlbumArt); _lblPosition = FindViewById<TextView>(Resource.Id.player_lblPosition); _lblLength = FindViewById<TextView>(Resource.Id.player_lblLength); _btnPlayPause = FindViewById<ImageButton>(Resource.Id.player_btnPlayPause); _btnPrevious = FindViewById<ImageButton>(Resource.Id.player_btnPrevious); _btnNext = FindViewById<ImageButton>(Resource.Id.player_btnNext); _btnShuffle = FindViewById<ImageButton>(Resource.Id.player_btnShuffle); _btnRepeat = FindViewById<ImageButton>(Resource.Id.player_btnRepeat); _btnPlaylist = FindViewById<ImageButton>(Resource.Id.player_btnPlaylist); _seekBar = FindViewById<SeekBar>(Resource.Id.player_seekBar); _carrouselDot1 = FindViewById<Button>(Resource.Id.player_carrouselDot1); _carrouselDot2 = FindViewById<Button>(Resource.Id.player_carrouselDot2); _carrouselDot3 = FindViewById<Button>(Resource.Id.player_carrouselDot3); _carrouselDot4 = FindViewById<Button>(Resource.Id.player_carrouselDot4); _carrouselDot5 = FindViewById<Button>(Resource.Id.player_carrouselDot5); _btnPlayPause.Click += BtnPlayPauseOnClick; _btnPrevious.Click += BtnPreviousOnClick; _btnNext.Click += BtnNextOnClick; _btnPlaylist.Click += BtnPlaylistOnClick; _btnRepeat.Click += BtnRepeatOnClick; _btnShuffle.Click += BtnShuffleOnClick; _btnPlayPause.SetOnTouchListener(this); _btnPrevious.SetOnTouchListener(this); _btnNext.SetOnTouchListener(this); _btnPlaylist.SetOnTouchListener(this); _btnRepeat.SetOnTouchListener(this); _btnShuffle.SetOnTouchListener(this); _seekBar.StartTrackingTouch += SeekBarOnStartTrackingTouch; _seekBar.StopTrackingTouch += SeekBarOnStopTrackingTouch; _seekBar.ProgressChanged += SeekBarOnProgressChanged; // Get screen size Point size = new Point(); WindowManager.DefaultDisplay.GetSize(size); // Create bitmap cache int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024); int cacheSize = maxMemory / 12; _bitmapCache = new BitmapCache(this, cacheSize, size.X, size.X); // The album art takes the whole screen width // Match height with width (cannot do that in xml) //_imageViewAlbumArt.LayoutParameters = new ViewGroup.LayoutParams(_imageViewAlbumArt.Width, _imageViewAlbumArt.Width); if (bundle != null) { string state = bundle.GetString("key", "value"); Console.WriteLine("PlayerActivity - OnCreate - State is {0} - isInitialized: {1}", state, _isInitialized); } else { Console.WriteLine("PlayerActivity - OnCreate - State is null - isInitialized: {0}", _isInitialized); } // Don't try to check the bundle contents, if the activity wasn't destroyed, it will be null. //if (bundle != null) // Console.WriteLine("PlayerActivity - OnCreate - Bundle isn't null - value: {0}", bundle.GetString("key", "null")); //else // Console.WriteLine("PlayerActivity - OnCreate - Bundle is null!"); // When Android stops an activity, it recalls OnCreate after, even though the activity is not destroyed (OnDestroy). It actually goes through creating a new object (the ctor is called). //((AndroidNavigationManager)_navigationManager).SetPlayerActivityInstance(this); _navigationManager.BindPlayerView(MobileNavigationTabType.Playlists, this); // Activate lock screen if not already activated _messengerHub.PublishAsync<ActivateLockScreenMessage>(new ActivateLockScreenMessage(this, true)); _messengerHub.Subscribe<ApplicationCloseMessage>(message => { Console.WriteLine("PlayerActivity - Received ApplicationCloseMessage; closing activity of type {0}", this.GetType().FullName); }); }
public PanListener(WaveFormScrollView scrollView) { _scrollView = scrollView; }
public ScaleListener(WaveFormScrollView scrollView) { _scrollView = scrollView; }
public WaveFormLayout(WaveFormScrollView scrollView) : base(scrollView.Context) { _scrollView = scrollView; Orientation = Orientation.Vertical; //SetBackgroundColor(Color.DarkOrange); int height = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 22, Resources.DisplayMetrics); ScaleView = new WaveFormScaleView(Context); ScaleView.SetBackgroundColor(Color.Purple); AddView(ScaleView, new LinearLayout.LayoutParams(LayoutParams.WrapContent, height)); WaveView = new WaveFormView(Context); //WaveView.SetBackgroundColor(Color.DarkRed); AddView(WaveView, new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.FillParent)); _panGestureDetector = new GestureDetector(Context, new PanListener(_scrollView)); _scaleGestureDetector = new ScaleGestureDetector(Context, new ScaleListener(_scrollView)); _scroller = new OverScroller(Context); }