async void OnAlbumItemClicked(object sender, AdapterView.ItemClickEventArgs e) { var selectedEpisode = _album.Episodes [e.Position]; if (AndroidAudioDownloader.ViewsDownloadInProgressByAudioId.ContainsKey(selectedEpisode.RemoteUrl)) { return; } if (AudioDownloader.HasLocalFile(selectedEpisode.RemoteUrl, selectedEpisode.FileSize)) { var resultIntent = new Intent(); ExtraUtils.PutEpisode(resultIntent, selectedEpisode.Id); ExtraUtils.PutAlbum(resultIntent, _album.Id); ExtraUtils.PutSelectedTab(resultIntent, (int)MainActivity.TabTitle.Player); SetResult(Result.Ok, resultIntent); StartService(PlayerService.CreateIntent( this, PlayerService.ACTION_PLAY, _album.Id, selectedEpisode.Id )); Finish(); } else { await AndroidAudioDownloader.StartDownloadAsync(e.Position, selectedEpisode.RemoteUrl, ListView); } }
public static Intent CreateIntent(Context context, String action, int albumID, int episodeID) { var intent = CreateIntent(context, action); ExtraUtils.PutAlbum(intent, albumID); ExtraUtils.PutEpisode(intent, episodeID); return(intent); }
public static Intent CreateIntent(Context context, int albumID, int currentEpisodeID) { var intent = new Intent(context, typeof(MainActivity)); ExtraUtils.PutAlbum(intent, albumID); ExtraUtils.PutEpisode(intent, currentEpisodeID); return(intent); }
public static Intent CreateIntent(Context context, int albumID, int episodeId = -1) { var intent = new Intent(context, typeof(AudioListActivity)); ExtraUtils.PutAlbum(intent, albumID); if (episodeId != -1) { ExtraUtils.PutEpisode(intent, episodeId); } return(intent); }
void ConfigureTabs() { ActionBar.NavigationMode = ActionBarNavigationMode.Tabs; ActionBar.SetDisplayShowTitleEnabled(false); ActionBar.SetDisplayShowHomeEnabled(false); foreach (var tabHolder in _tabConfiguration) { AddTab(tabHolder); } var selectedTabIndex = ExtraUtils.GetSelectedTab(Intent); if (selectedTabIndex != -1 && ActionBar.SelectedTab != GetTab(TabTitle.Player)) { Intent.RemoveExtra(ExtraUtils.SELECTED_TAB); ActionBar.GetTabAt(selectedTabIndex).Select(); } }
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)); } } }
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); }
/// <summary> /// When we start on the foreground we will present a notification to the user /// When they press the notification it will take them to the main page so they can control the music /// </summary> void StartForeground() { var intent = new Intent(ApplicationContext, typeof(MainActivity)); intent.SetAction(Intent.ActionMain); intent.AddCategory(Intent.CategoryLauncher); ExtraUtils.PutSelectedTab(intent, (int)MainActivity.TabTitle.Player); var pendingIntent = PendingIntent.GetActivity( ApplicationContext, 0, intent, PendingIntentFlags.UpdateCurrent ); var notificationBuilder = new Notification.Builder(ApplicationContext); notificationBuilder.SetContentTitle(CurrentEpisode.Title); notificationBuilder.SetContentText( String.Format( ApplicationContext.GetString(Resource.String.NotificationContentText), ApplicationContext.GetString(Resource.String.ApplicationName) ) ); notificationBuilder.SetSmallIcon(Resource.Drawable.ic_stat_av_play_over_video); notificationBuilder.SetTicker( String.Format( Application.GetString(Resource.String.NoticifationTicker), CurrentEpisode.Title ) ); notificationBuilder.SetOngoing(true); notificationBuilder.SetContentIntent(pendingIntent); StartForeground(NotificationId, notificationBuilder.Build()); }