Example usage for java.lang Float valueOf

List of usage examples for java.lang Float valueOf

Introduction

In this page you can find the example usage for java.lang Float valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Float valueOf(float f) 

Source Link

Document

Returns a Float instance representing the specified float value.

Usage

From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentWeight.java

private void findViews() {
    Toolbar mToolbar = (Toolbar) v.findViewById(R.id.toolbar_weight);
    TextViewFont txtTitle = (TextViewFont) v.findViewById(R.id.txtTitle);
    txtTitle.setText("Weight");
    mToolbar.inflateMenu(R.menu.menu_weight);
    mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override//from w  w w  .j a v  a2  s  .  co  m
        public boolean onMenuItemClick(MenuItem menuItem) {
            if (menuItem.getItemId() == R.id.action_create) {
                FragmentManager fm = getActivity().getSupportFragmentManager();
                UpdateWeightDialogFragment suggestionFragment = new UpdateWeightDialogFragment();
                suggestionFragment.show(fm, "Fragment");
            }
            return false;
        }
    });
    mToolbar.setNavigationIcon(R.mipmap.ic_menu);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCallbacks.openNavigationDrawer();
        }
    });
    weightLogAdapter = new WeightLogAdapter(getActivity(), 0, WeightLog.all());
    listWeight = (ListView) v.findViewById(R.id.listWeight);
    listWeight.setAdapter(weightLogAdapter);
    SetWeightListHeight.setListViewHeight(listWeight);
    WeightLog weightLogStart = weightLogAdapter.getItem(0);
    TextView startWeight = (TextView) v.findViewById(R.id.startWeight);
    startWeight.setText(df.format(weightLogStart.getCurrentWeight()) + " lbs");
    WeightLog weightLogCurrent = weightLogAdapter.getItem(weightLogAdapter.getCount() - 1);
    TextView currentWeight = (TextView) v.findViewById(R.id.currentWeight);
    currentWeight.setText(df.format(weightLogCurrent.getCurrentWeight()) + " lbs");
    double totalWeightLoss = weightLogStart.getCurrentWeight() - weightLogCurrent.getCurrentWeight();
    TextView lossWeight = (TextView) v.findViewById(R.id.lossWeight);
    lossWeight.setText(df.format(totalWeightLoss) + " lbs");
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    TextView goalWeight = (TextView) v.findViewById(R.id.goalWeight);
    goalWeight.setText(sharedPreferences.getString(Globals.USER_WEIGHT_GOAL, "") + " lbs");
    double weightRemaining = weightLogCurrent.getCurrentWeight()
            - Double.valueOf(sharedPreferences.getString(Globals.USER_WEIGHT_GOAL, ""));
    TextView remainderWeight = (TextView) v.findViewById(R.id.remainderWeight);
    remainderWeight.setText(df.format(weightRemaining) + " lbs");
    max = (int) Precision.round(weightLogStart.getCurrentWeight(), -1) + 10;
    if (Double.valueOf(sharedPreferences.getString(Globals.USER_WEIGHT_GOAL, "")) < weightLogCurrent
            .getCurrentWeight()) {
        min = (int) Precision.round(Integer.valueOf(sharedPreferences.getString(Globals.USER_WEIGHT_GOAL, "")),
                -1) - 10;
    } else {
        min = (int) Precision.round(weightLogCurrent.getCurrentWeight(), -1) - 10;
    }
    goalWeightLine = Float.valueOf(sharedPreferences.getString(Globals.USER_WEIGHT_GOAL, ""));

    goalPosition = Integer.valueOf(sharedPreferences.getString(Globals.USER_WEIGHT_LOSS_GOAL, ""));
    if (goalPosition == 0 || goalPosition == 8) {
        weightPerWeek = 2;
    }
    if (goalPosition == 1 || goalPosition == 7) {
        weightPerWeek = 1.5;
    }
    if (goalPosition == 2 || goalPosition == 6) {
        weightPerWeek = 1;
    }
    if (goalPosition == 3 || goalPosition == 5) {
        weightPerWeek = .5;
    }
    if (goalPosition == 4) {
        weightPerWeek = 0;
    }
    timeTillGoal = weightRemaining / weightPerWeek;

    TextView timeRem = (TextView) v.findViewById(R.id.timeRem);
    timeRem.setText(df.format(timeTillGoal) + " Week(s)");
}

