/// <summary> /// If the download isn't present, we initialize the download UI. This ties /// all of the controls into the remote service calls. /// </summary> private void InitializeDownloadUi() { InitializeControls(); initText.Visibility = ViewStates.Gone; useObbDownloader.Visibility = ViewStates.Visible; downloaderServiceConnection = DownloaderClientMarshaller.CreateStub(this, typeof(MediaDownloadService)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); progressBar = FindViewById <ProgressBar>(Resource.Id.prgProgress); statusTextView = FindViewById <TextView>(Resource.Id.lblStatus); progressFractionTextView = FindViewById <TextView>(Resource.Id.lblProgress); dashboardView = FindViewById(Resource.Id.dashboard); useCellDataView = FindViewById(Resource.Id.approve); pauseButton = FindViewById <Button>(Resource.Id.btnPause); openWiFiSettingsButton = FindViewById <Button>(Resource.Id.btnWifi); resumeOnCellDataButton = FindViewById <Button>(Resource.Id.btnResumeCell); pauseButton.Click += delegate { if (isPaused) { downloaderService.RequestContinueDownload(); } else { downloaderService.RequestPauseDownload(); } UpdatePauseButton(!isPaused); }; openWiFiSettingsButton.Click += delegate { StartActivity(new Intent(Settings.ActionWifiSettings)); }; resumeOnCellDataButton.Click += delegate { downloaderService.SetDownloadFlags(DownloaderServiceFlags.DownloadOverCellular); downloaderService.RequestContinueDownload(); useCellDataView.Visibility = ViewStates.Gone; }; dashboardView.Visibility = ViewStates.Gone; useCellDataView.Visibility = ViewStates.Gone; var delivered = AreExpansionFilesDelivered(); if (delivered) { statusTextView.Text = "Download Complete!"; } else if (!GetExpansionFiles()) { downloaderServiceConnection = DownloaderClientMarshaller.CreateStub(this, typeof(SampleDownloaderService)); } }
private void StartExpansionDownload() { //("MainActivity.StartExpansionDownload"); Intent intent = this.Intent; Intent intent2 = new Intent(this, typeof(SMainActivity)); intent2.SetFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask); intent2.SetAction(intent.Action); if (intent.Categories != null) { foreach (string category in intent.Categories) { intent2.AddCategory(category); } } PendingIntent activity = PendingIntent.GetActivity(this, 0, intent2, PendingIntentFlags.UpdateCurrent); try { DownloaderServiceRequirement downloaderServiceRequirement = DownloaderService.StartDownloadServiceIfRequired(this, activity, typeof(ExpansionDownloaderService)); if (downloaderServiceRequirement != 0) { //("MainActivity.StartExpansionDownload A startResult:" + downloaderServiceRequirement); this._downloaderServiceConnection = DownloaderClientMarshaller.CreateStub(this, typeof(ExpansionDownloaderService)); this._downloaderServiceConnection.Connect(this); //("MainActivity.StartExpansionDownload B startResult:" + downloaderServiceRequirement); } else { //("MainActivity.StartExpansionDownload - all files have finished downloading already"); this.OnExpansionDowloaded(); } } catch (IllegalStateException ex) { //("MainActivity.StartExpansionDownload ERROR exception:" + ex); Crashes.TrackError(ex); } }
private bool GetExpansionFiles() { bool result = false; // Build the intent that launches this activity. var launchIntent = Intent; var intent = new Intent(this, typeof(MainActivity)); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop); intent.SetAction(launchIntent.Action); if (launchIntent.Categories != null) { foreach (string category in launchIntent.Categories) { intent.AddCategory(category); } } // Build PendingIntent used to open this activity when user // taps the notification. var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.UpdateCurrent); // Request to start the download var startResult = DownloaderService.StartDownloadServiceIfRequired(this, pendingIntent, typeof(SampleDownloaderService)); // The DownloaderService has started downloading the files, // show progress otherwise, the download is not needed so we // fall through to starting the actual app. if (startResult != DownloadServiceRequirement.NoDownloadRequired) { downloaderServiceConnection = DownloaderClientMarshaller.CreateStub(this, typeof(SampleDownloaderService)); result = true; } return(result); }
/// <summary> /// If the download isn't present, we initialize the download UI. This ties /// all of the controls into the remote service calls. /// </summary> private void InitializeDownloadUi() { InitializeControls(); _downloaderServiceConnection = DownloaderClientMarshaller.CreateStub( this, typeof(ExpansionDownloaderService)); }