Example usage for java.lang Float toString

List of usage examples for java.lang Float toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of this Float object.

Usage

From source file:com.tagaugmentedreality.NearByTagsList.java

public void prepareTagsList(String latitude, String longitude) {
    tagListView = (ListView) view.findViewById(R.id.tagListView);
    // tagListView.setVisibility(View.GONE);

    /*/*from   ww  w.j av  a 2 s.c  o  m*/
     * I am building the tags list
     */

    for (int i = 0; i < TagListCache.getTagsList().size(); i++) {
        TagListCache.getTagsList().get(i).destroyTag();
        TagListCache.getTagsList().remove(i);
    } // end for

    TagListCache.getTagsList().clear();

    TagCache tag;
    OpenGLModelCache openGLModel;

    Location tagLocation = new Location(" ");
    Location deviceLocation = new Location(" ");
    deviceLocation.setLatitude(Utilities.LATITUDE);
    deviceLocation.setLongitude(Utilities.LONGITUDE);
    Float bearing = 0.0f;
    Float distance = 0.0f;
    BigDecimal bearingRounded;
    /*
     * TagCache(String id, OpenGLModelCache openGLModel, String title,
     * String comment, Double latitude, Double longitude, String
     * tagImageLink, String accuracy, String distance, Float direction,
     * String firstName, String lastName, String userFacebookId, String
     * city, String province, String country, boolean grouped )
     */

    // tag1

    tag = new TagCache("1", null, "Tag1", "Tag1 is here.", Double.parseDouble(latitude),
            Double.parseDouble(longitude), "", "10", "10", 0.0f, "Lahore", "Punjab", "Pakistan", false);

    openGLModel = new OpenGLModelCache();
    openGLModel.resetVector();

    /**
     * I am getting the bearing of the tag with the device right here, by
     * using the latitude and longitude of both the tag and the device. Then
     * i am saving the value as the tag's heading.
     */
    tagLocation.setLatitude(Double.parseDouble("31.459379"));
    tagLocation.setLongitude(Double.parseDouble("74.368984"));
    distance = deviceLocation.distanceTo(tagLocation);
    bearing = deviceLocation.bearingTo(tagLocation);

    if (bearing < 0) {
        bearing = (-1) * bearing;
        bearing = 180 + (180 - bearing);
    } // end if

    bearingRounded = new BigDecimal(bearing).setScale(0, BigDecimal.ROUND_HALF_UP);
    bearing = Float.parseFloat(bearingRounded.toString());

    Log.e(Utilities.TAG, "bearing: " + bearing.toString());

    openGLModel.setHeading(bearing);// dataObject.getString("direction")));
    tag.setDirection(bearing);
    tag.setOpenGLModel(openGLModel);
    tag.setDistance(distance.toString());
    TagListCache.getTagsList().add(tag);

    // tag2

    tag = new TagCache("2", null, "Tag2", "Tag2 is here.", Double.parseDouble(latitude),
            Double.parseDouble(longitude), "", "10", "10", 0.0f, "Lahore", "Punjab", "Pakistan", false);

    openGLModel = new OpenGLModelCache();
    openGLModel.resetVector();

    /**
     * I am getting the bearing of the tag with the device right here, by
     * using the latitude and longitude of both the tag and the device. Then
     * i am saving the value as the tag's heading.
     */
    tagLocation.setLatitude(Double.parseDouble("31.459379"));
    tagLocation.setLongitude(Double.parseDouble("74.368984"));
    distance = deviceLocation.distanceTo(tagLocation);
    bearing = deviceLocation.bearingTo(tagLocation);

    if (bearing < 0) {
        bearing = (-1) * bearing;
        bearing = 180 + (180 - bearing);
    } // end if

    bearingRounded = new BigDecimal(bearing).setScale(0, BigDecimal.ROUND_HALF_UP);
    bearing = Float.parseFloat(bearingRounded.toString());

    Log.e(Utilities.TAG, "bearing: " + bearing.toString());

    openGLModel.setHeading(bearing);// dataObject.getString("direction")));
    tag.setDirection(bearing);
    tag.setOpenGLModel(openGLModel);
    tag.setDistance(distance.toString());
    TagListCache.getTagsList().add(tag);

    // tag3

    tag = new TagCache("3", null, "Tag3", "Tag3 is here.", Double.parseDouble(latitude),
            Double.parseDouble(longitude), "", "10", "10", 0.0f, "Lahore", "Punjab", "Pakistan", false);

    openGLModel = new OpenGLModelCache();
    openGLModel.resetVector();

    /**
     * I am getting the bearing of the tag with the device right here, by
     * using the latitude and longitude of both the tag and the device. Then
     * i am saving the value as the tag's heading.
     */
    tagLocation.setLatitude(Double.parseDouble("31.458804"));
    tagLocation.setLongitude(Double.parseDouble("74.368874"));
    distance = deviceLocation.distanceTo(tagLocation);
    bearing = deviceLocation.bearingTo(tagLocation);

    if (bearing < 0) {
        bearing = (-1) * bearing;
        bearing = 180 + (180 - bearing);
    } // end if

    bearingRounded = new BigDecimal(bearing).setScale(0, BigDecimal.ROUND_HALF_UP);
    bearing = Float.parseFloat(bearingRounded.toString());

    Log.e(Utilities.TAG, "bearing: " + bearing.toString());

    openGLModel.setHeading(bearing);// dataObject.getString("direction")));
    tag.setDirection(bearing);
    tag.setOpenGLModel(openGLModel);
    tag.setDistance(distance.toString());
    TagListCache.getTagsList().add(tag);

    // tag4

    tag = new TagCache("4", null, "Tag4", "Tag4 is here.", Double.parseDouble(latitude),
            Double.parseDouble(longitude), "", "10", "10", 0.0f, "Lahore", "Punjab", "Pakistan", false);

    openGLModel = new OpenGLModelCache();
    openGLModel.resetVector();

    /**
     * I am getting the bearing of the tag with the device right here, by
     * using the latitude and longitude of both the tag and the device. Then
     * i am saving the value as the tag's heading.
     */
    tagLocation.setLatitude(Double.parseDouble("31.458651"));
    tagLocation.setLongitude(Double.parseDouble("74.369171"));
    distance = deviceLocation.distanceTo(tagLocation);
    bearing = deviceLocation.bearingTo(tagLocation);

    if (bearing < 0) {
        bearing = (-1) * bearing;
        bearing = 180 + (180 - bearing);
    } // end if

    bearingRounded = new BigDecimal(bearing).setScale(0, BigDecimal.ROUND_HALF_UP);
    bearing = Float.parseFloat(bearingRounded.toString());

    Log.e(Utilities.TAG, "bearing: " + bearing.toString());

    openGLModel.setHeading(bearing);// dataObject.getString("direction")));
    tag.setDirection(bearing);
    tag.setOpenGLModel(openGLModel);
    tag.setDistance(distance.toString());
    TagListCache.getTagsList().add(tag);

    /*
     * I am building the combined tags list to be used by the Browser
     */

    temporaryList.clear();
    CombinedTagListCache.getCombinedList().clear();
    CombinedTagCache combinedTag;
    int counter = 1;

    for (int i = 0; i < TagListCache.getTagsList().size(); ++i) {
        temporaryList.add(TagListCache.getTagsList().get(i).getTitle());

        /**
         * I am creating the combined tags list on the basis that each tag
         * in the group is separated (direction of each tag is away from
         * each other by the value given by
         * Utilities.combinedDirectionCriteria degrees) by
         * Utilities.combinedDirectionCriteria degrees. I am grouping
         * together tags because there is limited real estate in the
         * Augmented Reality View Screen.
         */
        combinedTag = new CombinedTagCache();

        if (!TagListCache.getTagsList().get(i).isGrouped()) {
            TagListCache.getTagsList().get(i).setGrouped(true);
            combinedTag.setId(((Integer) counter).toString());
            combinedTag.getTagList().add(TagListCache.getTagsList().get(i));
            combinedTag.setOpenGLModel(TagListCache.getTagsList().get(i).getOpenGLModel());
            combinedTag.setDirection(TagListCache.getTagsList().get(i).getDirection());
            combinedTag.setLatitude(TagListCache.getTagsList().get(i).getLatitude());
            combinedTag.setLongitude(TagListCache.getTagsList().get(i).getLongitude());

            CombinedTagListCache.getCombinedList().add(combinedTag);

            for (int j = 0; j < TagListCache.getTagsList().size(); j++) {
                if (!TagListCache.getTagsList().get(j).isGrouped()) {
                    if (Math.abs(TagListCache.getTagsList().get(i).getDirection() - TagListCache.getTagsList()
                            .get(j).getDirection()) < Utilities.COMBINED_DIRECTION_CRITERIA) {
                        combinedTag.getTagList().add(TagListCache.getTagsList().get(j));
                        TagListCache.getTagsList().get(j).setGrouped(true);
                    } // end if
                } // end if
            } // end for

            counter++;
        } // end if

    } // end for

    Log.e("combined tags size: ", "" + CombinedTagListCache.getCombinedList().size());

    for (int i = 0; i < CombinedTagListCache.getCombinedList().size(); i++) {
        Log.e("combined: ", "" + CombinedTagListCache.getCombinedList().get(i).getId());

        for (int j = 0; j < CombinedTagListCache.getCombinedList().get(i).getTagList().size(); j++) {

            Log.e("combined tag: ",
                    "" + CombinedTagListCache.getCombinedList().get(i).getTagList().get(j).getDirection());

        } // end for

    } // end for

    adapter.notifyDataSetChanged();

    // tagListView.setVisibility(View.VISIBLE);

    if (null != Lists.getActionProgressBar()) {
        Lists.getActionProgressBar().collapseActionView();
        Lists.getActionProgressBar().setActionView(null);

    } // end if

}

