Example usage for android.os Bundle getFloat

List of usage examples for android.os Bundle getFloat

Introduction

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

Prototype

@Override
public float getFloat(String key, float defaultValue) 

Source Link

Document

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

Usage

From source file:org.onebusaway.android.map.RouteMapController.java

@Override
public void setState(Bundle args) {
    assert (args != null);
    String routeId = args.getString(MapParams.ROUTE_ID);

    // If the previous map zoom isn't the default, then zoom to that level as a start
    float mapZoom = args.getFloat(MapParams.ZOOM, MapParams.DEFAULT_ZOOM);
    if (mapZoom != MapParams.DEFAULT_ZOOM) {
        mFragment.getMapView().setZoom(mapZoom);
    }/* w w  w  .  ja v  a  2 s.c o m*/

    mZoomToRoute = args.getBoolean(MapParams.ZOOM_TO_ROUTE, false);
    mZoomIncludeClosestVehicle = args.getBoolean(MapParams.ZOOM_INCLUDE_CLOSEST_VEHICLE, false);
    if (!routeId.equals(mRouteId)) {
        if (mRouteId != null) {
            clearCurrentState();
        }

        // Set up the new route
        mRouteId = routeId;
        mRoutePopup.showLoading();
        mFragment.showProgress(true);
        //mFragment.getLoaderManager().restartLoader(ROUTES_LOADER, null, this);
        mRouteLoader = mRouteLoaderListener.onCreateLoader(ROUTES_LOADER, null);
        mRouteLoader.registerListener(0, mRouteLoaderListener);
        mRouteLoader.startLoading();

        mVehiclesLoader = mVehicleLoaderListener.onCreateLoader(VEHICLES_LOADER, null);
        mVehiclesLoader.registerListener(0, mVehicleLoaderListener);
        mVehiclesLoader.startLoading();
    } else {
        // We are returning to the route view with the route already set, so show the header
        mRoutePopup.show();
    }
}

From source file:info.guardianproject.notepadbot.NoteEdit.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.note_edit);/*  www  .  ja v a2 s .  c o  m*/

    // Find all the views now to save time searching later multiple times
    mImageView = (ImageView) findViewById(R.id.odata);
    mBodyText = (LinedEditText) findViewById(R.id.body);
    mTitleText = (EditText) findViewById(R.id.title);

    // Show the Up button in the action bar.
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (savedInstanceState != null) {
        mRowId = savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID);
        mTextSize = savedInstanceState.getFloat(TEXT_SIZE, 0);
    }

    if (mTextSize == 0)
        mTextSize = getSharedPreferences(PREFS_NAME, MODE_PRIVATE).getFloat(TEXT_SIZE, 0);

    if (mTextSize != 0)
        mBodyText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);

    mCacheWord = new CacheWordActivityHandler(this, ((App) getApplication()).getCWSettings());

}

From source file:com.ibm.mf.geofence.demo.MapsActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (savedInstanceState != null) {
        double[] loc = savedInstanceState.getDoubleArray("currentLocation");
        if (loc != null) {
            currentLocation = new Location(LocationManager.NETWORK_PROVIDER);
            currentLocation.setLatitude(loc[0]);
            currentLocation.setLongitude(loc[1]);
            currentLocation.setTime(System.currentTimeMillis());
        }/*w w  w  . j  a  va  2s  .c  om*/
        currentZoom = savedInstanceState.getFloat("zoom", -1f);
        //log.debug(String.format("restored currentLocation=%s; currentZoom=%f", currentLocation, currentZoom));
    }
}

