/// <summary>
 /// Retrieves application settings of types bool, float, int, long, ICollection<string> and string
 /// </summary>
 /// <param name="key">Settings Key</param>
 /// <returns>Application Settings of types bool, float, int, long, ICollection<string> or string</returns>
 public T GetSetting <T>(string key)
 {
     if (typeof(T) == typeof(bool))
     {
         return((T)(object)_sharedPreferences.GetBoolean(key, false));
     }
     else if (typeof(T) == typeof(float))
     {
         return((T)(object)_sharedPreferences.GetFloat(key, float.MinValue));
     }
     else if (typeof(T) == typeof(int))
     {
         return((T)(object)_sharedPreferences.GetInt(key, int.MinValue));
     }
     else if (typeof(T) == typeof(long))
     {
         return((T)(object)_sharedPreferences.GetFloat(key, long.MinValue));
     }
     else if (typeof(T) == typeof(ICollection <string>))
     {
         return((T)(object)_sharedPreferences.GetStringSet(key, null));
     }
     else
     {
         return((T)(object)_sharedPreferences.GetString(key, string.Empty));
     }
 }
Beispiel #2
0
        private void GetPreferences()
        {
            EditText txtPurchasePrice = FindViewById <EditText>(Resource.Id.txtPurchasePrice);
            EditText txtDownPayment   = FindViewById <EditText>(Resource.Id.txtDownPayment);
            EditText txtInterestRate  = FindViewById <EditText>(Resource.Id.txtInterestRate);

            //to do only on startup
            PreferenceManager.GetDefaultSharedPreferences(Application.Context).Dispose();
            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
            ISharedPreferencesEditor editor = prefs.Edit();

            editor.Clear();
            editor.Apply();
            //************************************************************************************

            double purchasePrice = prefs.GetFloat("purchase_price_key", 0);
            double deposit       = prefs.GetFloat("down_payment_key", 0);
            double interestRate  = prefs.GetFloat("interest_rate_key", 0);

            if (purchasePrice != 0)
            {
                txtPurchasePrice.Text = Convert.ToString(purchasePrice);
            }
            txtDownPayment.Text  = Convert.ToString(deposit);
            txtInterestRate.Text = Convert.ToString(interestRate);
        }
Beispiel #3
0
        public void LoadData(Context context)
        {
            _context = context;

            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context);

            var categoriesAsCollection = prefs.GetStringSet("Categories", GetDefaultCategories());

            Categories.Clear();
            foreach (var i in categoriesAsCollection)
            {
                Categories.Add(Enum.Parse <PoiCategory>(i));
            }

            IsViewAngleCorrection = prefs.GetBoolean("IsViewAngleCorrection", false);

            CorrectionViewAngleHorizontal = prefs.GetFloat("CorrectionViewAngleHorizontal", 0);
            CorrectionViewAngleVertical   = prefs.GetFloat("CorrectionViewAngleVertical", 0);

            AltitudeFromElevationMap = prefs.GetBoolean("AltitudeFromElevationMap", true);
            AutoElevationProfile     = prefs.GetBoolean("AutoElevationProfile", true);

            PrivacyPolicyApprovementLevel = prefs.GetInt("PrivacyPolicyApprovementLevel", 0);

            {
                var isTutorialNeeded = prefs.GetBoolean("ShowTutorialMainActivity", true);
                SetTutorialNeeded(TutorialPart.MainActivity, isTutorialNeeded);
            }
            {
                var isTutorialNeeded = prefs.GetBoolean("ShowTutorialPhotoEditActivity", true);
                SetTutorialNeeded(TutorialPart.PhotoEditActivity, isTutorialNeeded);
            }
            {
                var isTutorialNeeded = prefs.GetBoolean("ShowTutorialPhotoShowActivity", true);
                SetTutorialNeeded(TutorialPart.PhotoShowActivity, isTutorialNeeded);
            }

            CameraResolutionSelected = new Android.Util.Size(prefs.GetInt("CameraResolutionWidth", 0), prefs.GetInt("CameraResolutionHeight", 0));
            CameraId = prefs.GetString("CameraId", null);

            string lan = prefs.GetString("Language", "");

            if (!Enum.TryParse <Language>(lan, out Language))
            {
                Language = PoiCountryHelper.GetDefaultLanguage();
            }

            _applicationRatingCompleted = prefs.GetBoolean("ApplicationRatingCompleted", false);
            string applicationRatingQuestionDateAsString = prefs.GetString("ApplicationRatingQuestionDate", null);

            if (DateTime.TryParse(applicationRatingQuestionDateAsString, out var applicationRatingQuestionDateAsDate))
            {
                _applicationRatingQuestionDate = applicationRatingQuestionDateAsDate;
            }


            ShowElevationProfile = AutoElevationProfile;
        }
        private void getSharedPreferences()
        {
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);

            purchasePrice = prefs.GetFloat("purchase_price_key", 0);
            initialAmount = prefs.GetFloat("down_payment_key", 0);
            interestRate  = prefs.GetFloat("interest_rate_key", 0);
            rentReceived  = prefs.GetFloat("rent_received_key", 0);
        }
