Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            AppCenter.Start(AppCenterId, typeof(Crashes));

            var res    = ApplicationContext.Resources;
            var locale = new Java.Util.Locale("en");

            Java.Util.Locale.Default = locale;

            var config = new Configuration();

            config.Locale = locale;
            res.UpdateConfiguration(config, res.DisplayMetrics);

            SetContentView(Resource.Layout.activity_main);

            _location = Utility.GetPreferredLocation(this);
            _isMetric = Utility.IsMetric(this);


            if (FindViewById(Resource.Id.weather_detail_container) != null)
            {
                // The detail container view will be present only in the large-screen layouts
                // (res/layout-sw600dp). If this view is present, then the activity should be
                // in two-pane mode.

                _twoPane = true;
                // In two-pane mode, show the detail view in this activity by
                // adding or replacing the detail fragment using a
                // fragment transaction.
                if (savedInstanceState == null)
                {
                    SupportFragmentManager.BeginTransaction()
                    .Replace(Resource.Id.weather_detail_container, new DetailFragment(), DetailFragmentTag)
                    .Commit();
                }
            }
            else
            {
                _twoPane = false;
                SupportActionBar.Elevation = 0f;
            }

            var forecastFragment = ((ForecastFragment)SupportFragmentManager.FindFragmentById(Resource.Id.fragment_forecast));

            forecastFragment.SetUseTodayLayout(!_twoPane);
            SunshineSyncAdapter.InitializeSyncAdapter(this);
        }
Beispiel #2
0
 void UpdateWeather()
 {
     SunshineSyncAdapter.SyncImmediately(Activity);
 }