From source file:com.hro.museapp.map.ClusteringMapActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cluster_map);

    listType = getIntent().getIntExtra("type", TYPE_ALL);

    ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    FragmentManager fm = getSupportFragmentManager();
    SupportMapFragment f = (SupportMapFragment) fm.findFragmentById(R.id.map);
    map = f.getExtendedMap();//from ww w  . j a va 2  s  .co  m

    gps = new GPSTracker(ClusteringMapActivity.this);
    //gps = PlacesLoader.getGPS();

    // mapView = (MapView) this.findViewById(R.id.map);

    float cameraZoom = 8;
    LatLng cameraLatLng = new LatLng(52.281602, 5.503235);
    if (savedInstanceState != null) {
        double savedLat = savedInstanceState.getDouble("lat");
        double savedLng = savedInstanceState.getDouble("lng");
        cameraLatLng = new LatLng(savedLat, savedLng);

        cameraZoom = savedInstanceState.getFloat("zoom", 12);
    }
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(cameraLatLng, cameraZoom));

    map.setClustering(new ClusteringSettings().iconDataProvider(new DemoIconProvider(getResources()))
            .addMarkersDynamically(true));
    map.setMyLocationEnabled(true);

    map.setInfoWindowAdapter(new InfoWindowAdapter() {

        private TextView tv;
        {
            tv = new TextView(ClusteringMapActivity.this);
            tv.setTextColor(Color.BLACK);
        }

        private Collator collator = Collator.getInstance();
        private Comparator<Marker> comparator = new Comparator<Marker>() {
            public int compare(Marker lhs, Marker rhs) {
                String leftTitle = lhs.getTitle();
                String rightTitle = rhs.getTitle();
                if (leftTitle == null && rightTitle == null) {
                    return 0;
                }
                if (leftTitle == null) {
                    return 1;
                }
                if (rightTitle == null) {
                    return -1;
                }
                return collator.compare(leftTitle, rightTitle);
            }
        };

        @Override
        public View getInfoWindow(Marker marker) {
            return null;
        }

        @Override
        public View getInfoContents(Marker marker) {
            if (marker.isCluster()) {
                List<Marker> markers = marker.getMarkers();
                int i = 0;
                String text = "";
                while (i < 3 && markers.size() > 0) {
                    Marker m = Collections.min(markers, comparator);
                    String title = m.getTitle();
                    if (title == null) {
                        break;
                    }
                    text += title + "\n";
                    markers.remove(m);
                    i++;
                }
                if (text.length() == 0) {
                    text = "Markers with mutable data";
                } else if (markers.size() > 0) {
                    text += "and " + markers.size() + " more...";
                } else {
                    text = text.substring(0, text.length() - 1);
                }
                tv.setText(text);
                return tv;
            } else {
                String title = marker.getTitle();
                tv.setText(title);
                return tv;
            }
        }
    });

    map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

        @Override
        public void onInfoWindowClick(Marker marker) {
            if (marker.isCluster()) {
                List<Marker> markers = marker.getMarkers();
                Builder builder = LatLngBounds.builder();
                for (Marker m : markers) {
                    builder.include(m.getPosition());
                }
                LatLngBounds bounds = builder.build();
                map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds,
                        getResources().getDimensionPixelSize(R.dimen.padding)));
            } else {
                // String title = marker.getTitle();
                // String mid = MarkerGenerator.mapPlaceToId.get(title);
                String mid = (String) marker.getData();

                Intent in = new Intent(getApplicationContext(), ShowPlaceActivity.class);
                // sending mid to next activity
                in.putExtra(MarkerGenerator.TAG_MID, mid);

                // starting new activity and expecting some response back
                startActivityForResult(in, 100);
            }
        }
    });

    // MarkerGenerator.addMarkers(map);
    new AddMarkersInBackground().execute();

}

From source file:com.android.talkback.SpeechController.java

/**
 * Plays all earcons stored in a {@link FeedbackFragment}.
 *
 * @param fragment The fragment to process
 *//* w ww. j  ava 2  s  .c om*/
private void playEarconsFromFragment(FeedbackFragment fragment) {
    final Bundle nonSpeechParams = fragment.getNonSpeechParams();
    final float earconRate = nonSpeechParams.getFloat(Utterance.KEY_METADATA_EARCON_RATE, 1.0f);
    final float earconVolume = nonSpeechParams.getFloat(Utterance.KEY_METADATA_EARCON_VOLUME, 1.0f);

    for (int keyResId : fragment.getEarcons()) {
        mFeedbackController.playAuditory(keyResId, earconRate, earconVolume);
    }
}

