Exemplo n.º 1
0
 private void ApiListener_Success(object sender, object CovidResult)
 {
     DebugHelper.Method(MethodBase.GetCurrentMethod());
     if (CovidResult is CovidReport)
     {
         this.GlobalReport = (CovidReport)CovidResult;
         SharedPreferencesHandler.SaveGlobalReport(this, this.GlobalReport);
     }
     else if (CovidResult is IEnumerable <CovidCountryReport> )
     {
         this.CountriesReport = ((IEnumerable <CovidCountryReport>)CovidResult).ToList();
         if (this.HasCachedReport)
         {
             this.CountriesReport.LoadFavouritesFromPreferences(this);
         }
         SharedPreferencesHandler.SaveCountriesReport(this, this.CountriesReport);
     }
     else if (CovidResult is CountryTimeseriesContainer)
     {
         //@ToDo cache the timeseries. It's too big for SharedPreferences. Probably SQLite.
         //SharedPreferencesHandler.SaveCountryTimeseriesContainer(this, (CountryTimeseriesContainer)CovidResult);
     }
     if (this.AllDone)
     {
         GoToMain();
     }
 }
Exemplo n.º 2
0
 public override bool OnPreferenceTreeClick(Android.Support.V7.Preferences.Preference preference)
 {
     if (!(preference is SwitchPreferenceCompat Pref))
     {
         return(false);
     }
     SharedPreferencesHandler.SetUseDarkTheme(this.Context, Pref.Checked);
     return(true);
 }
Exemplo n.º 3
0
        private bool CacheIsRecent()
        {
            return(false);

            DebugHelper.Method(MethodBase.GetCurrentMethod());
            DateTime?GlobalStamp      = SharedPreferencesHandler.GetGlobalReportStamp(this);
            DateTime?ByCountriesStamp = SharedPreferencesHandler.GetCountriesReportStamp(this);
            DateTime?TimeseriesStamp  = SharedPreferencesHandler.GetTimeseriesStamp(this);

            if (GlobalStamp is null || ByCountriesStamp is null || TimeseriesStamp is null)
            {
                return(false);
            }
            return(LessThanNDaysAgo((DateTime)GlobalStamp) && LessThanNDaysAgo((DateTime)ByCountriesStamp) && LessThanNDaysAgo((DateTime)TimeseriesStamp));
        }
Exemplo n.º 4
0
 void LoadDataFromCache()
 {
     try
     {
         DebugHelper.Method(MethodBase.GetCurrentMethod());
         this.GlobalReport    = SharedPreferencesHandler.GetCovidReport(this);
         this.CountriesReport = SharedPreferencesHandler.GetCountriesReport(this);
     }
     catch (Exception ex)
     {
         DebugHelper.Error(ex);
         Toast.MakeText(this, Resources.GetString(Resource.String.impossible_to_start), ToastLength.Short);
         Finish();
     }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            DebugHelper.Method(MethodBase.GetCurrentMethod());
            Log.Debug(this.Tag, "google app id: " + GetString(Resource.String.google_app_id));
            base.OnCreate(savedInstanceState);
            if (SharedPreferencesHandler.ShouldUseDarkTheme(this))
            {
                SetTheme(Resource.Style.AppTheme_Dark);
            }
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            GetBoundleData();
            InitControls();
            InitFirebase();
            LoadBoundleData();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            if (SharedPreferencesHandler.ShouldUseDarkTheme(this))
            {
                SetTheme(Resource.Style.AppTheme_Dark);
            }
            SetContentView(Resource.Layout.charts_view);
            this.Report     = Intent.GetStringExtra(nameof(Report)).FromJson <CovidCountryReport>();
            ChartTypesArray = Resources.GetStringArray(Resource.Array.chart_types);

            spinnerChartType               = FindViewById <Spinner>(Resource.Id.spinnerChartType);
            spinnerChartType.Adapter       = new ArrayAdapter <string>(this, Resource.Layout.list_item, ChartTypesArray);
            spinnerChartType.ItemSelected += SpinnerChartType_ItemSelected;


            howManyDaysSpinner               = FindViewById <Spinner>(Resource.Id.spinnerDaysSpan);
            howManyDaysSpinner.Adapter       = new ArrayAdapter <int>(this, Resource.Layout.list_item, new [] { 5, 10, 20, 30, 60 });
            howManyDaysSpinner.ItemSelected += HowManyDaysSpinner_ItemSelected;

            txtProgressionTitle      = FindViewById <TextView>(Resource.Id.txtProgressionTitle);
            txtProgressionTitle.Text = $"{Resources.GetString(Resource.String.progressions)} {Report.RegionalFriendlyName ?? Report.Country}";
        }
 protected override void OnPause()
 {
     DebugHelper.Method(MethodBase.GetCurrentMethod());
     base.OnPause();
     SharedPreferencesHandler.SaveCountriesReport(this, this.CountriesReport);
 }