Beispiel #5
0
        private void ActionStartPause(object sender, EventArgs e)
        {
            if (!_locationManager.IsProviderEnabled(LocationManager.GpsProvider))
            {
                ShowMessageBox(null, Constants.MSG_GPS_DISABLED);
                return;
            }

            if (pState == PRACTICE_STATE.ready)
            {
                StartTimer();

                btnStartPause.SetBackgroundResource(Resource.Drawable.resume_inactive);
                btnStop.Visibility = ViewStates.Visible;


                _locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 2000, 1, this);

                pState = PRACTICE_STATE.playing;

                try
                {
                    var      name = MemberModel.firstname + " " + MemberModel.lastname;
                    var      loc  = String.Format("{0},{1}", _currentLocation.Latitude, _currentLocation.Longitude);
                    DateTime dt   = DateTime.Now;
                    dist = contextPref.GetFloat("dist", 0f);
                    var country = MemberModel.country;

                    svc.updateMomgoData(name, loc, dt, true, AppSettings.DeviceUDID, 0f, true, AppSettings.UserID, country, dist, true, gainAlt, true, _currentLocation.Bearing, true, 1, true, pType.ToString(), Constants.SPEC_GROUP_TYPE);
                }
                catch (Exception err)
                {
                    //Toast.MakeText(this, err.ToString(), ToastLength.Long).Show();
                }
            }
            else if (pState == PRACTICE_STATE.playing)
            {
                btnStartPause.SetBackgroundResource(Resource.Drawable.resume_active);
                btnStop.Visibility = ViewStates.Visible;

                _locationManager.RemoveUpdates(this);

                pState = PRACTICE_STATE.pause;
            }
            else if (pState == PRACTICE_STATE.pause)
            {
                btnStartPause.SetBackgroundResource(Resource.Drawable.resume_inactive);
                btnStop.Visibility = ViewStates.Visible;

                _locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 2000, 1, this);

                pState = PRACTICE_STATE.playing;
            }
        }
Beispiel #6
0
        public Configuracao ObterConfiguracao()
        {
            ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            Configuracao       conf        = new Configuracao();

            conf.EnderecoServidor        = preferences.GetString("endereco_servidor", "");
            conf.PercentualMaximoGrafico = preferences.GetFloat("perccentual_maximo_grafico", 0);
            conf.TamanhoFonteGrafico     = preferences.GetFloat("tamanho_fonte_grafico", 0);

            return(conf);
        }
Beispiel #7
0
        /// <summary>
        /// Loads float by key ((If database is not exist, it will be created)(If there is no value by this key, returns default value)).
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="defValue">The default value.</param>
        /// <returns>Float by key (If database is not exist, or there is not any value by this key, returns default value).</returns>
        public override float LoadData(string key, float defValue)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return(defValue);
            }

            if (_preferences == null)
            {
                CreateIfNotExist();
            }

            return(_preferences.GetFloat(key, defValue));
        }
