List of usage examples for android.content SharedPreferences getFloat
float getFloat(String key, float defValue);
From source file:com.csipsimple.utils.PreferencesWrapper.java
private static Float gPrefFloatValue(SharedPreferences aPrefs, String key) { if (FLOAT_PREFS.containsKey(key)) { return aPrefs.getFloat(key, FLOAT_PREFS.get(key)); }/* w ww . ja va 2s . c o m*/ return aPrefs.getFloat(key, (Float) null); }
From source file:com.tagaugmentedreality.utilties.Utilities.java
public static Object getSharedPreferences(Context context, String key, char type) { /**/*from w w w. ja v a 2 s . c o m*/ * s: String i: Integer b: Boolean l: Long f: Float */ SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0); if ('s' == type) { return (Object) settings.getString(key, ""); } // end if else if ('i' == type) { return (Object) settings.getInt(key, 0); } // end else if else if ('b' == type) { return (Object) settings.getBoolean(key, false); } // end else if else if ('l' == type) { return (Object) settings.getLong(key, 0); } // end else if else if ('f' == type) { return (Object) settings.getFloat(key, 0.0f); } // end else if else { return null; } // end else }
From source file:fyc.framework.util.PrefsUtils.java
public static float getFloat(Context context, String name, String key, float defValue, int mode, boolean[] keyValueEncrypt) { SharedPreferences preferences = null; if (TextUtils.isEmpty(name)) { preferences = PreferenceManager.getDefaultSharedPreferences(context); } else {/*from ww w.j av a 2 s .c om*/ preferences = context.getSharedPreferences(name, mode); } if (keyValueEncrypt[1]) { String value = getString(context, name, key, String.valueOf(defValue), mode, keyValueEncrypt); try { return Float.valueOf(value); } catch (Exception e) { return defValue; } } else { return preferences.getFloat(keyValueEncrypt[0] ? SecurityUtils.MD5(key) : key, defValue); } }
From source file:com.crte.sipstackhome.ui.preferences.PreferencesWrapper.java
/** * float?/*w ww. ja v a 2s . c om*/ * * @param aPrefs * @param key * @return */ private static Float gPrefFloatValue(SharedPreferences aPrefs, String key) { if (aPrefs == null) { return FLOAT_PREFS.get(key); } if (FLOAT_PREFS.containsKey(key)) { return aPrefs.getFloat(key, FLOAT_PREFS.get(key)); } if (aPrefs.contains(key)) { return aPrefs.getFloat(key, 0.0f); } return null; }
From source file:net.pmarks.chromadoze.PhononMutable.java
public boolean loadFromLegacyPrefs(SharedPreferences pref) { if (pref.getFloat("barHeight0", -1) < 0) { return false; }/*from w w w . j ava 2 s . c o m*/ for (int i = 0; i < BAND_COUNT; i++) { setBar(i, pref.getFloat("barHeight" + i, .5f)); } setMinVol(pref.getInt("minVol", 100)); setPeriod(pref.getInt("period", 18)); cleanMe(); return true; }
From source file:com.adithya321.sharesanalysis.fragments.SummaryFragment.java
private void calculateValues() { double currentInvestment = 0; double netWorth = 0; for (Share share : sharesList) { int totalSharesPurchased = 0; int totalSharesSold = 0; double totalValuePurchased = 0; double totalValueSold = 0; int currentNoOfShares = 0; RealmList<Purchase> purchases = share.getPurchases(); for (Purchase purchase : purchases) { if (purchase.getType().equals("buy")) { totalSharesPurchased += purchase.getQuantity(); totalValuePurchased += (purchase.getQuantity() * purchase.getPrice()); } else if (purchase.getType().equals("sell")) { totalSharesSold += purchase.getQuantity(); totalValueSold += (purchase.getQuantity() * purchase.getPrice()); }/*w ww .ja va 2 s. c o m*/ } double averageShareValue = totalValuePurchased / totalSharesPurchased; currentNoOfShares += (totalSharesPurchased - totalSharesSold); currentInvestment += (currentNoOfShares * averageShareValue); netWorth += (currentNoOfShares * share.getCurrentShareValue()); } double potentialProfit = netWorth - currentInvestment; SharedPreferences sharedPreferences = getActivity().getSharedPreferences("prefs", 0); double target = sharedPreferences.getFloat("target", 0); double targetProfit = currentInvestment * target / 100; currentInvestmentsTV.setText(String.valueOf(NumberUtils.round(currentInvestment, 2))); netWorthTV.setText(String.valueOf(NumberUtils.round(netWorth, 2))); potentialProfitTV.setText(String.valueOf(NumberUtils.round(potentialProfit, 2))); targetProfitTV.setText(String.valueOf(NumberUtils.round(targetProfit, 2))); }
From source file:de.frank_durr.ble_v_monitor.CurrentVoltageFragment.java
/** * Update the view according to the data of the data model. *//* www . j a va 2 s .c o m*/ private void updateView() { if (DataModel.theModel.getCurrentVoltage() == DataModel.INVALID_VOLTAGE) { textViewBatteryVoltage.setText(R.string.unknown); textViewChargeStatus.setText(R.string.unknown); imageViewChargeStatus.setImageResource(R.drawable.ic_battery_unknown); } else { double voltage = (double) (DataModel.theModel.getCurrentVoltage()) / 1000.0; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); float voltageOffset = prefs.getFloat("pref_voltage_offset", 0.0f); voltage += voltageOffset; String strVoltage = Double.toString(voltage); textViewBatteryVoltage.setText(strVoltage); // Assign the battery voltage to one of the charge levels 0 %, 25 %, 50 %, 75 %, 100 % // by checking whether the battery voltage falls into a certain voltage interval. // For instance, we assume the battery to be charged 50 %, if the voltage is within // the interval [ (CHARGED_25+CHARGED_50)/2 , (CHARGED_50+CHARGED_75)/2 ] if (voltage < (CHARGED_0 + CHARGED_25) / 2.0) { textViewChargeStatus.setText(R.string.charged0); imageViewChargeStatus.setImageResource(R.drawable.ic_battery_0); } else if (voltage < (CHARGED_25 + CHARGED_50) / 2.0) { textViewChargeStatus.setText(R.string.charged25); imageViewChargeStatus.setImageResource(R.drawable.ic_battery_25); } else if (voltage < (CHARGED_50 + CHARGED_75) / 2.0) { textViewChargeStatus.setText(R.string.charged50); imageViewChargeStatus.setImageResource(R.drawable.ic_battery_50); } else if (voltage < (CHARGED_75 + CHARGED_100) / 2.0) { textViewChargeStatus.setText(R.string.charged75); imageViewChargeStatus.setImageResource(R.drawable.ic_battery_75); } else { // Charged 100 % textViewChargeStatus.setText(R.string.charged100); imageViewChargeStatus.setImageResource(R.drawable.ic_battery_100); } } }
From source file:org.zapto.samhippiemiddlepoolchecker.Values.java
public Values(SharedPreferences settings, Context context) { this.settings = settings; this.context = context; accepted = settings.getFloat("accepted", 0); rejected = settings.getFloat("rejected", 0); immature = settings.getFloat("immature", 0); unexchanged = settings.getFloat("unexchanged", 0); balance = settings.getFloat("balance", 0); paid = settings.getFloat("paid", 0); }
From source file:com.adithya321.sharesanalysis.fragments.DetailFragment.java
private void setShareSales(View view) { TextView totalSharesPurchasedTV = (TextView) view.findViewById(R.id.detail_total_shares_sold); TextView totalValueTV = (TextView) view.findViewById(R.id.detail_total_value_sold); TextView targetSalePriceTV = (TextView) view.findViewById(R.id.detail_target); TextView differenceTV = (TextView) view.findViewById(detail_difference); int totalSharesSold = 0; int totalSharesPurchased = 0; double totalValueSold = 0; double totalValuePurchased = 0; double averageShareValue = 0; double targetSalePrice = 0; double difference = 0; RealmList<Purchase> purchases = share.getPurchases(); for (Purchase purchase : purchases) { if (purchase.getType().equals("sell")) { totalSharesSold += purchase.getQuantity(); totalValueSold += (purchase.getQuantity() * purchase.getPrice()); } else if (purchase.getType().equals("buy")) { totalSharesPurchased += purchase.getQuantity(); totalValuePurchased += (purchase.getQuantity() * purchase.getPrice()); }//from w w w . j a v a2s .c om } if (totalSharesPurchased != 0) averageShareValue = totalValuePurchased / totalSharesPurchased; Date today = new Date(); Date start = share.getDateOfInitialPurchase(); long noOfDays = DateUtils.getDateDiff(start, today, TimeUnit.DAYS); SharedPreferences sharedPreferences = getActivity().getSharedPreferences("prefs", 0); double target = sharedPreferences.getFloat("target", 0); targetSalePrice = averageShareValue * Math.pow((1 + (target / 100)), ((double) noOfDays / 365)); difference = share.getCurrentShareValue() - targetSalePrice; if (difference < 0) differenceTV.setTextColor(getResources().getColor((android.R.color.holo_red_dark))); else differenceTV.setTextColor(getResources().getColor((R.color.colorPrimary))); totalSharesPurchasedTV.setText(String.valueOf(totalSharesSold)); totalValueTV.setText(String.valueOf(NumberUtils.round(totalValueSold, 2))); targetSalePriceTV.setText(String.valueOf(NumberUtils.round(targetSalePrice, 2))); differenceTV.setText(String.valueOf(NumberUtils.round(difference, 2))); }
From source file:com.kircherelectronics.gyroscopeexplorer.activity.GyroscopeActivity.java
private float getPrefMeanFilterTimeConstant() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); return prefs.getFloat(ConfigActivity.MEAN_FILTER_SMOOTHING_TIME_CONSTANT_KEY, 0.5f); }