From source file:com.github.javaclub.toolbox.util.javabean.JavaTypeHandlers.java

public Object getValue(String fieldValue) {
    return Float.valueOf(fieldValue);
}

From source file:in.hatimi.nosh.support.CmdLineManager.java

private boolean injectString(Object target, Field field, String value) {
    if (field.getType().equals(Boolean.class) || field.getType().equals(Boolean.TYPE)) {
        Boolean vobj = new Boolean(value);
        return injectImpl(target, field, vobj);
    }/*from w  w w  . ja va 2s  .  c  o  m*/
    if (field.getType().equals(Double.class) || field.getType().equals(Double.TYPE)) {
        Double vobj = Double.valueOf(value);
        return injectImpl(target, field, vobj);
    }
    if (field.getType().equals(Float.class) || field.getType().equals(Float.TYPE)) {
        Float vobj = Float.valueOf(value);
        return injectImpl(target, field, vobj);
    }
    if (field.getType().equals(Long.class) || field.getType().equals(Long.TYPE)) {
        Long vobj = Long.valueOf(value);
        return injectImpl(target, field, vobj);
    }
    if (field.getType().equals(Integer.class) || field.getType().equals(Integer.TYPE)) {
        Integer vobj = Integer.valueOf(value);
        return injectImpl(target, field, vobj);
    }
    if (field.getType().equals(String.class)) {
        return injectImpl(target, field, value);
    }
    if (field.getType().equals(byte[].class)) {
        return injectImpl(target, field, value.getBytes());
    }
    if (field.getType().equals(char[].class)) {
        return injectImpl(target, field, value.toCharArray());
    }
    return false;
}

From source file:com.example.android.geofence.DGGeofencing.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

    if (action.equalsIgnoreCase("initCallbackForRegionMonitoring")) {
        cbContext = callbackContext;/*w w  w.java 2  s .co  m*/
    } else if (action.equalsIgnoreCase("startMonitoringRegion")) {

        // Create an intent filter for the broadcast receiver
        mIntentFilter = new IntentFilter();

        // Action for broadcast Intents that report successful addition of geofences
        mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCES_ADDED);

        // Action for broadcast Intents that report successful removal of geofences
        mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCES_REMOVED);

        // Action for broadcast Intents containing various types of geofencing errors
        mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCE_ERROR);

        // All Location Services sample apps use this category
        mIntentFilter.addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES);

        // Instantiate the current List of geofences
        mCurrentGeofences = new ArrayList<Geofence>();

        // Instantiate a Geofence requester
        mGeofenceRequester = new GeofenceRequester(this.cordova.getActivity());

        // Instantiate a Geofence remover
        mGeofenceRemover = new GeofenceRemover(this.cordova.getActivity());

        // Attach to the main UI
        //setContentView(R.layout.activity_main);

        /*
         * Record the request as an ADD. If a connection error occurs,
         * the app can automatically restart the add request if Google Play services
         * can fix the error
         */
        mRequestType = GeofenceUtils.REQUEST_TYPE.ADD;

        /*
         * Check for Google Play services. Do this after
         * setting the request type. If connecting to Google Play services
         * fails, onActivityResult is eventually called, and it needs to
         * know what type of request was in progress.
         */
        if (!servicesConnected()) {
            return false;
        }

        /*
         * Create a version of geofence 1 that is "flattened" into individual fields. This
         * allows it to be stored in SharedPreferences.
         */
        double lat = Double.valueOf(args.getString(1));
        double lng = Double.valueOf(args.getString(2));
        float radius = Float.valueOf(args.getString(3));

        mUIGeofence1 = new SimpleGeofence("1",
                // Get latitude, longitude, and radius from the UI
                lat, lng, radius,
                // Set the expiration time
                GEOFENCE_EXPIRATION_IN_MILLISECONDS,
                // Only detect entry transitions
                Geofence.GEOFENCE_TRANSITION_ENTER);

        /*
         * Add Geofence objects to a List. toGeofence()
         * creates a Location Services Geofence object from a
         * flat object
         */
        mCurrentGeofences.add(mUIGeofence1.toGeofence());

        // Start the request. Fail if there's already a request in progress
        try {
            // Try to add geofences
            mGeofenceRequester.addGeofences(mCurrentGeofences);
        } catch (UnsupportedOperationException e) {
            // Notify user that previous request hasn't finished.
        }
    }
    return true;
}

