Esempio n. 1
0
        /// <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));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DownloaderService"/> class.
        /// </summary>
        protected DownloaderService()
            : base("LVLDownloadService")
        {
            Log.Debug(Tag, "LVLDL DownloaderService()");

            this.serviceConnection = ServiceMarshaller.CreateStub(this);
            this.serviceMessenger  = this.serviceConnection.GetMessenger();

            this.Control = DownloadsDatabase.DownloadStatus == ExpansionDownloadStatus.PausedByApp
                               ? ControlAction.Paused
                               : ControlAction.Run;
        }
        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));
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.SetContentView(Resource.Layout.Main);

            this.progressBar = this.FindViewById<ProgressBar>(Resource.Id.prgProgress);
            this.statusTextView = this.FindViewById<TextView>(Resource.Id.lblStatus);
            this.progressFractionTextView = this.FindViewById<TextView>(Resource.Id.lblProgress);
            this.dashboardView = this.FindViewById(Resource.Id.dashboard);
            this.useCellDataView = this.FindViewById(Resource.Id.approve);
            this.pauseButton = this.FindViewById<Button>(Resource.Id.btnPause);
            this.openWiFiSettingsButton = this.FindViewById<Button>(Resource.Id.btnWifi);
            this.resumeOnCellDataButton = this.FindViewById<Button>(Resource.Id.btnResumeCell);

            this.pauseButton.Click += delegate
                {
                    if (this.isPaused)
                        this.downloaderService.RequestContinueDownload();
                    else
                        this.downloaderService.RequestPauseDownload();
                    this.UpdatePauseButton(!this.isPaused);
                };
            this.openWiFiSettingsButton.Click += delegate { this.StartActivity(new Intent(Settings.ActionWifiSettings)); };
            this.resumeOnCellDataButton.Click += delegate
                {
                    this.downloaderService.SetDownloadFlags(ServiceFlags.FlagsDownloadOverCellular);
                    this.downloaderService.RequestContinueDownload();
                    this.useCellDataView.Visibility = ViewStates.Gone;
                };

            this.dashboardView.Visibility = ViewStates.Gone;
            this.useCellDataView.Visibility = ViewStates.Gone;

            var delivered = this.AreExpansionFilesDelivered();

            if (delivered)
            {
                this.statusTextView.Text = "Download Complete!";
            }
            else if (!this.GetExpansionFiles())
            {
                this.downloaderServiceConnection = ClientMarshaller.CreateStub(this, typeof(SampleDownloaderService));
            }
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        private bool GetExpansionFiles()
        {
            bool result = false;

            // Build the intent that launches this activity.
            Intent launchIntent = this.Intent;
            var    intent       = new Intent(this, typeof(SuperSimpleActivity));

            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.
            PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.UpdateCurrent);

            // Request to start the download
            DownloadServiceRequirement 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)
            {
                this.downloaderServiceConnection = ClientMarshaller.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));
 }
Esempio n. 8
0
 /// <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()
 {
     this.InitializeControls();
     this.downloaderServiceConnection = ClientMarshaller.CreateStub(
         this, typeof(SampleDownloaderService));
 }
 /// <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()
 {
     this.InitializeControls();
     this.downloaderServiceConnection = ClientMarshaller.CreateStub(
         this, typeof(SampleDownloaderService));
 }
        private bool GetExpansionFiles()
        {
            bool result = false;

            // Build the intent that launches this activity.
            Intent launchIntent = this.Intent;
            var intent = new Intent(this, typeof(SuperSimpleActivity));
            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.
            PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.UpdateCurrent);

            // Request to start the download
            DownloadServiceRequirement 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)
            {
                this.downloaderServiceConnection = ClientMarshaller.CreateStub(this, typeof(SampleDownloaderService));

                result = true;
            }

            return result;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DownloaderService"/> class.
        /// </summary>
        protected DownloaderService()
            : base("LVLDownloadService")
        {
            Log.Debug(Tag,"LVLDL DownloaderService()");

            this.serviceConnection = ServiceMarshaller.CreateStub(this);
            this.serviceMessenger = this.serviceConnection.GetMessenger();

            this.Control = DownloadsDatabase.DownloadStatus == DownloadStatus.PausedByApp
                               ? ControlAction.Paused
                               : ControlAction.Run;
        }
Esempio n. 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //se ci sono documenti integrati controllo se è la prima volta che l'app viene lanciata
            //se è la prima volta importo i documenti altrimenti l'app prosegue normalmente
            //se non ci sono documenti integrati cerco il file di espansione

            AssetManager am = Resources.Assets;

            if (am.List("pub").Length > 0)
            {
                if (!DataManager.Get <IPreferencesManager>().Preferences.DocImported)
                {
                    _progressDialog = new ProgressDialog(this);

                    var importTask = new AnonymousAsyncTask <string, string, bool>((p) =>
                    {
                        RunOnUiThread(() =>
                        {
                            _progressDialog.Indeterminate = true;
                            _progressDialog.SetProgressPercentFormat(null);
                            _progressDialog.SetMessage(GetString(Resource.String.apkDown_loadResources));
                            _progressDialog.Show();
                        });

                        FileSystemManager.ImportDocuments();

                        return(true);
                    }, (bd) =>
                    {
                        StartApp();
                    });

                    importTask.Execute(new Java.Lang.Object[] { });
                }
                else
                {
                    StartApp();
                }
            }
            else
            {
                StartApp();
                _progressDialog = new ProgressDialog(this);
                _progressDialog.SetMessage("");
                _progressDialog.SetTitle(GetString(Resource.String.apkDown_downResources));
                _progressDialog.SetCancelable(false);
                _progressDialog.SetProgressStyle(ProgressDialogStyle.Horizontal);
                _progressDialog.Indeterminate = false;
                _progressDialog.SetProgressNumberFormat(null);

                _progressDialog.Show();

                var delivered = this.AreExpansionFilesDelivered();

                if (delivered)
                {
                    _progressDialog.SetMessage(GetString(Resource.String.apkDown_completed));
                    CheckDownloadedFile();
                }
                else if (!this.GetExpansionFiles())
                {
                    this.downloaderServiceConnection = ClientMarshaller.CreateStub(this, typeof(MyDownloaderService));
                }
            }
        }
 private void InitializeDownloadUI()
 {
     InitializeControls();
     downloaderServiceConnection = ClientMarshaller.CreateStub(this, typeof(LibraryDownloaderService));
 }
        /// <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 = ClientMarshaller.CreateStub(this, typeof(MediaDownloadService));
        }