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) 

Source Link

Document

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

Usage

From source file:org.jraf.android.bikey.wearable.app.display.DisplayActivity.java

private void retrieveRideValues() {
    // Retrieve the latest values now, to show the elapsed time
    new AsyncTask<Void, Void, Bundle>() {
        @Override/*from   w w  w .jav a  2 s.com*/
        protected Bundle doInBackground(Void... params) {
            return WearCommHelper.get().retrieveRideValues();
        }

        @Override
        protected void onPostExecute(Bundle rideValues) {
            float rideDistance = rideValues.getFloat(CommConstants.EXTRA_DISTANCE);
            float rideSpeed = rideValues.getFloat(CommConstants.EXTRA_SPEED);
            long rideStartDateOffset = rideValues.getLong(CommConstants.EXTRA_START_DATE_OFFSET);
            int heartRate = rideValues.getInt(CommConstants.EXTRA_HEART_RATE);

            mSpeedDisplayFragment.setSpeed(rideSpeed);
            mElapsedTimeDisplayFragment.setStartDateOffset(rideStartDateOffset);
            mTotalDistanceDisplayFragment.setTotalDistance(rideDistance);
        }
    }.execute();
}

From source file:com.kaiserdev.android.clima.MapViewer.java

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

    currentMarkers = new ArrayList<Marker>();

    mMapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
    mMap = mMapFragment.getMap();//from ww w  .  j ava 2s  .  c  o m

    Bundle b = this.getIntent().getExtras();
    float lat = b.getFloat(MainActivity.CURRENT_LATITUDE);
    float log = b.getFloat(MainActivity.CURRENT_LONGITUDE);

    LatLng home = new LatLng(lat, log);
    CameraUpdate toHome = CameraUpdateFactory.newLatLngZoom(home, BASE_ZOOM);
    mMap.animateCamera(toHome);

    new AnimationWaiter().execute();
    Toast.makeText(this, "Long press anywhere to search that area.", Toast.LENGTH_LONG).show();
    mMap.setOnMapLongClickListener(new OnMapLongClickListener() {

        @Override
        public void onMapLongClick(LatLng arg0) {
            CameraUpdate toHome = CameraUpdateFactory.newLatLng(arg0);
            mMap.animateCamera(toHome);
            Toast.makeText(MapViewer.this, "Updating...", Toast.LENGTH_SHORT).show();
            new AnimationWaiter().execute();
        }
    });
}

From source file:biz.wiz.android.wallet.util.ViewPagerTabs.java

@Override
public void onRestoreInstanceState(final Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        pagePosition = bundle.getInt("page_position");
        pageOffset = bundle.getFloat("page_offset");
        super.onRestoreInstanceState(bundle.getParcelable("super_state"));
        return;/*from   w ww.  j  av  a  2 s  . com*/
    }

    super.onRestoreInstanceState(state);
}

From source file:it.sineo.android.tileMapEditor.TileMap.java

public TileMap(Bundle b) {
    name = b.getString("name");

    rows = b.getInt("rows");
    columns = b.getInt("columns");
    scale = b.getFloat("scale");
    xOff = b.getFloat("xOff");
    yOff = b.getFloat("yoff");

    tilePaths = new String[rows][columns];
    tileBitmaps = new Bitmap[rows][columns];
    tileAngles = new byte[rows][columns];
    tileMatrices = new Matrix[rows][columns];

    for (int idxRow = 0; idxRow < rows; idxRow++) {
        for (int idxCol = 0; idxCol < columns; idxCol++) {
            if (b.containsKey("paths_" + idxRow + "_" + idxCol)) {
                tilePaths[idxRow][idxCol] = b.getString("paths_" + idxRow + "_" + idxCol);
                tileAngles[idxRow][idxCol] = b.getByte("angles_" + idxRow + "_" + idxCol);
            }//from   w ww .j  av  a  2s  .c o  m
        }
    }
}

From source file:com.andryr.guitartuner.TunerActivity.java

@SuppressLint("DefaultLocale")
@Override//from   w  ww. j a  va2 s. co m
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    mNeedleView.setTipPos(savedInstanceState.getFloat(STATE_NEEDLE_POS));
    int pitchIndex = savedInstanceState.getInt(STATE_PITCH_INDEX);
    mNeedleView.setTickLabel(0.0F, String.format("%.02fHz", mTuning.pitches[pitchIndex].frequency));
    mTuningView.setSelectedIndex(pitchIndex);
    mFrequencyView.setText(String.format("%.02fHz", savedInstanceState.getFloat(STATE_LAST_FREQ)));
}

From source file:com.fenlisproject.elf.core.framework.ElfBinder.java

