Example usage for android.os Bundle getDouble

List of usage examples for android.os Bundle getDouble

Introduction

In this page you can find the example usage for android.os Bundle getDouble.

Prototype

public double getDouble(String key) 

Source Link

Document

Returns the value associated with the given key, or 0.0 if no mapping of the desired type exists for the given key.

Usage

From source file:org.florescu.android.rangeseekbar.RangeSeekBar.java

/**
 * Overridden to restore instance state when device orientation changes. This method is called automatically if you assign an id to the RangeSeekBar widget using the {@link #setId(int)} method.
 *///from   w  w  w .ja va2  s . c  o m
@Override
protected void onRestoreInstanceState(Parcelable parcel) {
    final Bundle bundle = (Bundle) parcel;
    super.onRestoreInstanceState(bundle.getParcelable("SUPER"));
    normalizedMinValue = bundle.getDouble("MIN");
    normalizedMaxValue = bundle.getDouble("MAX");
}

From source file:de.j4velin.mapsmeasure.Map.java

@Override
protected void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    try {/* ww  w .j  a  va2 s.co  m*/
        metric = savedInstanceState.getBoolean("metric");
        @SuppressWarnings("unchecked")
        // Casting to Stack<LatLng> apparently results in
        // "java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Stack"
        // on some devices
        List<LatLng> tmp = (List<LatLng>) savedInstanceState.getSerializable("trace");
        Iterator<LatLng> it = tmp.iterator();
        while (it.hasNext()) {
            addPoint(it.next());
        }
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
                new LatLng(savedInstanceState.getDouble("position-lat"),
                        savedInstanceState.getDouble("position-lon")),
                savedInstanceState.getFloat("position-zoom")));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.wheelmap.android.fragment.POIsOsmdroidFragment.java

public void onRestoreInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState == null) {
        return;/*from  w w  w. j  a v a 2  s  . c o m*/
    }

    int la = savedInstanceState.getInt(Extra.LATITUDE);
    int lo = savedInstanceState.getInt(Extra.LONGITUDE);
    int zoom = savedInstanceState.getInt(Extra.ZOOM_LEVEL);

    mCurrentLocationGeoPoint = new GeoPoint(la, lo);

    setZoomIntern(zoom);

    centerMap(mCurrentLocationGeoPoint, true);

    if (savedInstanceState.containsKey(Extra.SELECTED_LATITUDE)) {
        Location selectedLocation = new Location("gps");
        selectedLocation.setLongitude(savedInstanceState.getDouble(Extra.SELECTED_LONGITUDE));
        selectedLocation.setLatitude(savedInstanceState.getDouble(Extra.SELECTED_LATITUDE));
        markItemOverlay.setLocation(selectedLocation);
    }

    requestUpdate();

}

From source file:org.onebusaway.android.ui.HomeActivity.java

/**
 * Sets up the initial map state, based on a previous savedInstanceState for this activity,
 * or an Intent that was passed into this activity
 *///from w  w w.jav  a2  s.c  o  m
private void setupMapState(Bundle savedInstanceState) {
    String stopId;
    // Check savedInstanceState to see if there is a previous state for this activity
    if (savedInstanceState != null) {
        // We're recreating an instance with a previous state, so show the focused stop in panel
        stopId = savedInstanceState.getString(STOP_ID);

        if (stopId != null) {
            mFocusedStopId = stopId;
            // We don't have an ObaStop or ObaRoute mapping, so just pass in null for those
            updateArrivalListFragment(stopId, null, null);
        }
    } else {
        // Check intent passed into Activity
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            // Did this activity start to focus on a stop?  If so, set focus and show arrival info
            stopId = bundle.getString(MapParams.STOP_ID);
            double lat = bundle.getDouble(MapParams.CENTER_LAT);
            double lon = bundle.getDouble(MapParams.CENTER_LON);

            if (stopId != null && lat != 0.0 && lon != 0.0) {
                mFocusedStopId = stopId;
                updateArrivalListFragment(stopId, null, null);
            }
        }
    }
}

From source file:org.onebusaway.android.ui.ArrivalsListFragment.java