From source file:com.ephesoft.dcma.fuzzydb.FuzzyLuceneEngine.java

/**
 * This method updates the value of document level fields for each document by searching for similarities in input search text with
 * the data in database tables mapped for each document type.
 * /* ww w .  j ava2  s. c  o  m*/
 * @param batchInstanceIdentifier {@link String}
 * @param documentType {@link String}
 * @param searchText {@link String}
 * @throws DCMAApplicationException for handling any exception.
 * @return {@link List<List<String>>}
 */
public List<List<String>> fuzzyTextSearch(final String batchInstanceIdentifier, final String documentType,
        final String searchText) throws DCMAApplicationException {
    LOGGER.info("Initializing properties...");
    String searchTextInLowerCase = searchText.toLowerCase(Locale.getDefault());
    List<List<String>> extractedData = null;
    String numOfPages = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_NO_OF_PAGES);
    String dbDriver = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_DB_DRIVER);
    String dbConnectionURL = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_CONNECTION_URL);
    String dbUserName = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_DB_USER_NAME);
    String thresholdValue = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_THRESHOLD_VALUE);
    String dbPassword = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_DB_PASSWORD);
    String dbName = FuzzyDBSearchConstants.EMPTY_STRING;
    if (dbConnectionURL != null && dbConnectionURL.length() > 0) {
        dbName = getDatabaseName(dbConnectionURL, dbDriver);
    }
    String queryDelimiters = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_QUERY_DELIMITERS);
    LOGGER.info("Properties Initialized Successfully");
    Batch batch = batchSchemaService.getBatch(batchInstanceIdentifier);
    String batchClassIdentifier = batch.getBatchClassIdentifier();
    String indexFolder = batchSchemaService.getFuzzyDBIndexFolder(batchClassIdentifier, false);

    if (dbName.length() <= 0) {
        LOGGER.info(FuzzyDBSearchConstants.WRONG_DB_NAME_MESSAGE);
        return extractedData;
    }

    File baseFuzzyDbIndexFolder = new File(indexFolder);
    if (baseFuzzyDbIndexFolder != null && !baseFuzzyDbIndexFolder.exists()) {
        LOGGER.info(FuzzyDBSearchConstants.FUZZY_DB_INDEX_FOLDER_DOES_NOT_EXIST_MESSAGE);
        return extractedData;
    }

    Map<String, Float> returnMap = new HashMap<String, Float>();
    Set<FuzzyDBResultInfo> resultSet = new TreeSet<FuzzyDBResultInfo>();

    List<com.ephesoft.dcma.da.domain.PageType> allPageTypes = pluginPropertiesService
            .getPageTypes(batchInstanceIdentifier);
    if (!(allPageTypes != null && !allPageTypes.isEmpty())) {
        LOGGER.info("Page Types not configured in Database");
        return extractedData;
    }

    BatchDynamicPluginConfiguration[] pluginPropsDocType = pluginPropertiesService.getDynamicPluginProperties(
            batchInstanceIdentifier, FuzzyDBSearchConstants.FUZZYDB_PLUGIN,
            FuzzyDBProperties.FUZZYDB_DOCUMENT_TYPE);
    if (pluginPropsDocType != null && pluginPropsDocType.length > 0) {
        for (BatchDynamicPluginConfiguration eachConfig : pluginPropsDocType) {
            if (eachConfig.getDescription().equals(documentType)) {
                String tableName = eachConfig.getValue();
                String fuzzyIndexFolder = indexFolder + File.separator + dbName + File.separator + tableName;
                File indexFolderDirectory = new File(fuzzyIndexFolder);
                if (indexFolderDirectory != null && indexFolderDirectory.exists()) {
                    String[] indexFiles = indexFolderDirectory.list();
                    if (indexFiles == null || indexFiles.length <= 0) {
                        LOGGER.info("No index files exist inside folder : " + indexFolderDirectory);
                        continue;
                    }
                } else {
                    LOGGER.info("No index created for : " + eachConfig.getDescription());
                    continue;
                }
                StringTokenizer tokens = new StringTokenizer(searchTextInLowerCase, queryDelimiters);

                StringBuffer query = createQueryForTextSearch(tokens);
                if (query != null && query.toString() != null && query.toString().length() > 0) {
                    LOGGER.info(FuzzyDBSearchConstants.GENERATING_CONFIDENCE_MESSAGE + searchTextInLowerCase);
                    try {
                        returnMap = SearchFiles.generateConfidence(fuzzyIndexFolder, query.toString(),
                                FuzzyDBSearchConstants.INDEX_FIELD, Integer.valueOf(numOfPages),
                                this.ignoreWordList);
                        for (String key : returnMap.keySet()) {
                            FuzzyDBResultInfo fuzzyDBResultInfo = new FuzzyDBResultInfo(returnMap.get(key),
                                    key);
                            resultSet.add(fuzzyDBResultInfo);
                        }
                    } catch (NumberFormatException e) {
                        LOGGER.error(FuzzyDBSearchConstants.CONFIDENCE_ERROR_MSG + searchTextInLowerCase, e);
                        continue;
                    } catch (Exception e) {
                        LOGGER.error(FuzzyDBSearchConstants.CONFIDENCE_ERROR_MSG + searchTextInLowerCase, e);
                        continue;
                    }
                    LOGGER.info(FuzzyDBSearchConstants.RETURN_MAP_MESSAGE + returnMap);
                    if (resultSet != null && resultSet.size() > 0) {
                        if (extractedData == null) {
                            extractedData = new ArrayList<List<String>>();
                        }
                        boolean isHeaderAdded = true;
                        Set<FuzzyDBResultInfo> set = fetchDocumentHavingThresholdValue(resultSet,
                                thresholdValue);
                        for (FuzzyDBResultInfo fuzzyDBResultInfo : set) {
                            Float confidenceScore = fuzzyDBResultInfo.getConfidence();
                            long keyLong = 0;
                            try {
                                keyLong = Long.parseLong(fuzzyDBResultInfo.getRowId());
                            } catch (NumberFormatException nfe) {
                                LOGGER.error(nfe.getMessage(), nfe);
                                return null;
                            }
                            extractedData.addAll(fetchFuzzySearchResult(keyLong, confidenceScore.toString(),
                                    tableName, dbConnectionURL, dbName, dbDriver, dbUserName, dbPassword,
                                    eachConfig, isHeaderAdded));
                            isHeaderAdded = false;
                            LOGGER.info(FuzzyDBSearchConstants.EXTRACTED_DATA_MESSAGE + extractedData);
                        }
                    } else {
                        LOGGER.info("No record found ");
                    }
                } else {
                    LOGGER.info(FuzzyDBSearchConstants.EMPTY_QUERY_MESSAGE + searchTextInLowerCase);
                }
            }
        }
    } else {
        LOGGER.info("No properties configured for FUZZYDB_DOCUMENT_TYPE");
    }
    if (extractedData != null && extractedData.isEmpty()) {
        return null;
    }
    return extractedData;
}

