/* * protected override void OnResume() * { * base.OnResume(); * * Toast.MakeText(this, "OnResume", ToastLength.Short).Show(); * } */ protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); var db = new SQLiteConnection(dbPath); //fonts var textview1 = FindViewById <TextView>(Resource.Id.location_text); var textview2 = FindViewById <TextView>(Resource.Id.address_text); var textview3 = FindViewById <TextView>(Resource.Id.city); var textview4 = FindViewById <TextView>(Resource.Id.temperature); var textview5 = FindViewById <TextView>(Resource.Id.dataTextView); var textview6 = FindViewById <TextView>(Resource.Id.weatherDescriptionTextView); var textview7 = FindViewById <TextView>(Resource.Id.windSpeedTextView); Typeface tf = Typeface.CreateFromAsset(Assets, "dosis.book.ttf"); textview1.SetTypeface(tf, TypefaceStyle.Bold); textview2.SetTypeface(tf, TypefaceStyle.Bold); textview3.SetTypeface(tf, TypefaceStyle.Bold); textview4.SetTypeface(tf, TypefaceStyle.Bold); textview5.SetTypeface(tf, TypefaceStyle.Bold); textview6.SetTypeface(tf, TypefaceStyle.Bold); textview7.SetTypeface(tf, TypefaceStyle.Bold); //fonts ended textview6.Text = pref.GetString("weatherDescGlob", String.Empty); //current data getCurrentData(); //current data ended MAIN_Activity.firstAppLaunchGlob = false; //mToolbar = FindViewById<SupportToolbar>(Resource.Id.toolbar); mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); mLeftDrawer = FindViewById <ListView>(Resource.Id.left_drawer); //LISTVIEW WITH IMAGE libros.Add(new clases.cls_Libro(1, "Home", "PATRICIA BRIGGS1", 350, 100)); libros.Add(new clases.cls_Libro(2, "Edit", "PATRICIA BRIGGS2", 430, 70)); libros.Add(new clases.cls_Libro(3, "Settings", "PATRICIA BRIGGS3", 350, 100)); libros.Add(new clases.cls_Libro(4, "Report", "PATRICIA BRIGGS4", 350, 100)); ListView lwLibros = FindViewById <ListView>(Resource.Id.left_drawer); lwLibros.Adapter = new adapter.adapter_listview(this, libros); //LISTVIEW WITH IMAGE ENDS HERE //mToolbar.SetBackgroundResource(Resource.Drawable.toolbar); //SetSupportActionBar(mToolbar); mDrawerToggle = new MYActionBarDrawerToggle(this, mDrawerLayout, Resource.String.openDrawer, Resource.String.closeDrawer); //mDrawerLayout.SetDrawerListener(mDrawerToggle); //SupportActionBar.SetHomeButtonEnabled(true); //IMPORTANT COMMENT!!!!!!!!!! /* * John Mckay3 месяца назад (изменено) * Great work as always, but as mentioned in another comment, * I had to call SupportActionBar.SetDisplayHomeAsUpEnabled(true); instead of SupportActionBar.SetDisplayShowTitleEnabled(true); to get the icon to show */ //SupportActionBar.SetDisplayHomeAsUpEnabled(true); //mDrawerToggle.SyncState(); mLeftDrawer.ItemClick += MLeftDrawer_ItemClick; city_or_coord(); var table = db.Table <DB.city>(); foreach (var i in table) { if (pref.GetString("City", String.Empty) == i.City) { dbr.RemoveCity(i.Id); } } dbr.InsertCity((pref.GetString("City", String.Empty))); if (MAIN_Activity.cityButtonPressedIndicGlob == false) { FindViewById <TextView>(Resource.Id.address_text).Text = pref.GetString("addressTextGlobalVariable", String.Empty); FindViewById <TextView>(Resource.Id.location_text).Text = pref.GetString("locationTextGlobalVariable", String.Empty); } else { FindViewById <TextView>(Resource.Id.address_text).Text = ""; FindViewById <TextView>(Resource.Id.location_text).Text = ""; } if (dbr.GetAllRecordsC_F() == "celsius") { FindViewById <TextView>(Resource.Id.temperature).Text = pref.GetString("tempGlobal", String.Empty) + "° C"; textview7.Text = "wind speed: " + pref.GetString("windSpeedGlob", String.Empty) + " m/s"; } else { FindViewById <TextView>(Resource.Id.temperature).Text = pref.GetString("tempGlobal", String.Empty) + "° F"; textview7.Text = "wind speed: " + pref.GetString("windSpeedGlob", String.Empty) + " mph"; } FindViewById <TextView>(Resource.Id.city).Text = pref.GetString("City", String.Empty); imageMeth(); FindViewById <Button>(Resource.Id.closeBN).Click += MainActivity_Click; //button to open Left Drawer FindViewById <Button>(Resource.Id.leftDrawerBN).Click += delegate { if (mDrawerLayout.IsDrawerOpen(mLeftDrawer)) { mDrawerLayout.CloseDrawer(mLeftDrawer); } else { mDrawerLayout.OpenDrawer(mLeftDrawer); } }; }
/* * protected override void OnResume() * { * base.OnResume(); * * Toast.MakeText(this, "OnResumeLoading", ToastLength.Short).Show(); * } */ protected override void OnCreate(Bundle savedInstanceState) { MobileCenter.Start("005f8f23-ea2c-48ac-962f-b4929664c618", typeof(Analytics), typeof(Crashes)); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.anim_layout); var restartBn = FindViewById <Button>(Resource.Id.restartBN); //using plugin when it is the first app launch CrossVersionTracking.Current.Track(); var vt = CrossVersionTracking.Current; vt.OnFirstLaunchOfVersion("1.0", () => firstMethod()); //using plugin when it is the first app launch ended //checking internet connection ConnectivityManager connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService); NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo; bool isOnline = (activeConnection != null) && activeConnection.IsConnected; //checking internet connection ended if (isOnline == true) { restartBn.Visibility = ViewStates.Gone; /*_x = MAIN_Activity._x; * _y = MAIN_Activity._y;*/ //Create the DB: DB.myDBRepo dbr = new DB.myDBRepo(); dbr.CreateDB(); //Create table: dbr.CreateTable(); dbr.CreateTableC_F(); dbr.CreateIndicatorTable(); dbr.CreateCoordsTable(); //setting celsiusOr_fahrenheit by default if (dbr.GetAllRecordsC_F() == "celsius") { SettingsActivity.c_f_Global = "celsius"; } else { SettingsActivity.c_f_Global = "fahrenheit"; } //setting celsiusOr_fahrenheit by default ended if (MAIN_Activity.firstAppLaunchGlob == false && MAIN_Activity.ipressedGlob == false) { dbr.GetAllRecords(); } Animation myAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.MyAnimation); ImageView myImage = FindViewById <ImageView>(Resource.Id.imageView1); myImage.StartAnimation(myAnimation); dbr.CreateIndicatorTable(); string dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "MyDB.db3"); var db = new SQLiteConnection(dbPath); var cityOrCoordIndicator = db.Table <DB.cityOrCoordIndicator>(); MainActivity ma = new MainActivity(); ma.city_or_coord(); if (MAIN_Activity.cityButtonPressedIndicGlob == false) { var coordinates = db.Table <DB.coordinates>(); foreach (var b in coordinates) { _x = b._X; _y = b._Y; } } if (MAIN_Activity.firstAppLaunchGlob == false) { Displaying(); } ISharedPreferences pref = Application.Context.GetSharedPreferences("WeatherData", FileCreationMode.Private); ISharedPreferencesEditor edit = pref.Edit(); if (MAIN_Activity._addressTextGlobalVariable != null) { edit.PutString("addressTextGlobalVariable", MAIN_Activity._addressTextGlobalVariable); } if (MAIN_Activity._locationTextGlobalVariable != null) { edit.PutString("locationTextGlobalVariable", MAIN_Activity._locationTextGlobalVariable); } edit.Apply(); } else { if (MAIN_Activity.firstAppLaunchGlob == false) { Toast.MakeText(this, "No Internet Connection.\nTurn the Internet connection on and click \"Restart\"", ToastLength.Long).Show(); } //fonts Typeface tf = Typeface.CreateFromAsset(Assets, "dosis.book.ttf"); restartBn.SetTypeface(tf, TypefaceStyle.Bold); //fonts ended restartBn.Visibility = ViewStates.Visible; restartBn.Click += RestartBn_Click; } deleteIncorrectCity(); FindViewById <Button>(Resource.Id.closeBN).Click += LoadingActivity_Click; FindViewById <Button>(Resource.Id.editBN).Click += LoadingActivity_Click1; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.settings); //fonts var textview1 = FindViewById <TextView>(Resource.Id.textView1); var radiobutton1 = FindViewById <RadioButton>(Resource.Id.celsiusRB); var radiobutton2 = FindViewById <RadioButton>(Resource.Id.FahrenheitRB); var textView2 = FindViewById <TextView>(Resource.Id.textView2); Typeface tf = Typeface.CreateFromAsset(Assets, "dosis.book.ttf"); textview1.SetTypeface(tf, TypefaceStyle.Bold); radiobutton1.SetTypeface(tf, TypefaceStyle.Bold); radiobutton2.SetTypeface(tf, TypefaceStyle.Bold); textView2.SetTypeface(tf, TypefaceStyle.Bold); //fonts ended DB.myDBRepo dbr = new DB.myDBRepo(); // mToolbar = FindViewById<SupportToolbar>(Resource.Id.toolbar); mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); mLeftDrawer = FindViewById <ListView>(Resource.Id.left_drawer); //LISTVIEW WITH IMAGE libros.Add(new clases.cls_Libro(1, "Home", "PATRICIA BRIGGS1", 350, 100)); libros.Add(new clases.cls_Libro(2, "Edit", "PATRICIA BRIGGS2", 430, 70)); libros.Add(new clases.cls_Libro(3, "Settings", "PATRICIA BRIGGS3", 350, 100)); libros.Add(new clases.cls_Libro(4, "Report", "PATRICIA BRIGGS4", 350, 100)); ListView lwLibros = FindViewById <ListView>(Resource.Id.left_drawer); lwLibros.Adapter = new adapter.adapter_listview(this, libros); //LISTVIEW WITH IMAGE ENDS HERE //mToolbar.SetBackgroundResource(Resource.Drawable.toolbar); //SetSupportActionBar(mToolbar); mDrawerToggle = new MYActionBarDrawerToggle(this, mDrawerLayout, Resource.String.openDrawer, Resource.String.closeDrawer); //mDrawerLayout.SetDrawerListener(mDrawerToggle); //SupportActionBar.SetHomeButtonEnabled(true); //IMPORTANT COMMENT!!!!!!!!!! /* * John Mckay3 мес¤ца назад (изменено) * Great work as always, but as mentioned in another comment, * I had to call SupportActionBar.SetDisplayHomeAsUpEnabled(true); instead of SupportActionBar.SetDisplayShowTitleEnabled(true); to get the icon to show */ //SupportActionBar.SetDisplayHomeAsUpEnabled(true); //mDrawerToggle.SyncState(); mLeftDrawer.ItemClick += MLeftDrawer_ItemClick; //Radiogroup RadioGroup radioGroup = FindViewById <RadioGroup>(Resource.Id.radioGroup1); FindViewById <RadioButton>(Resource.Id.celsiusRB).Click += delegate { c_f_Global = "celsius"; dbr.InsertCelsius_Fahrenheit("celsius"); }; FindViewById <RadioButton>(Resource.Id.FahrenheitRB).Click += delegate { c_f_Global = "fahrenheit"; dbr.InsertCelsius_Fahrenheit("fahrenheit"); }; //this snippet sets radiobutton by default if (dbr.GetAllRecordsC_F() == "celsius") { FindViewById <RadioButton>(Resource.Id.celsiusRB).Checked = true; } else { FindViewById <RadioButton>(Resource.Id.FahrenheitRB).Checked = true; } //this snippet sets radiobutton by default ended //Radiogroup ended /*FindViewById<Button>(Resource.Id.button1).Click += delegate * { * Toast.MakeText(this, dbr.GetAllRecordsC_F(), ToastLength.Short).Show(); * };*/ FindViewById <Button>(Resource.Id.closeBN).Click += SettingsActivity_Click; //button to open Left Drawer FindViewById <Button>(Resource.Id.leftDrawerBN).Click += delegate { if (mDrawerLayout.IsDrawerOpen(mLeftDrawer)) { mDrawerLayout.CloseDrawer(mLeftDrawer); } else { mDrawerLayout.OpenDrawer(mLeftDrawer); } }; }