Esempio n. 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.AudioListView);
            _album              = ExtraUtils.GetAlbum(DrunkAudibleApplication.Self.Database, Intent);
            Title               = _album.Title;
            ListAdapter         = new AudioListAdapter(this, _album);
            ListView.ItemClick += OnAlbumItemClicked;

            if (_album == DrunkAudibleApplication.Self.CurrentAlbum)
            {
                var currentEpisode = DrunkAudibleApplication.Self.CurrentEpisode;
                if (!AudioEpisode.IsNullOrEmpty(currentEpisode))
                {
                    ListView.SetSelection(_album.Episodes.IndexOf(currentEpisode));
                }
            }
        }
Esempio n. 2
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (intent == null)
            {
                // Re-launch the app after running with stop status in the background for a long time.
                // At this time, intent is null and throwing exceptions will break the app.
                return(StartCommandResult.Sticky);
            }

            var extraAlbum = ExtraUtils.GetAlbum(DrunkAudibleApplication.Self.Database, intent);

            if (!Album.IsNullOrEmpty(extraAlbum))
            {
                CurrentAlbum = extraAlbum;
            }
            var extraEpisode = ExtraUtils.GetAudioEpisode(intent, CurrentAlbum);

            if (!AudioEpisode.IsNullOrEmpty(extraEpisode))
            {
                CurrentEpisode = extraEpisode;
            }

            switch (intent.Action)
            {
            case ACTION_PLAY:
                Play();
                break;

            case ACTION_STOP:
                Stop();
                break;

            case ACTION_PAUSE:
                Pause();
                break;
            }

            //Set sticky as we are a long running operation
            return(StartCommandResult.Sticky);
        }