public static void bindFragmentArgument(Fragment receiver) {
    Field[] fields = receiver.getClass().getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);//from  ww  w .jav  a 2s.  c  o m
        FragmentArgument fragmentArgument = field.getAnnotation(FragmentArgument.class);
        if (fragmentArgument != null) {
            try {
                Bundle bundle = receiver.getArguments();
                if (bundle != null) {
                    Class<?> type = field.getType();
                    if (type == Boolean.class || type == boolean.class) {
                        field.set(receiver, bundle.getBoolean(fragmentArgument.value()));
                    } else if (type == Byte.class || type == byte.class) {
                        field.set(receiver, bundle.getByte(fragmentArgument.value()));
                    } else if (type == Character.class || type == char.class) {
                        field.set(receiver, bundle.getChar(fragmentArgument.value()));
                    } else if (type == Double.class || type == double.class) {
                        field.set(receiver, bundle.getDouble(fragmentArgument.value()));
                    } else if (type == Float.class || type == float.class) {
                        field.set(receiver, bundle.getFloat(fragmentArgument.value()));
                    } else if (type == Integer.class || type == int.class) {
                        field.set(receiver, bundle.getInt(fragmentArgument.value()));
                    } else if (type == Long.class || type == long.class) {
                        field.set(receiver, bundle.getLong(fragmentArgument.value()));
                    } else if (type == Short.class || type == short.class) {
                        field.set(receiver, bundle.getShort(fragmentArgument.value()));
                    } else if (type == String.class) {
                        field.set(receiver, bundle.getString(fragmentArgument.value()));
                    } else if (type == Boolean[].class || type == boolean[].class) {
                        field.set(receiver, bundle.getBooleanArray(fragmentArgument.value()));
                    } else if (type == Byte[].class || type == byte[].class) {
                        field.set(receiver, bundle.getByteArray(fragmentArgument.value()));
                    } else if (type == Character[].class || type == char[].class) {
                        field.set(receiver, bundle.getCharArray(fragmentArgument.value()));
                    } else if (type == Double[].class || type == double[].class) {
                        field.set(receiver, bundle.getDoubleArray(fragmentArgument.value()));
                    } else if (type == Float[].class || type == float[].class) {
                        field.set(receiver, bundle.getFloatArray(fragmentArgument.value()));
                    } else if (type == Integer[].class || type == int[].class) {
                        field.set(receiver, bundle.getIntArray(fragmentArgument.value()));
                    } else if (type == Long[].class || type == long[].class) {
                        field.set(receiver, bundle.getLongArray(fragmentArgument.value()));
                    } else if (type == Short[].class || type == short[].class) {
                        field.set(receiver, bundle.getShortArray(fragmentArgument.value()));
                    } else if (type == String[].class) {
                        field.set(receiver, bundle.getStringArray(fragmentArgument.value()));
                    } else if (Serializable.class.isAssignableFrom(type)) {
                        field.set(receiver, bundle.getSerializable(fragmentArgument.value()));
                    } else if (type == Bundle.class) {
                        field.set(receiver, bundle.getBundle(fragmentArgument.value()));
                    }
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.ravi.apps.android.newsbytes.DetailsActivity.java

/**
 * Creates the starting views required for the shared element transition.
 *//* w w w  . ja v  a 2s.co m*/
private void createTransitionStartViews(Bundle bundle) {
    // Create the view objects.
    mThumbnailView = new ImageView(this);
    mHeadlineView = new TextView(this);

    // Set the thumbnail view parameters.
    mThumbnailView.setX(bundle.getFloat(MainActivity.IMAGE_XPOS));
    mThumbnailView.setY(bundle.getFloat(MainActivity.IMAGE_YPOS));
    byte[] thumbnailByteStream = bundle.getByteArray(MainActivity.IMAGE);
    if (thumbnailByteStream != null && thumbnailByteStream.length != 0) {
        // Get the thumbnail bitmap from byte array.
        Bitmap thumbnailBitmap = BitmapFactory.decodeByteArray(thumbnailByteStream, 0,
                thumbnailByteStream.length);

        // Set the thumbnail bitmap into the image view.
        if (thumbnailBitmap != null) {
            mThumbnailView.setImageBitmap(thumbnailBitmap);
            mThumbnailView.setScaleType(ImageView.ScaleType.FIT_XY);
        }
    }

    // Set the thumbnail view parameters.
    mHeadlineView.setX(bundle.getFloat(MainActivity.TEXT_XPOS));
    mHeadlineView.setY(bundle.getFloat(MainActivity.TEXT_YPOS));
    mHeadlineView.setText(bundle.getString(MainActivity.TEXT));
}

From source file:io.github.hidroh.materialistic.ReadabilityFragment.java

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);//www .  ja  v  a  2 s .  c  om
    if (savedInstanceState != null) {
        mTextSize = savedInstanceState.getFloat(STATE_TEXT_SIZE);
        mContent = savedInstanceState.getString(STATE_CONTENT);
        mTypefaceName = savedInstanceState.getString(STATE_TYPEFACE_NAME);
    } else {
        mTextSize = toHtmlPx(Preferences.Theme.resolvePreferredReadabilityTextSize(getActivity()));
        mTypefaceName = Preferences.Theme.getReadabilityTypeface(getActivity());
    }
    mTextColor = toHtmlColor(android.R.attr.textColorPrimary);
    mTextLinkColor = toHtmlColor(android.R.attr.textColorLink);
}

From source file:com.idean.atthack.api.Param.java

/**
 * Add param value from Bundle to JsonObject
 * //w  w w . j  a  v  a 2  s.c  o  m
 * @param obj
 * @param params
 */
public void addToJson(JSONObject obj, Bundle params) {
    if (params.containsKey(name())) {
        try {
            switch (type) {
            case BOOLEAN:
                obj.put(name(), params.getBoolean(name()));
                break;
            case FLOAT:
                obj.put(name(), params.getFloat(name()));
                break;
            case INTEGER:
                obj.put(name(), params.getInt(name()));
                break;
            case STRING:
                obj.put(name(), params.getString(name()));
                break;
            default:
            }
        } catch (JSONException e) {
            Log.w(TAG, "Unable to add param " + this + " to json");
        }
    }
}

From source file:com.javielinux.fragments.SearchGeoFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    switch (requestCode) {
    case ACTIVITY_MAPSEARCH:
        if (resultCode != 0) {
            Bundle extras = intent.getExtras();
            if (extras.containsKey("longitude")) {
                longitude.setText(extras.getFloat("longitude") + "");
            }/*from   w w  w .  j  a  va 2  s .com*/

            if (extras.containsKey("latitude")) {
                latitude.setText(extras.getFloat("latitude") + "");
            }
        }
        break;
    }
}