Example usage for java.lang Double doubleToRawLongBits

List of usage examples for java.lang Double doubleToRawLongBits

Introduction

In this page you can find the example usage for java.lang Double doubleToRawLongBits.

Prototype

@HotSpotIntrinsicCandidate
public static native long doubleToRawLongBits(double value);

Source Link

Document

Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout, preserving Not-a-Number (NaN) values.

Usage

From source file:com.nextgis.mobile.fragment.MapFragment.java

@Override
public void onPause() {
    if (null != mCurrentLocationOverlay) {
        mCurrentLocationOverlay.stopShowingCurrentLocation();
    }//from  w w  w. j  a  va  2  s . c om
    if (null != mGpsEventSource) {
        mGpsEventSource.removeListener(this);
    }
    if (null != mEditLayerOverlay) {
        mEditLayerOverlay.removeListener(this);
    }

    final SharedPreferences.Editor edit = mPreferences.edit();
    if (null != mMap) {
        edit.putFloat(SettingsConstantsUI.KEY_PREF_ZOOM_LEVEL, mMap.getZoomLevel());
        GeoPoint point = mMap.getMapCenter();
        edit.putLong(SettingsConstantsUI.KEY_PREF_SCROLL_X, Double.doubleToRawLongBits(point.getX()));
        edit.putLong(SettingsConstantsUI.KEY_PREF_SCROLL_Y, Double.doubleToRawLongBits(point.getY()));

        mMap.removeListener(this);
    }
    edit.apply();

    super.onPause();
}

From source file:com.neovisionaries.security.Digest.java

/**
 * Update the wrapped {@code MessageDigest} object with the
 * given input data./*from  w  ww.  j  a v a2  s .c  om*/
 *
 * <p>
 * This method converts the given {@code double} value to a
 * {@code long} by {@link Double#doubleToRawLongBits(double)}
 * and then passes it to {@link #update(long)}.
 * </p>
 *
 * @param input
 *         Input data.
 *
 * @return
 *         {@code this} object.
 */
public Digest update(double input) {
    return update(Double.doubleToRawLongBits(input));
}

From source file:it.geosolutions.geocollect.android.core.mission.PendingMissionListFragment.java

/**
 * Handle the results/*from w w w.jav a  2  s. c o  m*/
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(TAG, "onActivityResult()");
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == PendingMissionListActivity.SPATIAL_QUERY) {

        if (data != null && data.hasExtra("query")) {
            BaseFeatureInfoQuery query = data.getParcelableExtra("query");

            // Create task query
            if (query instanceof BBoxQuery) {
                BBoxQuery bbox = (BBoxQuery) query;

                // TODO: Refactor the Preferences Double Storage
                // This is just a fast hack to store Doubles in Long but It should be handled by a more clean utility class
                // Maybe extend the Preference Editor?

                Log.v(TAG, "Received:\nN: " + bbox.getN() + "\nN: " + bbox.getS() + "\nE: " + bbox.getE()
                        + "\nW: " + bbox.getW() + "\nSRID: " + bbox.getSrid());
                SharedPreferences sp = getSherlockActivity()
                        .getSharedPreferences(SQLiteCascadeFeatureLoader.PREF_NAME, Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = sp.edit();
                editor.putLong(SQLiteCascadeFeatureLoader.FILTER_N, Double.doubleToRawLongBits(bbox.getN()));
                editor.putLong(SQLiteCascadeFeatureLoader.FILTER_S, Double.doubleToRawLongBits(bbox.getS()));
                editor.putLong(SQLiteCascadeFeatureLoader.FILTER_W, Double.doubleToRawLongBits(bbox.getW()));
                editor.putLong(SQLiteCascadeFeatureLoader.FILTER_E, Double.doubleToRawLongBits(bbox.getE()));
                editor.putInt(SQLiteCascadeFeatureLoader.FILTER_SRID, Integer.parseInt(bbox.getSrid()));
                editor.commit();

                forceLoad();
                Toast.makeText(getActivity(), getString(R.string.selection_filtered), Toast.LENGTH_SHORT)
                        .show();
            }

            // else if(query instanceof CircleQuery){ }

        } else {

            // No result, clean the filter
            SharedPreferences sp = getSherlockActivity()
                    .getSharedPreferences(SQLiteCascadeFeatureLoader.PREF_NAME, Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = sp.edit();
            editor.remove(SQLiteCascadeFeatureLoader.FILTER_N);
            editor.remove(SQLiteCascadeFeatureLoader.FILTER_S);
            editor.remove(SQLiteCascadeFeatureLoader.FILTER_W);
            editor.remove(SQLiteCascadeFeatureLoader.FILTER_E);
            editor.remove(SQLiteCascadeFeatureLoader.FILTER_SRID);
            editor.commit();

            forceLoad();

        }

    } else if (requestCode == ARG_ENABLE_GPS) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "back from GPS settings");
        }
        PendingMissionListActivity.startMissionFeatureCreation(getSherlockActivity());
    } else {

        missionTemplate = ((GeoCollectApplication) getActivity().getApplication()).getTemplate();
        CURRENT_LOADER_INDEX = missionTemplate.getLoaderIndex();
        adapter.setTemplate(missionTemplate);
        forceLoad();
    }
}