From source file:com.gigabytedevelopersinc.app.calculator.Calculator.java

void evaluate(String exp) {
    Solver solver = new Solver();
    if (page_no == 4) {
        switch (unitSpinner.getSelectedItem().toString()) {
        case "Area":
            convert(exp, areaValues);/* ww w .j ava2  s  .c o  m*/
            break;
        case "Cooking":
            convert(exp, cookingValues);
            break;
        case "Digital Storage":
            convert(exp, digitalValues);
            break;
        case "Energy":
            convert(exp, energyValues);
            break;
        case "Fuel Consumption":
            convert(exp, fuelValues);
            break;
        case "Length / Distance":
            convert(exp, lengthValues);
            break;
        case "Mass / Weight":
            convert(exp, massValues);
            break;
        case "Power":
            convert(exp, powerValues);
            break;
        case "Pressure":
            convert(exp, pressureValues);
            break;
        case "Speed":
            convert(exp, speedValues);
            break;
        case "Time":
            convert(exp, timeValues);
            break;
        case "Torque":
            convert(exp, torqueValues);
            break;
        case "Volume":
            convert(exp, volumeValues);
            break;
        }
    } else {
        try {
            int test = too.getVisibility();
            SharedPreferences settings = getSharedPreferences("MyPrefs", 0);
            Float rate = settings.getFloat("rate", 0);
            if (format_bool) {
                try {
                    result_TV.setText(formatter
                            .format(Double.valueOf(solver.solve(exp).replace(Constants.DECIMAL_POINT, '.'))));
                    resultant_TV.setText(formatter.format(Double.valueOf(
                            solver.solve(String.valueOf(solver.solve("(" + exp + ")*" + rate.toString())
                                    .replace(Constants.DECIMAL_POINT, '.'))))));
                } catch (Exception i) {
                    result_TV.setText(String.valueOf(solver.solve(exp)));
                    resultant_TV.setText(String
                            .valueOf(solver.solve(String.valueOf(solver.solve(exp)) + "*" + rate.toString())));
                }
            } else {
                result_TV.setText(String.valueOf(solver.solve(exp)));
                resultant_TV.setText(String
                        .valueOf(solver.solve(String.valueOf(solver.solve(exp)) + "*" + rate.toString())));
            }
        } catch (Exception ee) {
            try {
                if (format_bool) {
                    try {
                        result_TV.setText(formatter.format(
                                Double.valueOf(solver.solve(exp).replace(Constants.DECIMAL_POINT, '.'))));
                    } catch (Exception i) {
                        result_TV.setText(String.valueOf(solver.solve(exp)));
                    }
                } else
                    result_TV.setText(String.valueOf(solver.solve(exp)));
                done = false;
            } catch (SyntaxException S) {
                if (done) {
                    Toast.makeText(Calculator.this, S.toString(), Toast.LENGTH_SHORT).show();
                }
                done = false;
            }
        }

        /*try {
        TextView decTV = (TextView) findViewById(R.id.dec_tv);
        TextView hexTV = (TextView) findViewById(R.id.hex_TV);
        TextView octTV = (TextView) findViewById(R.id.oct_TV);
        TextView binTV = (TextView) findViewById(R.id.bin_TV);
                
        DecimalFormat df = new DecimalFormat();
        df.setGroupingUsed(false);
        df.setMaximumFractionDigits(15);
        try {
            solver.setBase(base);
            String ans = solver.solve(exp);
            decTV.setText(changeBase(ans, base, Base.DECIMAL));
            hexTV.setText(newBase(decTV.getText().toString(), 10, 16));
            octTV.setText(newBase(decTV.getText().toString(), 10, 8));
            binTV.setText(newBase(decTV.getText().toString(), 10, 2));
        } catch (SyntaxException R) {
            if (done) {
                Toast.makeText(MainActivity.this, R.toString(), Toast.LENGTH_SHORT).show();
            }
            done = false;
        } catch (Exception e) {
            //Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_SHORT).show();
        }
        } catch (RuntimeException R) {
        //
        }*/
    }
}

From source file:au.org.ala.biocache.dao.SearchDAOImpl.java

/**
 * Build the query string for a spatial query (using Spatial-Solr plugin syntax)
 *
 * TODO change param type to SearchRequestParams
 *
 * New plugin syntax//from  w  ww  . ja  v a 2s .c  o  m
 * {!spatial circles=52.347,4.453,10}
 *
 * TODO different types of spatial queries...
 *
 * @param fullTextQuery
 * @param latitude
 * @param longitude
 * @param radius
 * @return
 */
protected String buildSpatialQueryString(String fullTextQuery, Float latitude, Float longitude, Float radius) {
    StringBuilder sb = new StringBuilder();
    sb.append(spatialField).append(":\"Intersects(Circle(").append(longitude.toString());
    sb.append(" ").append(latitude.toString()).append(" d=")
            .append(SpatialUtils.convertToDegrees(radius).toString());
    sb.append("))\"");
    if (StringUtils.isNotEmpty(fullTextQuery)) {
        sb.append(" AND (").append(fullTextQuery).append(")");
    }
    return sb.toString();
}

From source file:com.gigabytedevelopersinc.app.calculator.Calculator.java