@Override
public Location getStopLocation() {
    Location location = null;/*from   w w w  .ja  va  2 s .  com*/
    if (mStop != null) {
        location = mStop.getLocation();
    } else {
        // Check the arguments
        Bundle args = getArguments();
        double latitude = args.getDouble(STOP_LAT);
        double longitude = args.getDouble(STOP_LON);
        if (latitude != 0 && longitude != 0) {
            location = LocationUtils.makeLocation(latitude, longitude);
        }
    }
    return location;
}

From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java

@Override
protected void onRestoreInstanceState(Bundle load) {
    super.onRestoreInstanceState(load);

    if (load != null && load.containsKey(INSTANCE_TRACK)) {
        mTrackId = load.getLong(INSTANCE_TRACK);
        mAverageSpeed = load.getDouble(INSTANCE_SPEED);
        mMapView.getController().setZoom(LoggerMap.ZOOM_LEVEL);
        GeoPoint storedPoint = new GeoPoint(load.getInt(INSTANCE_E6LAT), load.getInt(INSTANCE_E6LONG));
        mMapView.getController().setCenter(storedPoint);
    }//from  www . java2  s .c  o m
}

From source file:com.mirasense.scanditsdk.plugin.ScanditSDK.java

private void resize(JSONArray data) {
    if (mBarcodePicker != null) {
        final Bundle bundle = new Bundle();
        try {//from w w w  . ja v  a2s .  c om
            if (data.length() < 1) {
                Log.e("ScanditSDK",
                        "The resize call received too few arguments and has to return without starting.");
                return;
            }
            setOptionsOnBundle(data.getJSONObject(0), bundle);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
                ScanditSDKParameterParser.updatePickerUIFromBundle(mBarcodePicker, bundle, display.getWidth(),
                        display.getHeight());
                double animationDuration = 0;
                if (bundle.containsKey(ScanditSDKParameterParser.paramAnimationDuration)) {
                    animationDuration = bundle.getDouble(ScanditSDKParameterParser.paramAnimationDuration);
                }
                adjustLayout(bundle, animationDuration);
            }
        });
    }
}

From source file:com.inmobi.ultrapush.AnalyzeActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    // will be calls after the onStart()
    super.onRestoreInstanceState(savedInstanceState);

    dtRMS = savedInstanceState.getDouble("dtRMS");
    dtRMSFromFT = savedInstanceState.getDouble("dtRMSFromFT");
    maxAmpDB = savedInstanceState.getDouble("maxAmpDB");
    maxAmpFreq = savedInstanceState.getDouble("maxAmpFreq");
}

From source file:com.wirelessmoves.cl.MainActivity.java

@SuppressWarnings("deprecation")
@Override//from   w w w .j a  v a  2 s .  c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    /* If saved variable state exists from last run, recover it */
    if (savedInstanceState != null) {
        NumberOfSignalStrengthUpdates = savedInstanceState.getLong("NumberOfSignalStrengthUpdates");

        LastCellId = savedInstanceState.getLong("LastCellId");
        NumberOfCellChanges = savedInstanceState.getLong("NumberOfCellChanges");

        LastLacId = savedInstanceState.getLong("LastLacId");
        NumberOfLacChanges = savedInstanceState.getLong("NumberOfLacChanges");

        PreviousCells = savedInstanceState.getLongArray("PreviousCells");
        PreviousCellsIndex = savedInstanceState.getInt("PreviousCellsIndex");
        NumberOfUniqueCellChanges = savedInstanceState.getLong("NumberOfUniqueCellChanges");

        outputDebugInfo = savedInstanceState.getBoolean("outputDebugInfo");

        CurrentLocationLong = savedInstanceState.getDouble("CurrentLocationLong");
        CurrentLocationLat = savedInstanceState.getDouble("CurrentLocationLat");

        /* attempt to restore the previous gps location information object */
        PrevLocation = (Location) getLastNonConfigurationInstance();

    } else {
        /* Initialize PreviousCells Array to defined values */
        for (int x = 0; x < PreviousCells.length; x++)
            PreviousCells[x] = 0;
    }

    /* Get a handle to the telephony manager service */
    /* A listener will be installed in the object from the onResume() method */
    MyListener = new MyPhoneStateListener();
    Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    /* get a handle to the power manager and set a wake lock so the screen saver
     * is not activated after a timeout */
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");

    /* Get a handle to the location system for getting GPS information */
    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    gpsListener = new myLocationListener();
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener);

}

