Exemple #1
0
        private void CopyDownloadedFile(string path)
        {
            if (System.IO.File.Exists(path))
            {
                var importTask = new AnonymousAsyncTask <string, string, bool>((p) =>
                {
                    RunOnUiThread(() => {
                        _progressDialog.Indeterminate = true;
                        _progressDialog.SetProgressPercentFormat(null);
                        _progressDialog.SetMessage(GetString(Resource.String.apkDown_loadResources));
                    });

                    System.IO.FileInfo fi = new System.IO.FileInfo(path);

                    string destFile = DataManager.Get <ISettingsManager>().Settings.SharedPath + "/" + fi.Name.Replace(fi.Extension, "") + ".mb";

                    System.IO.File.Copy(path, destFile);

                    FileSystemManager.ImportDocuments();

                    DataManager.Get <IPreferencesManager>().Preferences.ApkDownloaded = fi.Name;
                    DataManager.Get <IPreferencesManager>().Save();

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

                importTask.Execute(new Java.Lang.Object[] {});
            }
        }
Exemple #2
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));
                }
            }
        }