public void BtnClick(final View v) {

    page_no = mPager.getCurrentItem();/*w  ww. j a  v a  2  s.c om*/
    unitSpinner = findViewById(R.id.units_spinner);
    switch (page_no) {
    /*case 0:
        result_TV = (AutoResizeTextView) findViewById(R.id.sci_result_TV);
        expression_TV = (EditText) findViewById(R.id.sci_expression_TV);
        break;
    case 1:
        result_TV = (AutoResizeTextView) findViewById(R.id.pro_result_TV);
        expression_TV = (EditText) findViewById(R.id.pro_expression_TV);
        break;*/
    case 2:
        result_TV = (AutoResizeTextView) findViewById(R.id.curr_result_TV);
        expression_TV = (EditText) findViewById(R.id.curr_expression_TV);
        resultant_TV = (AutoResizeTextView) findViewById(R.id.curr_resultant_TV);
        break;
    case 3:
    case 4:
        result_TV = (AutoResizeTextView) findViewById(R.id.conv_result_TV);
        expression_TV = (EditText) findViewById(R.id.conv_expression_TV);
        resultant_TV = (AutoResizeTextView) findViewById(R.id.conv_resultant_TV);
        break;

    }
    try {
        result_TV.setInputType(InputType.TYPE_NULL);
        result_TV.setRawInputType(InputType.TYPE_CLASS_TEXT);
        result_TV.setTextIsSelectable(true);
        result = result_TV.getText().toString();

        try {
            resultant_TV.setInputType(InputType.TYPE_NULL);
            resultant_TV.setRawInputType(InputType.TYPE_CLASS_TEXT);
            resultant_TV.setTextIsSelectable(true);
        } catch (Exception idk) {
            //
        }

        expression_TV.setInputType(InputType.TYPE_NULL);
        expression_TV.setRawInputType(InputType.TYPE_CLASS_TEXT);
        expression_TV.setTextIsSelectable(true);
        expression = expression_TV.getText().toString();
        if (!flag) {
            expression_TV.setText("");
            result_TV.setMaxTextSize(34);
            result_TV.setTextSize(34);
            result_TV.setText("" + 0);
            expression = "";
            result = "" + 0;
            flag = true;
        }
    } catch (Exception eee) {
        //
    }

    //Converter
    from = (Spinner) findViewById(R.id.from_spinner);
    to = (Spinner) findViewById(R.id.to_spinner);
    try {
        from.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                evaluate(expression_TV.getText().toString());
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
        to.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                evaluate(expression_TV.getText().toString());
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
    } catch (Exception e) {
        //
    }

    //Currency
    fro = (Spinner) findViewById(R.id.fro_spinner);
    too = (Spinner) findViewById(R.id.too_spinner);
    /*LinearLayout sciFunLayout = (LinearLayout) findViewById(R.id.sci_fun_layout);
    final ListView constantsList = (ListView) findViewById(R.id.constants_list);*/

    switch (page_no) {
    /*case 0:
        historyLayout = (LinearLayout) findViewById(R.id.sci_history_layout);
        memoryLayout = (LinearLayout) findViewById(R.id.sci_memory_layout);
        simplePad = (LinearLayout) findViewById(R.id.sci_simple_pad);
        historyList = (ListView) findViewById(R.id.sci_history_list);
        historyList.setEmptyView(findViewById(R.id.sci_empty_history));
        memoryList = (ListView) findViewById(R.id.sci_memory_list);
        memoryList.setEmptyView(findViewById(R.id.sci_empty));
        fav_List_LL = (LinearLayout) findViewById(R.id.conv_fav_layout);
        favList = (ListView) findViewById(R.id.conv_fav_list);
        favList.setEmptyView(findViewById(R.id.conv_empty_fav));
        hyBtn = (Button) findViewById(R.id.sci_history_Btn);
        myBtn = (Button) findViewById(R.id.sci_M_Btn);
        favBtn = (Button) findViewById(R.id.conv_fav_Btn);
        break;
    case 1:
        historyLayout = (LinearLayout) findViewById(R.id.pro_history_layout);
        memoryLayout = (LinearLayout) findViewById(R.id.pro_memory_layout);
        simplePad = (LinearLayout) findViewById(R.id.pro_simple_pad);
        historyList = (ListView) findViewById(R.id.pro_history_list);
        historyList.setEmptyView(findViewById(R.id.pro_empty_history));
        memoryList = (ListView) findViewById(R.id.pro_memory_list);
        memoryList.setEmptyView(findViewById(R.id.pro_empty));
        fav_List_LL = (LinearLayout) findViewById(R.id.conv_fav_layout);
        favList = (ListView) findViewById(R.id.conv_fav_list);
        favList.setEmptyView(findViewById(R.id.conv_empty_fav));
        favBtn = (Button) findViewById(R.id.conv_fav_Btn);
        break;*/
    case 2:
        historyLayout = (LinearLayout) findViewById(R.id.curr_history_layout);
        memoryLayout = (LinearLayout) findViewById(R.id.curr_memory_layout);
        simplePad = (LinearLayout) findViewById(R.id.curr_simple_pad);
        historyList = (ListView) findViewById(R.id.curr_history_list);
        historyList.setEmptyView(findViewById(R.id.curr_empty_history));
        memoryList = (ListView) findViewById(R.id.curr_memory_list);
        memoryList.setEmptyView(findViewById(R.id.curr_empty));
        fav_List_LL = (LinearLayout) findViewById(R.id.curr_fav_layout);
        favList = (ListView) findViewById(R.id.curr_fav_list);
        favList.setEmptyView(findViewById(R.id.curr_empty_fav));
        /*hyBtn = (Button) findViewById(R.id.curr_history_Btn);
        myBtn = (Button) findViewById(R.id.curr_M_Btn);
        favBtn = (Button) findViewById(R.id.curr_fav_Btn);*/
        break;
    case 3:
    case 4:
        historyLayout = (LinearLayout) findViewById(R.id.conv_history_layout);
        memoryLayout = (LinearLayout) findViewById(R.id.conv_memory_layout);
        simplePad = (LinearLayout) findViewById(R.id.conv_simple_pad);
        historyList = (ListView) findViewById(R.id.conv_history_list);
        historyList.setEmptyView(findViewById(R.id.conv_empty_history));
        memoryList = (ListView) findViewById(R.id.conv_memory_list);
        memoryList.setEmptyView(findViewById(R.id.conv_empty));
        fav_List_LL = (LinearLayout) findViewById(R.id.conv_fav_layout);
        favList = (ListView) findViewById(R.id.conv_fav_list);
        favList.setEmptyView(findViewById(R.id.conv_empty_fav));
        /*hyBtn = (Button) findViewById(R.id.conv_history_Btn);
        myBtn = (Button) findViewById(R.id.conv_M_Btn);
        favBtn = (Button) findViewById(R.id.conv_fav_Btn);*/
        break;
    default:
        historyLayout = (LinearLayout) findViewById(R.id.conv_history_layout);
        memoryLayout = (LinearLayout) findViewById(R.id.conv_memory_layout);
        simplePad = (LinearLayout) findViewById(R.id.conv_simple_pad);
        historyList = (ListView) findViewById(R.id.conv_history_list);
        historyList.setEmptyView(findViewById(R.id.conv_empty_history));
        fav_List_LL = (LinearLayout) findViewById(R.id.conv_fav_layout);
        memoryList = (ListView) findViewById(R.id.conv_memory_list);
        memoryList.setEmptyView(findViewById(R.id.conv_empty));
        favList = (ListView) findViewById(R.id.conv_fav_list);
        favList.setEmptyView(findViewById(R.id.conv_empty_fav));
        /*hyBtn = (Button) findViewById(R.id.conv_history_Btn);
        myBtn = (Button) findViewById(R.id.conv_M_Btn);
        favBtn = (Button) findViewById(R.id.conv_fav_Btn);*/
        break;
    }

    /*Button funcBtn = (Button) findViewById(R.id.functions_Btn);
    Button constBtn = (Button) findViewById(R.id.constants_Btn);
            
    Button decBtn = (Button) findViewById(R.id.dec_Btn);
    Button hexBtn = (Button) findViewById(R.id.hex_Btn);
    Button octBtn = (Button) findViewById(R.id.oct_Btn);
    Button binBtn = (Button) findViewById(R.id.bin_Btn);
            
    TextView decTV = (TextView) findViewById(R.id.dec_tv);
    TextView hexTV = (TextView) findViewById(R.id.hex_TV);
    TextView octTV = (TextView) findViewById(R.id.oct_TV);
    TextView binTV = (TextView) findViewById(R.id.bin_TV);*/

    int id = v.getId();
    Button btn = (Button) findViewById(id);
    final String btnText = btn.getText().toString();
    switch (id) {
    case R.id.curr_add_to_fav:
    case R.id.conv_add_to_fav:
        createFav();
        break;
    //case R.id.sci_history_Btn:
    //case R.id.conv_history_Btn:
    //case R.id.curr_history_Btn:
    /*dbAdapter = new DbAdapter(this);
    dbAdapter.open();
    fillData();
            
    if (historyLayout.getVisibility() == View.GONE) {
        historyLayout.setVisibility(View.VISIBLE);
        hyBtn.setTextColor(primary_text_color);
        hyBtn.setBackgroundColor(primary_color);
        myBtn.setTextColor(sec_text_color);
        myBtn.setBackgroundColor(sec_color);
        memoryLayout.setVisibility(View.GONE);
        try {
            fav_List_LL.setVisibility(View.GONE);
            favBtn.setTextColor(sec_text_color);
            favBtn.setBackgroundColor(sec_color);
        } catch (Exception e) {
            //
        }
        *//*try {
             constantsList.setVisibility(View.GONE);
             constBtn.setTextColor(sec_text_color);
             constBtn.setBackgroundColor(sec_color);
             sciFunLayout.setVisibility(View.GONE);
             funcBtn.setTextColor(sec_text_color);
             funcBtn.setBackgroundColor(sec_color);
           } catch (Exception e) {
             //
           }*//*
               simplePad.setVisibility(View.GONE);
               } else {
               hyBtn.setTextColor(sec_text_color);
               hyBtn.setBackgroundColor(sec_color);
               historyLayout.setVisibility(View.GONE);
               simplePad.setVisibility(View.VISIBLE);
               }
               break;*/

    /*case R.id.floating:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (getDrawPermit()) {
                Intent startServiceIntent = new Intent(MainActivity.this, FloatingCalculator.class);
                startService(startServiceIntent);
            } else
                Toast.makeText(getApplicationContext(),
                        "Allow permission to draw over other apps to use Floating Calculator.",
                        Toast.LENGTH_LONG).show();
        } else {
            Intent startServiceIntent = new Intent(MainActivity.this, FloatingCalculator.class);
            startService(startServiceIntent);
        }
        break;
    case R.id.matgraph:
        startActivity(new Intent(getApplicationContext(), Calculator.class).putExtra("MAIN", true));
        break;
    case R.id.settings:
        startActivity(new Intent(MainActivity.this, SettingsActivity.class));
        break;
    case R.id.report:
        Intent report = new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://github.com/gigabytedevelopers/CalcMate/issues"));
        startActivity(report);
        break;
    case R.id.about:
        new LibsBuilder()
                .withLicenseShown(true)
                .withVersionShown(true)
                .withAboutVersionShown(true)
                .withActivityTitle(getString(R.string.app_name))
                .withAboutIconShown(true)
                .withListener(libsListener)
                .start(MainActivity.this);
        break;*/

    case R.id.AC_Btn:
        createHistory();
        reset();
        break;
    case R.id.C_Btn:
        int start = Math.max(expression_TV.getSelectionStart(), 0);
        int end = Math.max(expression_TV.getSelectionEnd(), 0);
        if (start == end && start != 0)
            expression_TV.getText().replace(Math.min(start, end) - 1, Math.max(start, end), "", 0, 0);
        else
            expression_TV.getText().replace(Math.min(start, end), Math.max(start, end), "", 0, 0);
        evaluate(expression_TV.getText().toString());
        break;

    //Memory
    case R.id.MC_Btn:
        dbAdapter = new DbAdapter(this);
        dbAdapter.open();
        dbAdapter.deleteAllMemories();
        Toast clearmem = Toast.makeText(Calculator.this, "Memory Cleared!", Toast.LENGTH_SHORT);
        clearmem.show();
        fillData();
        break;
    case R.id.MR_Btn:
        dbAdapter = new DbAdapter(this);
        dbAdapter.open();
        fillData();
        String mem = dbAdapter.memoryRetrieve();
        if (mem.equals("xyz")) {
            Toast toast = Toast.makeText(Calculator.this, "No Memory Yet!", Toast.LENGTH_SHORT);
            toast.show();
        } else
            insert(dbAdapter.memoryRetrieve());
        break;
    case R.id.MS_Btn:
        createMemory();
        Toast savemem = Toast.makeText(Calculator.this, "New Memory Saved!", Toast.LENGTH_SHORT);
        savemem.show();
        break;
    //case R.id.sci_M_Btn:
    //case R.id.curr_M_Btn:
    /*case R.id.conv_M_Btn:
    dbAdapter = new DbAdapter(this);
    dbAdapter.open();
    fillData();
    if (memoryLayout.getVisibility() == View.GONE) {
        memoryLayout.setVisibility(View.VISIBLE);
        myBtn.setTextColor(primary_text_color);
        myBtn.setBackgroundColor(primary_color);
        try {
            fav_List_LL.setVisibility(View.GONE);
            favBtn.setTextColor(sec_text_color);
            favBtn.setBackgroundColor(sec_color);
        } catch (Exception e) {
            //
        }
        *//*try {
             constantsList.setVisibility(View.GONE);
             constBtn.setTextColor(sec_text_color);
             constBtn.setBackgroundColor(sec_color);
             sciFunLayout.setVisibility(View.GONE);
             funcBtn.setTextColor(sec_text_color);
             funcBtn.setBackgroundColor(sec_color);
           } catch (Exception e) {
             //
           }*//*
               simplePad.setVisibility(View.GONE);
               hyBtn.setTextColor(sec_text_color);
               hyBtn.setBackgroundColor(sec_color);
               historyLayout.setVisibility(View.GONE);
               } else {
               myBtn.setTextColor(sec_text_color);
               myBtn.setBackgroundColor(sec_color);
               memoryLayout.setVisibility(View.GONE);
               simplePad.setVisibility(View.VISIBLE);
               }
               break;*/

    //case R.id.curr_fav_Btn:
    //case R.id.conv_fav_Btn:
    /*dbAdapter = new DbAdapter(this);
    dbAdapter.open();
    fillData();
    if (fav_List_LL.getVisibility() == View.GONE) {
        fav_List_LL.setVisibility(View.VISIBLE);
        try {
            memoryLayout.setVisibility(View.GONE);
            myBtn.setTextColor(sec_text_color);
            myBtn.setBackgroundColor(sec_color);
        } catch (Exception e) {
            //
        }
        favBtn.setTextColor(primary_text_color);
        favBtn.setBackgroundColor(primary_color);
        simplePad.setVisibility(View.GONE);
        hyBtn.setTextColor(sec_text_color);
        hyBtn.setBackgroundColor(sec_color);
        historyLayout.setVisibility(View.GONE);
    } else {
        fav_List_LL.setVisibility(View.GONE);
        favBtn.setTextColor(sec_text_color);
        favBtn.setBackgroundColor(sec_color);
        simplePad.setVisibility(View.VISIBLE);
    }
    break;*/

    /*case R.id.constants_Btn:
        dataBaseHelper = new DataBaseHelper(this);
        try {
            dataBaseHelper.createDataBase();
        } catch (IOException ioe) {
            throw new Error("Unable to create database");
        }
        dataBaseHelper.openDataBase();
        dataSource = new DataSource(this);
        dataSource.open();
        if (constantsList.getVisibility() == View.GONE) {
            constantsList.setVisibility(View.VISIBLE);
            constBtn.setTextColor(primary_text_color);
            constBtn.setBackgroundColor(primary_color);
            memoryLayout.setVisibility(View.GONE);
            myBtn.setTextColor(sec_text_color);
            myBtn.setBackgroundColor(sec_color);
            hyBtn.setTextColor(sec_text_color);
            hyBtn.setBackgroundColor(sec_color);
            historyLayout.setVisibility(View.GONE);
            try {
                sciFunLayout.setVisibility(View.GONE);
                funcBtn.setTextColor(sec_text_color);
                funcBtn.setBackgroundColor(sec_color);
            } catch (Exception e) {
                //
            }
            simplePad.setVisibility(View.GONE);
        } else {
            constantsList.setVisibility(View.GONE);
            constBtn.setTextColor(sec_text_color);
            constBtn.setBackgroundColor(sec_color);
            simplePad.setVisibility(View.VISIBLE);
        }
        try {
            Cursor c = dataSource.getConstants();
            startManagingCursor(c);
            
            String[] fro = new String[]{DataBaseHelper.COLUMN_NAME, DataBaseHelper.COLUMN_SYMBOL, DataBaseHelper.COLUMN_VALUE, DataBaseHelper.COLUMN_DIMENSION};
            int[] too = new int[]{R.id.text11, R.id.text12, R.id.text21, R.id.text22};
            
            SimpleCursorAdapter constants =
                    new SimpleCursorAdapter(this, R.layout.constants_row, c, fro, too);
            constantsList.setAdapter(constants);
            constantsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Cursor obj = (Cursor) constantsList.getItemAtPosition(position);
                    insert(obj.getString(3));
                }
            });
        } catch (Exception e) {
            //
        }
        break;
            
    case R.id.functions_Btn:
        if (sciFunLayout.getVisibility() == View.GONE) {
            funcBtn.setTextColor(primary_text_color);
            funcBtn.setBackgroundColor(primary_color);
            sciFunLayout.setVisibility(View.VISIBLE);
            memoryLayout.setVisibility(View.GONE);
            myBtn.setTextColor(sec_text_color);
            myBtn.setBackgroundColor(sec_color);
            hyBtn.setTextColor(sec_text_color);
            hyBtn.setBackgroundColor(sec_color);
            historyLayout.setVisibility(View.GONE);
            simplePad.setVisibility(View.GONE);
            constantsList.setVisibility(View.GONE);
            constBtn.setTextColor(sec_text_color);
            constBtn.setBackgroundColor(sec_color);
        } else {
            funcBtn.setTextColor(sec_text_color);
            funcBtn.setBackgroundColor(sec_color);
            sciFunLayout.setVisibility(View.GONE);
            simplePad.setVisibility(View.VISIBLE);
        }
        break;*/

    case R.id.conv_swap_Btn:
    case R.id.curr_swap_Btn:
        if (page_no == 4) {
            int temp = from.getSelectedItemPosition();
            from.setSelection(to.getSelectedItemPosition());
            to.setSelection(temp);
        } else {
            SharedPreferences settings = getSharedPreferences("MyPrefs", 0);
            Float rate = settings.getFloat("rate", 0);
            SharedPreferences.Editor editor = settings.edit();
            editor.putFloat("rate", 1 / rate);
            editor.apply();
            rate = 1 / rate;
            result_TV.setText("1");
            resultant_TV.setText(rate.toString());
            int temp = fro.getSelectedItemPosition();
            fro.setSelection(too.getSelectedItemPosition());
            too.setSelection(temp);
        }
        break;

    //Operators
    case R.id.leftBracket_Btn:
    case R.id.rightBracket_Btn:
    case R.id.add_Btn:
    case R.id.sub_Btn:
        //case R.id.factorial_Btn:
        // case R.id.imagine_Btn:
        //Numbers
    case R.id.dot_Btn:
    case R.id.Btn_0:
    case R.id.Btn_1:
    case R.id.Btn_2:
    case R.id.Btn_3:
    case R.id.Btn_4:
    case R.id.Btn_5:
    case R.id.Btn_6:
    case R.id.Btn_7:
    case R.id.Btn_8:
    case R.id.Btn_9:
        insert(btnText);
        break;
    case R.id.div_Btn:
        insert("/");
        break;
    case R.id.mul_Btn:
        insert("*");
        break;

    /*//Hex
    case R.id.A_Btn:
    case R.id.B_Btn:
    case R.id.C_hex_Btn:
    case R.id.D_Btn:
    case R.id.E_Btn:
    case R.id.F_Btn:
        insert(btnText);
        break;
    //Functions
    case R.id.abs_Btn:
    case R.id.ceil_Btn:
    case R.id.cos_Btn:
    case R.id.cosh_Btn:
    case R.id.exp_Btn:
    case R.id.floor_Btn:
    case R.id.log_Btn:
    case R.id.log10_Btn:
    case R.id.log2_Btn:
    case R.id.sin_Btn:
    case R.id.sinh_Btn:
    case R.id.tan_Btn:
    case R.id.tanh_Btn:
        insert(btnText + "(");
        break;
            
    case R.id.deg_Btn:
        insert("*" + getResources().getString(R.string.pi) + "/180");
        break;
            
    case R.id.acos_Btn:
        insert("acos(");
        break;
    case R.id.asin_Btn:
        insert("asin(");
        break;
    case R.id.atan_Btn:
        insert("atan(");
        break;
    case R.id.acosd_Btn:
        insert("acosd(");
        break;
    case R.id.acosh_Btn:
        insert("acosh(");
        break;
    case R.id.asind_Btn:
        insert("asind(");
        break;
    case R.id.sind_Btn:
        insert("sind(");
        break;
    case R.id.asinh_Btn:
        insert("asinh(");
        break;
    case R.id.cosd_Btn:
        insert("cosd(");
        break;
    case R.id.tand_Btn:
        insert("tand(");
        break;
    case R.id.atand_Btn:
        insert("atand(");
        break;
    case R.id.atanh_Btn:
        insert("atanh(");
        break;
            
    case R.id.root_Btn:
        insert("sqrt(");
        break;
            
    case R.id.cbrt_Btn:
        insert("cbrt(");
        break;
            
    case R.id.reciprocal_Btn:
        expression_TV.getText().replace(0, 0, "1/(", 0, 3);
        break;*/

    case R.id.percent_Btn:
        insert("%");
        break;

    /*case R.id.e_Btn:
        insert("2.7182818285");
        break;
            
    case R.id.pi_Btn:
        insert(btnText);
        break;*/

    case R.id.power_Btn:
        insert(btnText);
        break;

    case R.id.equals_Btn:
        done = true;
        evaluate(expression_TV.getText().toString());
        createHistory();
        try {
            expression_TV.setText("");
            insert(result_TV.getText().toString());
            result_TV.setText("0");
        } catch (RuntimeException ee) {
            //
        }
        break;

    /*case R.id.dec_Btn:
        try {
            decBtn.setBackgroundColor(sec_color);
            decBtn.setTextColor(sec_text_color);
            hexBtn.setBackgroundColor(primary_color);
            hexBtn.setTextColor(primary_text_color);
            octBtn.setBackgroundColor(primary_color);
            octBtn.setTextColor(primary_text_color);
            binBtn.setBackgroundColor(primary_color);
            binBtn.setTextColor(primary_text_color);
            decTV.setBackgroundColor(sec_color);
            decTV.setTextColor(sec_text_color);
            hexTV.setBackgroundColor(primary_color);
            hexTV.setTextColor(primary_text_color);
            octTV.setBackgroundColor(primary_color);
            octTV.setTextColor(primary_text_color);
            binTV.setBackgroundColor(primary_color);
            binTV.setTextColor(primary_text_color);
            expression_TV.setText("");
            insert(changeBase(expression, base, Base.DECIMAL));
            base = Base.DECIMAL;
        } catch (SyntaxException S) {
            Toast.makeText(getApplicationContext(), S.toString(), Toast.LENGTH_SHORT).show();
        }
        break;
    case R.id.hex_Btn:
        try {
            decBtn.setBackgroundColor(primary_color);
            decBtn.setTextColor(primary_text_color);
            hexBtn.setBackgroundColor(sec_color);
            hexBtn.setTextColor(sec_text_color);
            octBtn.setBackgroundColor(primary_color);
            octBtn.setTextColor(primary_text_color);
            binBtn.setBackgroundColor(primary_color);
            binBtn.setTextColor(primary_text_color);
            decTV.setBackgroundColor(primary_color);
            decTV.setTextColor(primary_text_color);
            hexTV.setBackgroundColor(sec_color);
            hexTV.setTextColor(sec_text_color);
            octTV.setBackgroundColor(primary_color);
            octTV.setTextColor(primary_text_color);
            binTV.setBackgroundColor(primary_color);
            binTV.setTextColor(primary_text_color);
            expression_TV.setText("");
            insert(changeBase(expression, base, Base.HEXADECIMAL));
            base = Base.HEXADECIMAL;
        } catch (SyntaxException S) {
            Toast.makeText(getApplicationContext(), S.toString(), Toast.LENGTH_SHORT).show();
        }
        break;
    case R.id.oct_Btn:
        try {
            decBtn.setBackgroundColor(primary_color);
            decBtn.setTextColor(primary_text_color);
            hexBtn.setBackgroundColor(primary_color);
            hexBtn.setTextColor(primary_text_color);
            octBtn.setBackgroundColor(sec_color);
            octBtn.setTextColor(sec_text_color);
            binBtn.setBackgroundColor(primary_color);
            binBtn.setTextColor(primary_text_color);
            decTV.setBackgroundColor(primary_color);
            decTV.setTextColor(primary_text_color);
            hexTV.setBackgroundColor(primary_color);
            hexTV.setTextColor(primary_text_color);
            octTV.setBackgroundColor(sec_color);
            octTV.setTextColor(sec_text_color);
            binTV.setBackgroundColor(primary_color);
            binTV.setTextColor(primary_text_color);
            expression_TV.setText("");
            insert(changeBase(expression, base, Base.OCTAL));
            base = Base.OCTAL;
        } catch (SyntaxException S) {
            Toast.makeText(getApplicationContext(), S.toString(), Toast.LENGTH_SHORT).show();
        }
        break;
    case R.id.bin_Btn:
        try {
            decBtn.setBackgroundColor(primary_color);
            decBtn.setTextColor(primary_text_color);
            hexBtn.setBackgroundColor(primary_color);
            hexBtn.setTextColor(primary_text_color);
            octBtn.setBackgroundColor(primary_color);
            octBtn.setTextColor(primary_text_color);
            binBtn.setBackgroundColor(sec_color);
            binBtn.setTextColor(sec_text_color);
            decTV.setBackgroundColor(primary_color);
            decTV.setTextColor(primary_text_color);
            hexTV.setBackgroundColor(primary_color);
            hexTV.setTextColor(primary_text_color);
            octTV.setBackgroundColor(primary_color);
            octTV.setTextColor(primary_text_color);
            binTV.setBackgroundColor(sec_color);
            binTV.setTextColor(sec_text_color);
            expression_TV.setText("");
            insert(changeBase(expression, base, Base.BINARY));
            base = Base.BINARY;
        } catch (SyntaxException S) {
            Toast.makeText(getApplicationContext(), S.toString(), Toast.LENGTH_SHORT).show();
        }
        break;
            
    default:
        break;
    }
    try {
        if (v.getId() != R.id.AC_Btn) {
            result_TV.resizeText();
            try {
                resultant_TV.resizeText();
            } catch (Exception e) {
                //
            }
        }
            
    } catch (Exception eeee) {
        //
    }*/
    }
}