Beispiel #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.settings);
            preferences = Application.Context.GetSharedPreferences("TaxInfo", FileCreationMode.Private);

            saveSettingsTextView        = FindViewById <TextView>(Resource.Id.saveSettingsTextView);
            saveSettingsTextView.Click += SaveSettingsTextView_Click;

            mainTaxRateEditText = FindViewById <EditText>(Resource.Id.mainTaxRateEditText);

            tax1DescEditText       = FindViewById <EditText>(Resource.Id.tax1DescriptionEditText);
            tax1RateEditText       = FindViewById <EditText>(Resource.Id.tax1ValueEditText);
            tax1PercentRadioButton = FindViewById <RadioButton>(Resource.Id.tax1PercentRadioButton);
            tax1DollarsRadioButton = FindViewById <RadioButton>(Resource.Id.tax1DollarsRadioButton);
            tax1CountedCheckbox    = FindViewById <CheckBox>(Resource.Id.tax1OnlyTaxCheckbox);

            tax2DescEditText       = FindViewById <EditText>(Resource.Id.tax2DescriptionEditText);
            tax2RateEditText       = FindViewById <EditText>(Resource.Id.tax2ValueEditText);
            tax2PercentRadioButton = FindViewById <RadioButton>(Resource.Id.tax2PercentRadioButton);
            tax2DollarsRadioButton = FindViewById <RadioButton>(Resource.Id.tax2DollarsRadioButton);
            tax2CountedCheckbox    = FindViewById <CheckBox>(Resource.Id.tax2OnlyTaxCheckbox);

            tax3DescEditText       = FindViewById <EditText>(Resource.Id.tax3DescriptionEditText);
            tax3RateEditText       = FindViewById <EditText>(Resource.Id.tax3ValueEditText);
            tax3PercentRadioButton = FindViewById <RadioButton>(Resource.Id.tax3PercentRadioButton);
            tax3DollarsRadioButton = FindViewById <RadioButton>(Resource.Id.tax3DollarsRadioButton);
            tax3CountedCheckbox    = FindViewById <CheckBox>(Resource.Id.tax3OnlyTaxCheckbox);

            mainTaxRateEditText.Text = preferences.GetFloat("mainRate", 8.00f).ToString();

            tax1DescEditText.Text          = preferences.GetString("tax1Desc", "Recycle");
            tax1RateEditText.Text          = preferences.GetFloat("tax1Rate", 5.00f).ToString();
            tax1PercentRadioButton.Checked = preferences.GetBoolean("tax1IsPercent", false);
            tax1DollarsRadioButton.Checked = !preferences.GetBoolean("tax1IsPercent", false);
            tax1CountedCheckbox.Checked    = preferences.GetBoolean("tax1IsOnlyTax", false);

            tax2DescEditText.Text          = preferences.GetString("tax2Desc", "CRV");
            tax2RateEditText.Text          = preferences.GetFloat("tax2Rate", 0.05f).ToString();
            tax2PercentRadioButton.Checked = preferences.GetBoolean("tax2IsPercent", false);
            tax2DollarsRadioButton.Checked = !preferences.GetBoolean("tax2IsPercent", false);
            tax2CountedCheckbox.Checked    = preferences.GetBoolean("tax2IsOnlyTax", true);

            tax3DescEditText.Text          = preferences.GetString("tax3Desc", "Tobacco");
            tax3RateEditText.Text          = preferences.GetFloat("tax3Rate", 0.87f).ToString();
            tax3PercentRadioButton.Checked = preferences.GetBoolean("tax3IsPercent", false);
            tax3DollarsRadioButton.Checked = !preferences.GetBoolean("tax3IsPercent", false);
            tax3CountedCheckbox.Checked    = preferences.GetBoolean("tax3IsOnlyTax", false);
        }