From source file:iddb.core.util.Functions.java

public static String minutes2Str(Long minutes) {
    Float num;//from   ww w . java 2  s  .  co m
    String suffix = "";
    if (minutes < 60) {
        num = new Float(minutes);
    } else if (minutes < 1440) {
        num = Float.valueOf(minutes) / 60;
        suffix = "h";
    } else if (minutes < 10080) {
        num = Float.valueOf(minutes) / 1440;
        suffix = "d";
    } else if (minutes < 525600) {
        num = Float.valueOf(minutes) / 10080;
        suffix = "w";
    } else {
        num = Float.valueOf(minutes) / 525600;
        suffix = "y";
    }
    if ("0".equals(num.toString().substring(num.toString().indexOf(".") + 1))) {
        return String.format("%d%s", num.intValue(), suffix);
    }
    return String.format("%.2g%s", num, suffix); // 2=1 decimal
}

From source file:gov.nih.nci.caintegrator.application.study.AnnotationGroupUploadContent.java

private boolean matchingCdeId(AnnotationDefinition definition) {
    return (cdeId.equals(definition.getCommonDataElement().getPublicID()) && (version == null
            || version.equals(Float.valueOf(definition.getCommonDataElement().getVersion()))));
}

From source file:com.yoncabt.abys.core.util.EBRConf.java

public float getValue(String key, float defaultValue) {
    return Float.valueOf(getValueFromAll(key, Float.toString(defaultValue)));
}

From source file:Coordinate.java

/**
 * A private method to calculate the latitude constant
 *
 * @return a double representing the latitude constant
 *///from  w w  w  .  j a  va 2 s . co m
public static double latitudeConstant() {
    return EARTH_DIAMETER * (Math.PI / Float.valueOf("360"));
    //return EARTH_DIAMETER * (Float.valueOf("3.14") / Float.valueOf("360"));
}

From source file:net.solarnetwork.node.weather.nz.metservice.MetserviceSupport.java

/**
 * Parse a FLoat from an attribute value.
 * /* w  w  w  .  j a v a  2 s. c om*/
 * <p>
 * If the Float cannot be parsed, <em>null</em> will be returned.
 * </p>
 * 
 * @param key
 *        the attribute key to obtain from the {@code data} node
 * @param data
 *        the attributes
 * @return the parsed {@link Float}, or <em>null</em> if an error occurs or
 *         the specified attribute {@code key} is not available
 */
protected Float parseFloatAttribute(String key, JsonNode data) {
    Float num = null;
    if (data != null) {
        JsonNode node = data.get(key);
        if (node != null) {
            try {
                num = Float.valueOf(node.asText());
            } catch (NumberFormatException e) {
                log.debug("Error parsing float attribute [{}] value [{}]: {}",
                        new Object[] { key, data.get(key), e.getMessage() });
            }
        }
    }
    return num;
}

From source file:org.opens.color.finder.webapp.controller.IndexController.java

/**
 * Call the colorFinder implementation regarding the user selection and
 * return it (knowing it handles the results)
 *
 * @param colorModel//from w  w  w . j  ava2  s  .  c o m
 * @param foregroundColor
 * @param backgroundColor
 * @return the chosen colorFinder implementation with its results
 */
private ColorFinder getColorFinderAndExecute(ColorModel colorModel, Color foregroundColor,
        Color backgroundColor) {

    ColorFinder colorFinder = colorFinderFactory.getColorFinder(colorModel.getAlgo());

    colorFinder.findColors(foregroundColor, backgroundColor, colorModel.getIsBackgroundTested(),
            Float.valueOf(colorModel.getRatio()));

    return colorFinder;
}