From source file:com.ibm.mf.geofence.demo.MapsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    log.debug("***************************************************************************************");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maps_activity);
    mapCrossHair = (ImageView) findViewById(R.id.map_cross_hair);
    log.debug("in onCreate() tracking is " + (trackingEnabled ? "enabled" : "disabled"));
    addFenceButton = (Button) findViewById(R.id.addFenceButton);
    addFenceButton.setOnClickListener(new View.OnClickListener() {
        @Override/*w w  w. jav  a2s.c  o  m*/
        public void onClick(View v) {
            switchMode();
        }
    });
    if (savedInstanceState != null) {
        double[] loc = savedInstanceState.getDoubleArray("currentLocation");
        if (loc != null) {
            currentLocation = new Location(LocationManager.NETWORK_PROVIDER);
            currentLocation.setLatitude(loc[0]);
            currentLocation.setLongitude(loc[1]);
            currentLocation.setTime(System.currentTimeMillis());
        }
        currentZoom = savedInstanceState.getFloat("zoom", -1f);
        log.debug(String.format("restored currentLocation=%s; currentZoom=%f", currentLocation, currentZoom));
    }
    if (currentLocation == null) {
        LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        currentLocation = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    }
    log.debug("onCreate() : init of geofencing service");
    /*
    if (!dbDeleted) {
    dbDeleted = true;
    DemoUtils.deleteGeofenceDB(this);
    }
    */
    initManager();
    /*
    // testing the loading from a zip resource
    manager.loadGeofencesFromResource("com/ibm/pisdk/geofencing/geofence_2016-03-18_14_38_04.zip");
    */
    customHttpService = new CustomHttpService(manager, this, SERVER_URL, USER, PWD);
    try {
        startSimulation(geofenceHolder.getFences());
    } catch (Exception e) {
        log.error("error in startSimulation()", e);
    }
}

From source file:com.ez.gallery.ucrop.UCropActivity.java

/**
 * This method extracts {@link com.ez.gallery.ucrop.UCrop.Options #optionsBundle} from incoming intent
 * and setups Activity, {@link OverlayView} and {@link CropImageView} properly.
 *//*from   ww w . j a va  2s  . c  o m*/
@SuppressWarnings("deprecation")
private void processOptions(@NonNull Intent intent) {
    Bundle optionsBundle = intent.getBundleExtra(UCrop.EXTRA_OPTIONS);
    if (optionsBundle != null) {
        // Bitmap compression options
        String compressionFormatName = optionsBundle.getString(UCrop.Options.EXTRA_COMPRESSION_FORMAT_NAME);
        Bitmap.CompressFormat compressFormat = null;
        if (!TextUtils.isEmpty(compressionFormatName)) {
            compressFormat = Bitmap.CompressFormat.valueOf(compressionFormatName);
        }
        mCompressFormat = (compressFormat == null) ? DEFAULT_COMPRESS_FORMAT : compressFormat;

        mCompressQuality = optionsBundle.getInt(UCrop.Options.EXTRA_COMPRESSION_QUALITY,
                UCropActivity.DEFAULT_COMPRESS_QUALITY);

        // Gestures options
        int[] allowedGestures = optionsBundle.getIntArray(UCrop.Options.EXTRA_ALLOWED_GESTURES);
        if (allowedGestures != null && allowedGestures.length == TABS_COUNT) {
            mAllowedGestures = allowedGestures;
        }

        // Crop image view options
        mGestureCropImageView.setMaxBitmapSize(optionsBundle.getInt(UCrop.Options.EXTRA_MAX_BITMAP_SIZE,
                CropImageView.DEFAULT_MAX_BITMAP_SIZE));
        mGestureCropImageView.setMaxScaleMultiplier(optionsBundle.getFloat(
                UCrop.Options.EXTRA_MAX_SCALE_MULTIPLIER, CropImageView.DEFAULT_MAX_SCALE_MULTIPLIER));
        mGestureCropImageView.setImageToWrapCropBoundsAnimDuration(
                optionsBundle.getInt(UCrop.Options.EXTRA_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION,
                        CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION));

        // Overlay view options
        mOverlayView.setDimmedColor(optionsBundle.getInt(UCrop.Options.EXTRA_DIMMED_LAYER_COLOR,
                getResources().getColor(R.color.ucrop_color_default_dimmed)));
        mOverlayView.setOvalDimmedLayer(optionsBundle.getBoolean(UCrop.Options.EXTRA_OVAL_DIMMED_LAYER,
                OverlayView.DEFAULT_OVAL_DIMMED_LAYER));

        mOverlayView.setShowCropFrame(optionsBundle.getBoolean(UCrop.Options.EXTRA_SHOW_CROP_FRAME,
                OverlayView.DEFAULT_SHOW_CROP_FRAME));
        mOverlayView.setCropFrameColor(optionsBundle.getInt(UCrop.Options.EXTRA_CROP_FRAME_COLOR,
                getResources().getColor(R.color.ucrop_color_default_crop_frame)));
        mOverlayView.setCropFrameStrokeWidth(optionsBundle.getInt(UCrop.Options.EXTRA_CROP_FRAME_STROKE_WIDTH,
                getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_frame_stoke_width)));

        mOverlayView.setShowCropGrid(optionsBundle.getBoolean(UCrop.Options.EXTRA_SHOW_CROP_GRID,
                OverlayView.DEFAULT_SHOW_CROP_GRID));
        mOverlayView.setCropGridRowCount(optionsBundle.getInt(UCrop.Options.EXTRA_CROP_GRID_ROW_COUNT,
                OverlayView.DEFAULT_CROP_GRID_ROW_COUNT));
        mOverlayView.setCropGridColumnCount(optionsBundle.getInt(UCrop.Options.EXTRA_CROP_GRID_COLUMN_COUNT,
                OverlayView.DEFAULT_CROP_GRID_COLUMN_COUNT));
        mOverlayView.setCropGridColor(optionsBundle.getInt(UCrop.Options.EXTRA_CROP_GRID_COLOR,
                getResources().getColor(R.color.ucrop_color_default_crop_grid)));
        mOverlayView.setCropGridStrokeWidth(optionsBundle.getInt(UCrop.Options.EXTRA_CROP_GRID_STROKE_WIDTH,
                getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_grid_stoke_width)));
    }
}