From source file:de.innovationgate.wgpublisher.WGPDispatcher.java

private void dispatchPublishingFile(PublishingFile publishingFile, HttpServletRequest request,
        HttpServletResponse response, String textOutputEncoding, FileCache fileCache, WGPRequestPath path)
        throws WGException, HttpErrorException, IOException {

    // Collect HTTP client hints (if enabled)
    ClientHints clientHints = new ClientHints();
    boolean useHttpClientHints = false;
    if (publishingFile.getDatabase() != null) {
        Database database = WGA.get(request, response, getCore()).database(publishingFile.getDatabase());
        if (database instanceof App
                && ((Boolean) database.getPublisherOption(WGACore.DBATTRIB_USE_NONFINAL_HT_FEATURES)) == true) {
            useHttpClientHints = true;//from w  w  w. ja  v  a  2s  . c o m
        }
    }

    if (useHttpClientHints) {
        String dprStr = request.getHeader("CH-DPR");
        if (dprStr != null) {
            try {
                clientHints.setDevicePixelRatio(Float.valueOf(dprStr));
            } catch (NumberFormatException e) {
                getCore().getLog().warn("Client uses unparseable device pixel ratio: " + dprStr);
            }
        }
    }

    // Optionally select derivate
    Float usedDevicePixelRatio = null;
    try {

        String derivate = request.getParameter(URLPARAM_DERIVATE);
        if (derivate != null) {
            DerivateQuery derivateQuery = getCore().getFileDerivateManager().parseDerivateQuery(derivate);
            if (publishingFile instanceof DocumentPublishingFile) {
                DocumentPublishingFile docPublishingFile = (DocumentPublishingFile) publishingFile;
                WGFileDerivateMetaData derivateMd = docPublishingFile.queryDerivate(derivateQuery, clientHints);
                if (derivateMd != null) {
                    usedDevicePixelRatio = docPublishingFile.getUsedDevicePixelRatio();
                    publishingFile = new DerivatePublishingFile(this, docPublishingFile.getContainer(),
                            derivateMd);

                }
            } else if (!isFallbackToOriginalOnDerivateQuery(derivateQuery, publishingFile)) {
                throw new WGNotSupportedException("Derivate queries are not supported on this file type");
            }

        }

    } catch (WGNotSupportedException e) {
        throw new HttpErrorException(412, e.getMessage(), path.getDatabaseKey());
    } catch (WGInvalidDerivateQueryException e) {
        throw new HttpErrorException(400, "Invalid derivate query: " + e.getMessage(), path.getDatabaseKey());
    } catch (WGFailedDerivateQueryException e) {
        throw new HttpErrorException(412,
                "No derivate of file '" + publishingFile.getFileName() + "' matches the derivate query",
                path.getDatabaseKey());
    }

    // Put out the used device pixel ratio, if any
    if (usedDevicePixelRatio != null) {
        response.setHeader("Vary", "CH-DPR");
        response.setHeader("DPR", usedDevicePixelRatio.toString());
    }

    // Handle browser cache
    long lastModified = determinePublishingFileLastModified(publishingFile, request, response);

    if (browserCacheIsValid(request, lastModified, publishingFile.getETag())) {
        response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
        return;
    } else {
        response.setDateHeader("Last-Modified", lastModified);
        response.setHeader("ETag", '"' + publishingFile.getETag() + '"');
    }

    // Optionally inject online scaling information to file object
    String maxHeightStr = request.getParameter(URLPARAM_MAXHEIGHT);
    String maxWidthStr = request.getParameter(URLPARAM_MAXWIDTH);
    if (maxHeightStr != null || maxWidthStr != null) {
        try {
            int maxHeight = -1;
            if (maxHeightStr != null) {
                maxHeight = Integer.parseInt(maxHeightStr);
            }
            int maxWidth = -1;
            if (maxWidthStr != null) {
                maxWidth = Integer.parseInt(maxWidthStr);
            }
            publishingFile.setOnlineScaling(maxWidth, maxHeight, clientHints);
        } catch (NumberFormatException e) {
            getCore().getLog().error("Unparseable online scaling metrics", e);
        } catch (Exception e) {
            getCore().getLog().error("Exception setting online scaling information", e);
        }
    }

    // Put out content type
    String contentType = publishingFile.getContentType();
    if (contentType == null) {
        contentType = "application/octet-stream";
    }
    response.setContentType(contentType);

    // Content Disposition Header - Either if download forced or a disposition filename has been specified
    Boolean forceDownload = Boolean.parseBoolean(request.getParameter("forcedownload"));
    if (forceDownload) {
        response.setHeader("Content-disposition",
                "attachment" + (publishingFile.getDispositionFileName() != null
                        ? ";filename=" + publishingFile.getDispositionFileName()
                        : ""));
    } else if (publishingFile.getDispositionFileName() != null) {
        response.setHeader("Content-disposition", "inline;filename=" + publishingFile.getDispositionFileName());
    }

    // Allow accept ranges on all CS with optimized file handling and binary responses
    if (publishingFile.isAllowAcceptRanges() && isBinary(request, response)) {
        response.setHeader("Accept-Ranges", "bytes");
    }

    try {
        // Look if file is cached - If so, send it and exit
        if (fileCache != null) {
            boolean outputHandled = dispatchFileWithCache(publishingFile, request, response, fileCache,
                    lastModified, textOutputEncoding, contentType, path);
            if (outputHandled) {
                return;
            }
        }

        // We serve from cache so must retrieve the file. Test for availability now which may load the document.
        if (!publishingFile.isAvailable()) {
            throw new HttpErrorException(404, "File not found: " + publishingFile.getName(),
                    path.getDatabaseKey());
        }

        // File is above threshold and not in cache - serve from database
        writeData(publishingFile, request, response, publishingFile.getTextEncoding(),
                publishingFile.getFileSize(), publishingFile.getSourceHint(),
                publishingFile.isAllowAcceptRanges() && isBinary(request, response));
    } catch (java.net.SocketException exc) {
        _log.warn("Dispatch of file request failed bc. of socket error: " + exc.getMessage());
    } catch (java.io.IOException exc) {
        if (!exc.getClass().getName().equals("org.apache.catalina.connector.ClientAbortException")) {
            _log.warn("Dispatch of file request failed bc. of IO error: " + exc.getMessage());
        }
    } catch (HttpErrorException exc) {
        throw exc;
    } catch (Exception exc) {
        _log.error("Exception dispatching file " + publishingFile.getName(), exc);
    }
}

