//location ends here protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MAIN_); locMgr = GetSystemService(Context.LocationService) as LocationManager; cityTextGlobal = null; FindViewById <Button>(Resource.Id.get_address_button).Click += FindLocBN_clicked; FindViewById <Button>(Resource.Id.EnterYourCity).Click += MAIN_Activity_Click; FindViewById <Button>(Resource.Id.closeBN).Click += MAIN_Activity_Click1; //Create the DB: DB.myDBRepo dbr = new DB.myDBRepo(); dbr.CreateDB(); //Create table: dbr.CreateTable(); dbr.CreateIndicatorTable(); //fonts var ORtextView = FindViewById <TextView>(Resource.Id.ORtextView); var enterBN = FindViewById <Button>(Resource.Id.EnterYourCity); Typeface tf = Typeface.CreateFromAsset(Assets, "dosis.book.ttf"); ORtextView.SetTypeface(tf, TypefaceStyle.Bold); enterBN.SetTypeface(tf, TypefaceStyle.Bold); //fonts ended //InitializeLocationManager(); }
public async void FindLocBN_clicked(object sender, EventArgs e) { InitializeLocationManager(); if (isGPSenabled == false) { turnGPSon(); } else { cityButtonPressedIndicGlob = false; cityTextGlobal = null; ipressedGlob = false; if (_currentLocation == null) { _addressTextGlobalVariable = "Can't determine the current address. Try again in a few minutes."; } try { Address address = await ReverseGeocodeCurrentLocation(); DisplayAddress(address); //spliting string with coordinates string[] values = _locationTextGlobalVariable.Split(','); for (int i = 0; i < values.Length; i++) { values[i] = values[i].Trim(); if (i == 0) { _x = values[i]; } if (i == 1) { _y = values[i]; } } //Insert Coordinates to DB DB.myDBRepo dbr = new DB.myDBRepo(); dbr.InsertCoordinates(_x, _y); dbr.InsertcityOrCoordIndicator("coord"); StartActivity(new Intent(this, typeof(LoadingActivity))); } catch { Toast.MakeText(this, "Determination failed", ToastLength.Short).Show(); } } }
private void MAIN_Activity_Click(object sender, EventArgs e) { InitializeLocationManager(); firstAppLaunchGlob = false; cityButtonPressedIndicGlob = true; ipressedGlob = true; cityTextGlobal = FindViewById <EditText>(Resource.Id.cityNameET).Text; //Insert city to db DB.myDBRepo dbr = new DB.myDBRepo(); dbr.InsertcityOrCoordIndicator("city"); if (cityTextGlobal == null || cityTextGlobal == "" || cityTextGlobal == " " || cityTextGlobal == " ") { Toast.MakeText(this, "Enter your city name", ToastLength.Long).Show(); } else { StartActivity(new Intent(this, typeof(LoadingActivity))); } }
/* * 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); } }; }