From source file:com.github.omadahealth.slidepager.lib.views.ProgressView.java

@Override
protected void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        final Bundle bundle = (Bundle) state;
        Resources res = getContext().getResources();
        mShowStreaks = bundle.getBoolean(INSTANCE_SHOW_STREAKS, true);
        mShowProgressText = bundle.getBoolean(INSTANCE_SHOW_PROGRESS_TEXT, true);
        mShowProgressPlusMark = bundle.getBoolean(INSTANCE_SHOW_PROGRESS_PLUSMARK, true);
        mHasToReanimate = bundle.getBoolean(INSTANCE_REANIMATE, true);

        mCompletedColor = bundle.getInt(INSTANCE_COMPLETED_COLOR,
                res.getColor(R.color.default_progress_completed_reach_color));
        mCompletedFillColor = bundle.getInt(INSTANCE_COMPLETED_FILL_COLOR,
                res.getColor(R.color.default_progress_completed_fill_color));

        mNotCompletedReachColor = bundle.getInt(INSTANCE_NOT_COMPLETED_COLOR,
                res.getColor(R.color.default_progress_not_completed_reach_color));
        mNotCompletedOutlineColor = bundle.getInt(INSTANCE_NOT_COMPLETED_OUTLINE_COLOR,
                res.getColor(R.color.default_progress_not_completed_outline_color));
        mNotCompletedOutlineSize = bundle.getFloat(INSTANCE_NOT_COMPLETED_OUTLINE_SIZE,
                res.getDimension(R.dimen.circular_bar_default_outline_width));
        mNotCompletedFutureOutlineSize = bundle.getFloat(INSTANCE_NOT_COMPLETED_FUTURE_OUTLINE_SIZE,
                res.getDimension(R.dimen.circular_bar_default_future_outline_width));
        mNotCompletedFillColor = bundle.getInt(INSTANCE_NOT_COMPLETED_FILL_COLOR,
                res.getColor(R.color.default_progress_not_completed_fill_color));

        mSpecialReachColor = bundle.getInt(INSTANCE_SPECIAL_COMPLETED_COLOR,
                res.getColor(R.color.default_progress_special_reach_color));
        mSpecialOutlineColor = bundle.getInt(INSTANCE_SPECIAL_COMPLETED_OUTLINE_COLOR,
                res.getColor(R.color.default_progress_special_outline_color));
        mSpecialFillColor = bundle.getInt(INSTANCE_SPECIAL_COMPLETED_FILL_COLOR,
                res.getColor(R.color.default_progress_special_fill_color));

        mProgressTextColor = bundle.getInt(INSTANCE_TEXT_COLOR,
                res.getColor(R.color.default_progress_text_color));

        mReachedWidth = bundle.getFloat(INSTANCE_REACHED_WIDTH,
                res.getDimension(R.dimen.default_progress_reached_width));

        super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE));
        return;//  ww w  .j  a v  a2s .  c o m
    }
    super.onRestoreInstanceState(state);
}