From source file:ome.formats.OMEROMetadataStoreClient.java

/**
 * Transforms a Java type into the corresponding OMERO RType.
 * @param value Java concrete type value.
 * @return RType or <code>null</code> if <code>value</code> is
 * <code>null</code>./* w  ww .  j  ava  2  s. c o m*/
 */
public RDouble toRType(Float value) {
    return value == null ? null : rdouble(Double.parseDouble(value.toString()));
}

From source file:es.pode.publicacion.negocio.servicios.SrvPublicacionServiceImpl.java

/**
 * Reindexa en el indice de busqueda el ODE que se le indica con la
 * valoracion que le pasan./*from   w  w  w . ja v a  2 s.  co m*/
 * 
 * @param idODE
 *            Identificador del ODE.
 * @param valoracion
 *            Valoracion asignada al ODE
 * @return se retorna un VO con el resultado de la operacion.
 * @throws Exception
 * 
 */
protected ReindexarODEResultadoVO handleReindexarODEPublicado(String idODE, Float valoracion) throws Exception {

    // Comprobar que el identificador del ODE que me pasan coincide con un
    // ODE que esta en estado PUBLICADO
    IdODECriteria criterio = new IdODECriteria();
    criterio.setIdODE(idODE);
    criterio.setEstadoTransitado(null);
    List<Transicion> estadoActual = this.getTransicionDao().buscarEstadoPorCriterioIdODE(criterio);
    if (estadoActual != null && estadoActual.get(0) != null
            && estadoActual.get(0).getEstadoActual().getNombre().equals(SrvPublicacionServiceImpl.PUBLICADO)) {
        if (logger.isDebugEnabled())
            logger.debug("El ode con identificador [" + idODE + "] se encuentra publicado");

        // Obtener la localizacion del fichero imsmanifest del ODE y
        // parsearlo.
        String rutaManifest = this.getSrvLocalizadorService().consultaLocalizador(idODE).getPath();
        Manifest imsmanifest;
        try {
            File extraeSubmanifest = new File(rutaManifest, MANIFEST_NAME);
            imsmanifest = this.getScormDao().parsearODEEager(extraeSubmanifest);
        } catch (Exception e) {
            logger.error("Error realizando el parseo del ODE[" + idODE + "]. Imposible reindexar el ODE.["
                    + e.getCause() + "]");
            return new ReindexarODEResultadoVO(rutaManifest, ERROR_PARSEO_MANIFEST, 11);
        }

        // Mapear la informacion de indexacion en el VO que pasamos al
        // indexador, utilizando la valoracion
        // que nos pasan para indexarla.
        // rellenamos y aadimos a la lista todos los idodevos
        es.pode.indexador.negocio.servicios.indexado.IdODEVO ODEaIndexar;
        try {
            ManifestAgrega manifAgrega = new ManifestAgrega(imsmanifest);
            ODEaIndexar = rellenaIdOdeVO(manifAgrega, rutaManifest, idODE, valoracion.toString(),
                    new Float(tamanioDir(rutaManifest).floatValue()));
        } catch (Exception e) {
            logger.error("Error realizando el mapeo de indexacion del ODE[" + idODE
                    + "]. Imposible mapear el ODE.[" + e.getCause() + "]");
            return new ReindexarODEResultadoVO(rutaManifest, ERROR_MAPEO_INDEXADO, 12);
        }

        // Llamar al indexador reindexando el ODE concreto.
        es.pode.indexador.negocio.servicios.indexado.IdODEVO[] arrayIDODES = new IdODEVO[] { ODEaIndexar };
        IndexadorVO[] retornoIndexador = this.getSrvIndexadorService().reindexarODE(arrayIDODES);

        ReindexarODEResultadoVO retornoPublicador = new ReindexarODEResultadoVO();
        if (retornoIndexador != null && retornoIndexador.length > 1)
            this.getBeanMapper().map(retornoIndexador, retornoPublicador);
        return retornoPublicador;

    } else {
        if (logger.isDebugEnabled())
            logger.debug("El ode con identificador [" + idODE + "] no estaba publicado");
        return new ReindexarODEResultadoVO("", "10.7", 7);
    }

}

From source file:ca.oson.json.Oson.java

private String float2JsonDefault(FieldData objectDTO) {
    Float valueToReturn = json2FloatDefault(objectDTO);

    if (valueToReturn == null) {
        return null;
    }//from w  w w . j a v  a  2 s  .co  m

    return valueToReturn.toString();
}