Beispiel #9
0
        private Location GetOldLocation()
        {
            string locationProvider = LocationManager.NetworkProvider;

            ISharedPreferences prefs = GetSharedPreferences("PaketGlobalLocation.Droid", FileCreationMode.Private | FileCreationMode.MultiProcess); 

            float lat = prefs.GetFloat(LOCATION_LAT_KEY, 0);
            float lng = prefs.GetFloat(LOCATION_LON_KEY, 0);

            var locatation = new Location(locationProvider);

            locatation.Latitude  = lat;
            locatation.Longitude = lng;

            return(locatation);
        }
        public T GetValue <T>(String key)
        {
            Object result;

            switch (typeof(T).Name)
            {
            case "String":
                result = _sharedPreferences.GetString(key, default);
                break;

            case "Int32":
                result = _sharedPreferences.GetInt(key, default);
                break;

            case "Boolean":
                result = _sharedPreferences.GetBoolean(key, default);
                break;

            case "Single":
                result = _sharedPreferences.GetFloat(key, default);
                break;

            default:
                return(default);
            }

            return((T)Convert.ChangeType(result, typeof(T)));
        }
        public static T GetValue <T>(Context aContext, string aKey, T aDefaultValue)
        {
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(aContext);

            if (typeof(T) == typeof(string))
            {
                return((T)Convert.ChangeType(prefs.GetString(aKey, aDefaultValue as string), typeof(T)));
            }
            else if (typeof(T) == typeof(int))
            {
                return((T)Convert.ChangeType(prefs.GetInt(aKey, Convert.ToInt32(aDefaultValue)), typeof(T)));
            }
            else if (typeof(T) == typeof(float))
            {
                return((T)Convert.ChangeType(prefs.GetFloat(aKey, Convert.ToSingle(aDefaultValue)), typeof(T)));
            }
            else if (typeof(T) == typeof(bool))
            {
                return((T)Convert.ChangeType(prefs.GetBoolean(aKey, Convert.ToBoolean(aDefaultValue)), typeof(T)));
            }
            else
            {
                throw new Exception("T value type is not supported. Types: string, int, float, bool.");
            }
        }
        public object Get(string key, Type type)
        {
            var typeCode = Type.GetTypeCode(type);

            switch (typeCode)
            {
            case TypeCode.Boolean: return(preferences.GetBoolean(key, false));

            case TypeCode.String: return(preferences.GetString(key, null));

            case TypeCode.Single: return(preferences.GetFloat(key, 0));

            case TypeCode.Int64: return(preferences.GetLong(key, 0));

            case TypeCode.Int16:
            case TypeCode.Int32:
                return(preferences.GetInt(key, 0));

#if FEATURE_SERIALIZATION
            case TypeCode.Object:
            {
                var stringValue = preferences.GetString(key, null);
                return(serializationManager.Deserialize(stringValue, type));
            }
#endif

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #13
0
        private T Get <T>(string key, ISharedPreferences prefs)
        {
            object result = null;

            switch (Type.GetTypeCode(typeof(T)))
            {
            case TypeCode.Boolean:
                result = (bool)prefs.GetBoolean(key, false);
                break;

            case TypeCode.Int32:
                result = (int)prefs.GetInt(key, 0);
                break;

            case TypeCode.Single:
                result = (float)prefs.GetFloat(key, 0);
                break;

            case TypeCode.String:
                result = (string)prefs.GetString(key, string.Empty);
                break;

            default:
                throw new NotSupportedException($"{typeof(T)} is not supported.");
            }

            return((T)result);
        }
Beispiel #14
0
        /// <summary>
        /// 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值
        /// </summary>
        /// <returns>The parameter.</returns>
        /// <param name="context">Context.</param>
        /// <param name="key">Key.</param>
        /// <param name="defaultObject">Default object.</param>
        public static Object GetParam(Context context, String key, Object defaultObject)
        {
            String             type = defaultObject.GetType().Name;
            ISharedPreferences sp   = context.GetSharedPreferences(FILE_NAME, FileCreationMode.Private);

            if ("String".Equals(type))
            {
                return(sp.GetString(key, (String)defaultObject));
            }
            else if ("Integer".Equals(type))
            {
                return(sp.GetInt(key, Int32.Parse(defaultObject.ToString())));
            }
            else if ("Boolean".Equals(type))
            {
                return(sp.GetBoolean(key, bool.Parse(defaultObject.ToString())));
            }
            else if ("Float".Equals(type))
            {
                return(sp.GetFloat(key, float.Parse(defaultObject.ToString())));
            }
            else if ("Long".Equals(type))
            {
                return(sp.GetLong(key, long.Parse(defaultObject.ToString())));
            }

            return(null);
        }
        /// <summary>
        /// Returns a stored geofence by its ID, or returns null if it's not found
        /// </summary>
        /// <returns>A SimpleGeofence defined by its center and radius, or null if the ID is invalid</returns>
        /// <param name="id">The ID of a stored Geofence</param>
        public override GeofenceCircularRegion Get(String id)
        {
            // Get the latitude for the geofence identified by id, or INVALID_FLOAT_VALUE if it doesn't exist (similarly for the other values that follow)
            double lat                       = mPrefs.GetFloat(GetFieldKey(id, LatitudeGeofenceRegionKey), InvalidFloatValue);
            double lng                       = mPrefs.GetFloat(GetFieldKey(id, LongitudeGeofenceRegionKey), InvalidFloatValue);
            double radius                    = mPrefs.GetFloat(GetFieldKey(id, RadiusGeofenceRegionKey), InvalidFloatValue);
            bool   notifyOnEntry             = mPrefs.GetBoolean(GetFieldKey(id, NotifyOnEntryGeofenceRegionKey), false);
            bool   notifyOnExit              = mPrefs.GetBoolean(GetFieldKey(id, NotifyOnExitGeofenceRegionKey), false);
            bool   notifyOnStay              = mPrefs.GetBoolean(GetFieldKey(id, NotifyOnStayGeofenceRegionKey), false);
            string notificationEntryMessage  = mPrefs.GetString(GetFieldKey(id, NotificationEntryMessageGeofenceRegionKey), string.Empty);
            string notificationExitMessage   = mPrefs.GetString(GetFieldKey(id, NotificationExitMessageGeofenceRegionKey), string.Empty);
            string notificationStayMessage   = mPrefs.GetString(GetFieldKey(id, NotificationStayMessageGeofenceRegionKey), string.Empty);
            bool   showNotification          = mPrefs.GetBoolean(GetFieldKey(id, ShowNotificationGeofenceRegionKey), false);
            bool   persistent                = mPrefs.GetBoolean(GetFieldKey(id, PersistentGeofenceRegionKey), false);
            bool   showEntryNotification     = mPrefs.GetBoolean(GetFieldKey(id, ShowEntryNotificationGeofenceRegionKey), false);
            bool   showExitNotification      = mPrefs.GetBoolean(GetFieldKey(id, ShowExitNotificationGeofenceRegionKey), false);
            bool   showStayNotification      = mPrefs.GetBoolean(GetFieldKey(id, ShowStayNotificationGeofenceRegionKey), false);
            int    stayedInThresholdDuration = mPrefs.GetInt(GetFieldKey(id, StayedInThresholdDurationGeofenceRegionKey), InvalidIntValue);

            //long expirationDuration = mPrefs.GetLong(GetFieldKey(id, ExpirationDurationGeofenceRegionKey), InvalidLongValue);
            //int transitionType = mPrefs.GetInt(GetFieldKey(id, TransitionTypeGeofenceRegionKey), InvalidIntValue);

            // If none of the values is incorrect, return the object
            if (lat != InvalidFloatValue &&
                lng != InvalidFloatValue &&
                radius != InvalidFloatValue &&
                persistent &&
                stayedInThresholdDuration != InvalidIntValue
                // && expirationDuration != InvalidLongValue
                //&& transitionType != InvalidIntValue
                )
            {
                return new GeofenceCircularRegion(id, lat, lng, radius, notifyOnEntry, notifyOnExit, notifyOnStay, showNotification, persistent,
                                                  showEntryNotification, showExitNotification, showStayNotification)
                       {
                           NotificationEntryMessage = notificationEntryMessage,
                           NotificationStayMessage  = notificationStayMessage,
                           NotificationExitMessage  = notificationExitMessage,

                           StayedInThresholdDuration = TimeSpan.FromMilliseconds(stayedInThresholdDuration)
                       }
            }
            ;

            // Otherwise return null
            return(null);
        }
Beispiel #16
0
        static public float GetFloatSetting(string name, float defValue = -1)
        {
            var res = g_prefs.GetFloat(name, defValue);

            Console.WriteLine("GetFloatSetting {0}: {1} --> {2}",
                              Application.Context.ApplicationInfo.PackageName, name, res);
            return(res);
        }
 public double?GetDouble(string key)
 {
     if (_preferenceManager.Contains(key))
     {
         return(_preferenceManager.GetFloat(key, 0));
     }
     return(null);
 }
 /// <summary>
 ///  Retrieve an Float value from the mPreferences.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="defaultValue"></param>
 /// <returns></returns>
 public float GetFloat(string key, float defaultValue)
 {
     if (_preferences.Contains(ToKey(key)))
     {
         return(_preferences.GetFloat(ToKey(key), defaultValue));
     }
     return(defaultValue);
 }
Beispiel #19
0
        public static Money GetMoney(this ISharedPreferences sharedPref, string key)
        {
            sharedPref.CheckContains(key + AmountSuffix);
            var amount   = Convert.ToDecimal(sharedPref.GetFloat(key + AmountSuffix, 0));
            var currency = sharedPref.GetCurrency(key + CurrencySuffix);

            return(new Money(amount, currency));
        }
        /// <summary> Creates the achievement & loads data for the current progress </summary>
        /// <param name="id"></param>
        public Achievement(String id)
        {
            Id = id;
#if __ANDROID__
            ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(GameActivity.Instance);
            PercentageComplete = preferences.GetFloat($"{id}-Percentage", 0);
            Achieved           = preferences.GetBoolean($"{id}-Achieved", false);
#elif __IOS__
            PercentageComplete = NSUserDefaults.StandardUserDefaults.FloatForKey($"{id}-Percentage");
            Achieved           = NSUserDefaults.StandardUserDefaults.BoolForKey($"{id}-Achieved");
#endif
        }
Beispiel #21
0
        public void SaveAnimal(Android.Locations.Location l)
        {
            Animal a = new Animal(name.Text, desc.Text, uri);

            if (animalAndroid != null)
            {
                a.ID = animalAndroid.id;
            }

            if (l != null)
            {
                a.latitude = l.Latitude;
                a.altitude = l.Altitude;
            }
            else
            {
                ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Activity);

                var altitude = prefs.GetFloat("Altitude", float.MaxValue);
                var latitude = prefs.GetFloat("Latitude", float.MaxValue);
                a.latitude = latitude;
                a.altitude = altitude;
            }
            id = 0;
            var scientists = new List <ScientistAdded>();

            if (a.Subjects == null)
            {
                a.Subjects = new List <Scientist> ();
            }
            foreach (var scien in listAdapter.data)
            {
                if (scien.added)
                {
                    var scientist = DataManager.Instance.GetOnlyOneScientistForId(scien.id);
                    a.Subjects.Add(scientist);
                }
            }
            DataManager.Instance.AddAnimal(a);
        }
Beispiel #22
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.plazafoodlistlayout);
            listproductos = FindViewById <ListView>(Resource.Id.listproductosplaza);
            plazaname     = FindViewById <TextView>(Resource.Id.plazanamepage);
            carrito       = FindViewById <TextView>(Resource.Id.carrito);
            var idplaza             = Intent.GetStringExtra(IDPLAZA);
            var plazanombre         = Intent.GetStringExtra(NOMBREPLAZA);
            ISharedPreferences prof = PreferenceManager.GetDefaultSharedPreferences(this);
            var idproduct           = prof.GetString("IDPRODUCTO", "");
            var nombreproduct       = prof.GetString("NOMBREPRODUCTO", "");
            var idresta             = prof.GetString("IDRESTAURANTE", "");
            var precioproduct       = prof.GetFloat("PRECIOPRODUCTO", 0);
            var cantidadproduct     = prof.GetInt("CANTIDADPRODUCTO", 0);
            ISharedPreferences clos = PreferenceManager.GetDefaultSharedPreferences(this);
            var jee = clos.GetString("Usuario", "");

            plazaname.Text = plazanombre.ToString();



            string          sql = string.Format("Select * From TapFood.Producto where (IdPlaza = '{0}')", idplaza);
            MySqlCommand    exe = new MySqlCommand(sql, conn);
            MySqlDataReader reader;

            reader = exe.ExecuteReader();
            while (reader.Read())
            {
                Producto producto = new Producto();
                producto.IdProducto        = reader["IdProducto"].ToString();
                producto.NombreProducto    = reader["NombreProducto"].ToString();
                producto.IdRestaurante     = reader["IdRestaurante"].ToString();
                producto.NombreRestaurante = reader["NombreRestaurante"].ToString();
                producto.IdPlaza           = Convert.ToInt32(reader["IdPlaza"].ToString());
                producto.TipoDeComida      = reader["TipoDeComida"].ToString();
                producto.Descripcion       = reader["Descripcion"].ToString();
                producto.PrecioProducto    = Convert.ToInt32(reader["PrecioProducto"].ToString());
                producto.TiempoEntrega     = Convert.ToInt32(reader["TiempoEntrega"].ToString());
                producto.Descuento         = Convert.ToInt32(reader["Descuento"].ToString());
                producto.FotoProducto      = reader["FotoProducto"] as byte[];
                productos.Add(producto);
            }
            reader.Close();
            listproductos.Adapter    = new foodlistadapter(this, productos);
            listproductos.ChoiceMode = ChoiceMode.None;

            string holo = "Tu carrito";

            carrito.SetText(holo, TextView.BufferType.Editable);
            carrito.TextAlignment = TextAlignment.Center;
        }
        /// <summary>
        /// Returns a stored geofence by its ID, or returns null if it's not found
        /// </summary>
        /// <returns>A SimpleGeofence defined by its center and radius, or null if the ID is invalid</returns>
        /// <param name="id">The ID of a stored Geofence</param>
        public SimpleGeofence GetGeofence(String id)
        {
            // Get the latitude for the geofence identified by id, or INVALID_FLOAT_VALUE if it doesn't exist (similarly for the other values that follow)
            double lat                = mPrefs.GetFloat(GetGeofenceFieldKey(id, Constants.KEY_LATITUDE), Constants.INVALID_FLOAT_VALUE);
            double lng                = mPrefs.GetFloat(GetGeofenceFieldKey(id, Constants.KEY_LONGITUDE), Constants.INVALID_FLOAT_VALUE);
            float  radius             = mPrefs.GetFloat(GetGeofenceFieldKey(id, Constants.KEY_RADIUS), Constants.INVALID_INT_VALUE);
            long   expirationDuration = mPrefs.GetLong(GetGeofenceFieldKey(id, Constants.KEY_EXPIRATION_DURATION), Constants.INVALID_LONG_VALUE);
            int    transitionType     = mPrefs.GetInt(GetGeofenceFieldKey(id, Constants.KEY_TRANSITION_TYPE), Constants.INVALID_INT_VALUE);

            // If none of the values is incorrect, return the object
            if (lat != Constants.INVALID_FLOAT_VALUE &&
                lng != Constants.INVALID_FLOAT_VALUE &&
                radius != Constants.INVALID_FLOAT_VALUE &&
                expirationDuration != Constants.INVALID_LONG_VALUE &&
                transitionType != Constants.INVALID_INT_VALUE)
            {
                return(new SimpleGeofence(id, lat, lng, radius, expirationDuration, transitionType));
            }

            // Otherwise return null
            return(null);
        }
