示例#1
0
        protected override void OnResume()
        {
            try
            {
                base.OnResume();

                AskForPermissions.askForWriteExternalStoragePermission(this);

                //Register Light Sensor Manager
                DynamicUIBuild_Utils.RegisterLightSensor(m_sensorManager, m_sensorListener);
            }
            catch (Exception e)
            {
                MobileCenter_Helper.ReportError(new FileAccessManager(), e, GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
        }
示例#2
0
        private Trajet AddtrajetForTest()
        {
            Trajet test = new Trajet();

            test.m_sRefNumber     = "B";
            test.m_datetrajet     = DateTime.Now;
            test.m_sLocationStart = "Grenoble - Presqu'île";
            test.m_sLocationEnd   = "Plaine des Sports";
            test.m_sTimeStart     = "6:57";
            test.m_sTimeEnd       = "7:34";
            test.m_sTrainType     = "Tramway";
            test.m_sLocoType      = "Electrique";
            test.m_sWeight        = "56";
            test.m_lsarret        = new List <Arret>();
            test.m_lsarret.Add(new Arret("Grenoble - Presqu'île", "0", "", "", 0, "6:57", "", "", "", 45.204441, 5.701218, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Cité Internationale", "0", "", "", 0, "7:00", "", "", "", 45.195042, 5.711121, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Palais de Justice", "0", "", "", 0, "7:03", "", "", "", 45.191158, 5.711664, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Saint Bruno", "0", "", "", 0, "7:05", "", "", "", 45.190149, 5.715212, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Gare", "0", "", "0", 5, "7:07", "", "", "V2", 45.190149, 5.715212, 7, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Alsace lorraine", "0", " ", "30", 0, "7:09", "", "", "V2", 45.189394, 5.720446, 2, false, "", "S", false));
            test.m_lsarret.Add(new Arret("Victor Hugo", "0", "", "70", 2, "7:11", "", "", "V2", 45.189799, 5.725152, 6, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Maison du tourisme", "0", "", "70", 8, "7:12", "", "", "V2", 45.190195, 5.728310, 2, false, "", "S", false));
            test.m_lsarret.Add(new Arret("Sainte Claire les halles", "0", "A2", "30", 0, "7:14", "", "", "BV2", 45.191323, 5.730705, 2, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Notre Dame Musée", "0", "", "0", 12, "7:15", "", "", "V2", 45.193565, 5.732215, 19, false, "", "S", false));
            test.m_lsarret.Add(new Arret("Île Verte", "0", "", "", 0, "7:16", "", "", "", 45.197286, 5.736712, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("La Tronche Hôpital", "0", "", "", 0, "7:17", "", "", "", 45.200633, 5.741139, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Michallon", "0", "", "", 0, "7:19", "", "", "", 45.200280, 5.745447, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Grand Sablon", "0", "", "", 0, "7:21", "", "", "", 45.198984, 5.749868, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Les Taillées-Universités", "0", "", "", 0, "7:23", "", "", "", 45.192195, 5.757836, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Gabriel Fauré", "0", "", "", 0, "7:25", "", "", "", 45.192288, 5.764456, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Bibliothèques Universitaires", "0", "", "", 0, "7:27", "", "", "", 45.192298, 5.770843, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Condillac-Universités", "0", "", "", 0, "7:29", "", "", "", 45.189128, 5.774377, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Mayencin Champ Roman", "0", "", "", 0, "7:31", "", "", "", 45.184743, 5.779055, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Gières Gare-Universités", "0", "", "", 0, "7:33", "", "", "", 45.185393, 5.785503, 0, true, "", "S", false));
            test.m_lsarret.Add(new Arret("Plaine des Sports", "0", "", "", 0, "7:34", "", "", "", 45.187521, 5.784426, 0, true, "", "S", false));

            //Recup pdf files from asset
            AssetManager  assetManager = Assets;
            List <string> lsfiles      = new List <string>();

            try
            {
                lsfiles = new List <string>(assetManager.List("PDF_forDemo"));
            }
            catch (Java.IO.IOException)
            { }
            catch (System.IO.IOException)
            { }

            //save pdf files to local storage : dans le dossier Downloads
            string outDir = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).AbsolutePath + "/pdf_Trajet_Tram";

            try
            {
                if (!AskForPermissions.askForWriteExternalStoragePermission(this, 48))
                {
                    return(null);
                }

                if (!System.IO.Directory.Exists(outDir))
                {
                    System.IO.Directory.CreateDirectory(outDir);
                }
                foreach (string sFileName in lsfiles)
                {
                    Stream     input  = null;
                    FileStream output = null;
                    try
                    {
                        input = assetManager.Open("PDF_forDemo/" + sFileName);

                        if (System.IO.File.Exists(outDir + "/" + sFileName))
                        {
                            System.IO.File.Delete(outDir + "/" + sFileName);
                        }

                        output = System.IO.File.Create(outDir + "/" + sFileName);

                        input.CopyTo(output);
                        output.Close();
                    }
                    catch (Java.IO.IOException)
                    { }
                    catch (System.IO.IOException)
                    { }
                }
            }
            catch (Exception e)
            {
                MobileCenter_Helper.ReportError(new FileAccessManager(), e, GetType().Name, MethodBase.GetCurrentMethod().Name);
                DynamicUIBuild_Utils.ShowSnackBar_WithOKButtonToClose(this, m_frameLayout, Resource.String.snackbar_errorHappened);
            }

            LocalDatabase.Get().Addtrajet(new FileAccessManager(), test);
            foreach (Arret p in test.m_lsarret)
            {
                p.m_iLocalIDtrajet = test.m_iLocalID;
                LocalDatabase.Get().AddArret(new FileAccessManager(), p);
            }

            //Refresh list if needed
            m_fragmentListtrajets?.RefreshtrajetList();

            return(test);
        }