From source file:nl.skope.android.service.WorkerThread.java

/***
 * Calls the Skope mLocation service for the given mLocation. 
 *
 * @param bundle//from w w w. j a va 2  s . c  om
 *            Bundle contains the current mLocation as a pair of
 *            latitude/longitude doubles. Since the message could 
 *            be posted from the UI, the bundle might be empty.
 *            In that case use the current mLocation stored in the
 *            parent service. 
 */
private void findObjectsOfInterest(final Bundle bundle) {
    Location currentLocation;
    ObjectOfInterestList objectOfInterestList = new ObjectOfInterestList();

    mCache.setStateFindObjectsOfInterest("Searching objects of interest nearby");
    mUiQueue.postToUi(Type.FIND_OBJECTS_OF_INTEREST_START, null, true);

    JSONArray jsonResponse = new JSONArray();

    // Check if bundle is present
    if (bundle == null) {
        // Bundle not present
        currentLocation = mCache.getCurrentLocation();

        // If the current mLocation is not known, post message
        if (currentLocation == null) {
            mCache.setStateFindObjectsOfInterest("Finished");
            mUiQueue.postToUi(Type.UNDETERMINED_LOCATION, null, true);
            return;
        }
    } else {
        // Bundle present, extract mLocation information
        double latitude = bundle.getDouble(LocationService.LATITUDE);
        double longitude = bundle.getDouble(LocationService.LONGITUDE);
        String provider = bundle.getString(LocationService.PROVIDER);
        currentLocation = new Location(provider);
        currentLocation.setLatitude(latitude);
        currentLocation.setLongitude(longitude);
    }

    String username = mCache.getPreferences().getString(SkopeApplication.PREFS_USERNAME, "");
    String password = mCache.getPreferences().getString(SkopeApplication.PREFS_PASSWORD, "");
    String serviceUrl = mCache.getProperty("skope_service_url") + "/skope/";

    // Set up HTTP client
    CustomHttpClient client = new CustomHttpClient(serviceUrl, mLocationService.getApplicationContext());
    client.setUseBasicAuthentication(true);
    client.setUsernamePassword(username, password);

    client.addParam("lat", String.valueOf(currentLocation.getLatitude()));
    client.addParam("lng", String.valueOf(currentLocation.getLongitude()));
    client.addParam("status_message", mCache.getUser().getStatus());

    // Send HTTP request to web service
    try {
        client.execute(RequestMethod.GET);
    } catch (Exception e) {
        // Most exceptions already handled by client
        e.printStackTrace();
    }

    String response = client.getResponse();

    if (response == null) {
        return;
    } else {
        // Extract JSON data from response
        try {
            jsonResponse = new JSONArray(response);
        } catch (JSONException e) {
            // Log exception
            Log.e(TAG, e.toString());
            return;
        }

        // Copy the JSON list of objects to our OOI list
        objectOfInterestList.clear();
        for (int i = 0; i < jsonResponse.length(); i++) {
            try {
                JSONObject jsonObject = jsonResponse.getJSONObject(i);

                // Create new object of interest
                User user = new User(jsonObject);
                user.setCache(mCache);

                // If current user, skip
                if (user.getId() != mCache.getUser().getId()) {
                    // Set distance
                    user.setDistanceToLocation(currentLocation);
                    // Add to list
                    objectOfInterestList.add(user);
                }

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    mCache.getObjectOfInterestList().update(objectOfInterestList);

    mCache.setStateFindObjectsOfInterest("Finished");
    mUiQueue.postToUi(Type.FIND_OBJECTS_OF_INTEREST_FINISHED, null, true);

    /*if (bundle != null) {
    Bundle outBundle = new Bundle();
    outBundle.putString("TEXT",
            "Searching objects of interest finished. Called from ["
                    + bundle.getString("TEXT") + "]");
    mUiQueue.postToUi(Type.SHOW_DIALOG, outBundle, false);
    }*/
}