Beispiel #24
0
        public float GetFloat(string key)
        {
            try
            {
                return(_preferences.GetFloat(key, 0));
            }
            catch (Exception e)
            {
                Logger.Error($"Error Getting Float UserSetting {key} - {e.Message}", e);
            }

            return(0);
        }
        private double getAmountInvested()
        {
            //this is the amount invested without principal loan repayments
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);

            totalFees = prefs.GetFloat("total_fees_key", 0);

            if (totalFees != 0)
            {
                return(initialAmount + ((getGainLossPerYear() * -1) * NUMBER_OF_YEARS));
            }
            return(0);
        }
 protected override string GetPersistedString(string defaultReturnValue)
 {
     if (_sharedPreferences.Contains(Key))
     {
         // _sharedPreferences.Edit().Remove(Key).Commit();
         float floatValue = _sharedPreferences.GetFloat(Key, Convert.ToSingle(defaultReturnValue));
         return(floatValue.ToString());
     }
     else
     {
         return(defaultReturnValue);
     }
 }
Beispiel #27
0
        //todo fix this
        public TPrimitive Get <TPrimitive>(string name) where TPrimitive : struct
        {
            TPrimitive value = default(TPrimitive);
            Type       type  = typeof(TPrimitive);

#if ANDROID
            if (type == typeof(int))
            {
                value = _preferences.GetInt(name, 0).Cast <TPrimitive>();
            }
            else if (type == typeof(bool))
            {
                value = _preferences.GetBoolean(name, true).Cast <TPrimitive>();
            }
            else if (type == typeof(float))
            {
                value = _preferences.GetFloat(name, 0).Cast <TPrimitive>();
            }
            else if (type == typeof(long))
            {
                value = _preferences.GetLong(name, 0).Cast <TPrimitive>();
            }
            else
            {
                throw new NotImplementedException("");
            }
#elif iOS
            if (type == typeof(int))
            {
                value = MonoTouch.Foundation.NSUserDefaults.StandardUserDefaults.IntForKey(name).Cast <TPrimitive>();
            }
            else if (type == typeof(bool))
            {
                value = MonoTouch.Foundation.NSUserDefaults.StandardUserDefaults.BoolForKey(name).Cast <TPrimitive>();
            }
            else if (type == typeof(float))
            {
                value = MonoTouch.Foundation.NSUserDefaults.StandardUserDefaults.FloatForKey(name).Cast <TPrimitive>();
            }
            else if (type == typeof(long))
            {
                value = MonoTouch.Foundation.NSUserDefaults.StandardUserDefaults.StringForKey(name).ToLong().Cast <TPrimitive>();
            }
            else
            {
                throw new NotImplementedException("");
            }
#endif

            return(value);
        }
        public static bool tryLoad(Activity activity, Mat cameraMatrix, Mat distortionCoefficients)
        {
            ISharedPreferences sharedPref = activity.GetPreferences(FileCreationMode.Private);

            if (sharedPref.GetFloat("0", -1) == -1)
            {
                Log.Info(TAG, "No previous calibration results found");
                return(false);
            }

            double[] cameraMatrixArray = new double[CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS];
            for (int i = 0; i < CAMERA_MATRIX_ROWS; i++)
            {
                for (int j = 0; j < CAMERA_MATRIX_COLS; j++)
                {
                    int id = i * CAMERA_MATRIX_ROWS + j;
                    cameraMatrixArray[id] = sharedPref.GetFloat(id.ToString(), -1);
                }
            }

            cameraMatrix.Put(0, 0, cameraMatrixArray);

            Log.Info(TAG, "Loaded camera matrix: " + cameraMatrix.Dump());

            double[] distortionCoefficientsArray = new double[DISTORTION_COEFFICIENTS_SIZE];

            int shift = CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS;

            for (int i = shift; i < DISTORTION_COEFFICIENTS_SIZE + shift; i++)
            {
                distortionCoefficientsArray[i - shift] = sharedPref.GetFloat(i.ToString(), -1);
            }

            distortionCoefficients.Put(0, 0, distortionCoefficientsArray);
            Log.Info(TAG, "Loaded distortion coefficients: " + distortionCoefficients.Dump());

            return(true);
        }
Beispiel #29
0
        static public float GetFloatSetting(string name, float defValue = -1)
        {
            float res = 0f;

            try
            {
                res = g_prefs.GetFloat(name, defValue);
                Console.WriteLine("GetFloatSetting {0}: {1} --> {2}",
                                  Application.Context.ApplicationInfo.PackageName, name, res);
            }
            catch (Exception exc)
            {
                Console.WriteLine("Exception {0}", exc.Message);
                var str = g_prefs.GetString(name, "");
                float.TryParse(str, out res);
            }
            return(res);
        }
Beispiel #30
0
        public static double GetStorageDoubleValue(string appName, string key)
        {
            ISharedPreferences pref = Application.Context.GetSharedPreferences(appName, FileCreationMode.Private);

            try
            {
                return(Convert.ToDouble(pref.GetFloat(key, 0f)));
            }
            catch
            {
                try
                {
                    return(Convert.ToDouble(pref.GetInt(key, 0)));
                }
                catch
                {
                    return(0.0);
                }
            }
        }