Example #1
0
        /// <summary>
        /// Retrieve the data needed to display the guide. 
        /// May connect to the server or need to download files, so has to be asynchronous
        /// </summary>
        private async void InitialiseData()
        {
            guide = (Guide)await AppData.Session.FetchActivityWithId(Intent.GetIntExtra("ActivityId", 0));
            string scenarioFormatted = guide.Title.Replace(" ", String.Empty).Replace("/", String.Empty);

            string documentsPath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).AbsolutePath + "/speeching";
            localResourcesDirectory = documentsPath + "/" + scenarioFormatted;

            // Create these directories if they don't already exist
            if (!Directory.Exists(documentsPath))
            {
                Directory.CreateDirectory(documentsPath);
            }

            // If the scenario folder doesn't exist we need to download the additional files
            if (!GetPrefs().GetBoolean("DOWNLOADED", false))
            {
                if (!Directory.Exists(localResourcesDirectory))
                {
                    Directory.CreateDirectory(localResourcesDirectory);
                }

                localZipPath = System.IO.Path.Combine(localResourcesDirectory, scenarioFormatted + ".zip");

                PrepareData();
            }
            else
            {
                // We need to populate the resources dictionary with the existing files
                string[] files = Directory.GetFiles(localResourcesDirectory);
                resources = new Dictionary<string, string>();

                for (int i = 0; i < files.Length; i++)
                {
                    resources.Add(System.IO.Path.GetFileName(files[i]), files[i]);
                }
                DisplayContent();
            }
        }
Example #2
0
 public GuideAdapter(Android.Support.V4.App.FragmentManager SupportFragmentManager, Guide.Page[] slides, Dictionary<string, string> resources)
     : base(SupportFragmentManager)
 {
     this.SupportFragmentManager = SupportFragmentManager;
     this.slides = slides;
     this.resources = resources;
 }