Example usage for android.os Bundle putFloat

List of usage examples for android.os Bundle putFloat

Introduction

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

Prototype

@Override
public void putFloat(@Nullable String key, float value) 

Source Link

Document

Inserts a float value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

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

/**
 * Returns a Bundle representation of this map. No transient data is stored.
 * /*from  w w w. j  a  v a 2s. com*/
 * @return
 */
public Bundle toBundle() {
    Bundle b = new Bundle();
    b.putString("name", name);

    b.putInt("rows", rows);
    b.putInt("columns", columns);
    b.putFloat("scale", scale);
    b.putFloat("xOff", xOff);
    b.putFloat("yOff", yOff);
    for (int idxRow = 0; idxRow < rows; idxRow++) {
        for (int idxCol = 0; idxCol < columns; idxCol++) {
            if (tilePaths[idxRow][idxCol] != null) {
                b.putString("paths_" + idxRow + "_" + idxCol, tilePaths[idxRow][idxCol]);
                b.putByte("angles_" + idxRow + "_" + idxCol, tileAngles[idxRow][idxCol]);
            }
        }
    }
    return b;
}

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

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putFloat(STATE_TEXT_SIZE, mTextSize);
    outState.putString(STATE_CONTENT, mContent);
    outState.putString(STATE_TYPEFACE_NAME, mTypefaceName);
}

From source file:com.android.screenspeak.eventprocessor.ProcessorEventQueue.java

/**
 * Provides feedback for the specified utterance.
 *
 * @param queueMode The queueMode of the Utterance.
 * @param utterance The utterance to provide feedback for.
 *///from   w  w  w . j  a v  a 2 s .  com
private void provideFeedbackForUtterance(int queueMode, Utterance utterance) {
    final Bundle metadata = utterance.getMetadata();
    final float earconRate = metadata.getFloat(Utterance.KEY_METADATA_EARCON_RATE, 1.0f);
    final float earconVolume = metadata.getFloat(Utterance.KEY_METADATA_EARCON_VOLUME, 1.0f);
    final Bundle nonSpeechMetadata = new Bundle();
    nonSpeechMetadata.putFloat(Utterance.KEY_METADATA_EARCON_RATE, earconRate);
    nonSpeechMetadata.putFloat(Utterance.KEY_METADATA_EARCON_VOLUME, earconVolume);

    // Retrieve and play all spoken text.
    final CharSequence textToSpeak = StringBuilderUtils.getAggregateText(utterance.getSpoken());
    final int flags = metadata.getInt(Utterance.KEY_METADATA_SPEECH_FLAGS, 0);
    final Bundle speechMetadata = metadata.getBundle(Utterance.KEY_METADATA_SPEECH_PARAMS);

    final int utteranceGroup = utterance.getMetadata().getInt(Utterance.KEY_UTTERANCE_GROUP,
            SpeechController.UTTERANCE_GROUP_DEFAULT);

    mSpeechController.speak(textToSpeak, utterance.getAuditory(), utterance.getHaptic(), queueMode, flags,
            utteranceGroup, speechMetadata, nonSpeechMetadata);
}

From source file:com.variable.demo.api.fragment.MotionFragment.java

@Override
public void onMagnetometerUpdate(MotionSensor sensor, MotionReading reading) {
    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_MAGNETOMETER_READING);
    Bundle b = m.getData();
    b.putFloat(MessageConstants.X_VALUE_KEY, (reading.getX() + 6) * DECIMAL_PRECISION);
    b.putFloat(MessageConstants.Y_VALUE_KEY, (reading.getY() + 6) * DECIMAL_PRECISION);
    b.putFloat(MessageConstants.Z_VALUE_KEY, (reading.getZ() + 6) * DECIMAL_PRECISION);

    //For this demo we are streaming all time stamp from the node device.
    b.putLong(MessageConstants.TIME_STAMP, reading.getTimeStamp().getTime());
    b.putInt(MessageConstants.TIME_SOURCE, reading.getTimeStampSource());

    final Context thiscontext = this.getActivity();
    final String serialnumOne = sensor.getSerialNumber();
    final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
    final String scanX = Float.toString((reading.getX() + 16) * DECIMAL_PRECISION);
    final String scanY = Float.toString((reading.getY() + 16) * DECIMAL_PRECISION);
    final String scanZ = Float.toString((reading.getZ() + 16) * DECIMAL_PRECISION);
    String json = "magnetometer;" + serialnum + ";" + scanX + "," + scanY + "," + scanZ;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(//from   w  w w. j  av a  2  s  . c o  m
            "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]="
                    + json)
            .setLogging("MyLogs", Log.DEBUG).asString().withResponse()
            .setCallback(new FutureCallback<Response<String>>() {
                @Override
                public void onCompleted(Exception e, Response<String> result) {
                    if (e == null) {
                        Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString());
                    } else {
                        Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION");
                        e.printStackTrace();
                    }
                }
            });

    m.sendToTarget();
}

From source file:com.variable.demo.api.fragment.MotionFragment.java

@Override
public void onGyroscopeUpdate(MotionSensor sensor, MotionReading reading) {
    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_GYROSCOPE_READING);
    Bundle b = m.getData();
    b.putFloat(MessageConstants.X_VALUE_KEY, (reading.getX() + 2000) * DECIMAL_PRECISION);
    b.putFloat(MessageConstants.Y_VALUE_KEY, (reading.getY() + 2000) * DECIMAL_PRECISION);
    b.putFloat(MessageConstants.Z_VALUE_KEY, (reading.getZ() + 2000) * DECIMAL_PRECISION);

    //For this demo we are streaming all time stamp from the node device.
    b.putLong(MessageConstants.TIME_STAMP, reading.getTimeStamp().getTime());
    b.putInt(MessageConstants.TIME_SOURCE, reading.getTimeStampSource());

    final Context thiscontext = this.getActivity();
    final String serialnumOne = sensor.getSerialNumber();
    final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
    final String scanX = Float.toString((reading.getX() + 16) * DECIMAL_PRECISION);
    final String scanY = Float.toString((reading.getY() + 16) * DECIMAL_PRECISION);
    final String scanZ = Float.toString((reading.getZ() + 16) * DECIMAL_PRECISION);
    String json = "gyroscope;" + serialnum + ";" + scanX + "," + scanY + "," + scanZ;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(/*w w w.  j a v  a  2 s.  co  m*/
            "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]="
                    + json)
            .setLogging("MyLogs", Log.DEBUG).asString().withResponse()
            .setCallback(new FutureCallback<Response<String>>() {
                @Override
                public void onCompleted(Exception e, Response<String> result) {
                    if (e == null) {
                        Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString());
                    } else {
                        Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION");
                        e.printStackTrace();
                    }
                }
            });

    m.sendToTarget();
}

From source file:com.variable.demo.api.fragment.MotionFragment.java

@Override
public void onAccelerometerUpdate(MotionSensor sensor, MotionReading reading) {
    DateFormat formatter = new SimpleDateFormat("MM-dd-yyyy hh:mm.ss");

    // Log.d(TAG, "TimeStamp Source: " + reading.getTimeStampSource());
    // Log.d(TAG," Time:" + formatter.format(reading.getTimeStamp()));

    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_ACCELEROMETER_READING);
    Bundle b = m.getData();
    b.putFloat(MessageConstants.X_VALUE_KEY, (reading.getX() + 16) * DECIMAL_PRECISION);
    b.putFloat(MessageConstants.Y_VALUE_KEY, (reading.getY() + 16) * DECIMAL_PRECISION);
    b.putFloat(MessageConstants.Z_VALUE_KEY, (reading.getZ() + 16) * DECIMAL_PRECISION);

    //For this demo we are streaming all time stamp from the node device.
    b.putLong(MessageConstants.TIME_STAMP, reading.getTimeStamp().getTime());
    b.putInt(MessageConstants.TIME_SOURCE, reading.getTimeStampSource());

    final Context thiscontext = this.getActivity();
    final String serialnumOne = sensor.getSerialNumber();
    final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
    final String scanX = Float.toString((reading.getX() + 16) * DECIMAL_PRECISION);
    final String scanY = Float.toString((reading.getY() + 16) * DECIMAL_PRECISION);
    final String scanZ = Float.toString((reading.getZ() + 16) * DECIMAL_PRECISION);
    String json = "accelerometer;" + serialnum + ";" + scanX + "," + scanY + "," + scanZ;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(/*from  w w w .  jav a 2s .  c  o  m*/
            "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]="
                    + json)
            .setLogging("MyLogs", Log.DEBUG).asString().withResponse()
            .setCallback(new FutureCallback<Response<String>>() {
                @Override
                public void onCompleted(Exception e, Response<String> result) {
                    if (e == null) {
                        Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString());
                    } else {
                        Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION");
                        e.printStackTrace();
                    }
                }
            });

    m.sendToTarget();
}

From source file:com.dsi.ant.antplus.pluginsampler.fitnessequipment.Dialog_ConfigSettings.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    builder.setTitle("Settings Configuration");
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View detailsView = inflater.inflate(R.layout.dialog_fe_settings, null);

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(detailsView);//w  ww  .j  a va 2s .co m

    // Add action buttons
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent i = new Intent(Dialog_ConfigSettings.this.getActivity(),
                    Activity_FitnessEquipmentSampler.class);
            Bundle b = new Bundle();
            b.putString(SETTINGS_NAME, et_friendlyName.getText().toString());
            b.putShort(SETTINGS_AGE, Short.parseShort(et_age.getText().toString()));
            b.putFloat(SETTINGS_HEIGHT, Float.parseFloat(et_height.getText().toString()) / 100f); // Convert to m
            b.putFloat(SETTINGS_WEIGHT, Float.parseFloat(et_weight.getText().toString()));
            b.putBoolean(SETTINGS_GENDER, rb_male.isChecked());
            b.putBoolean(INCLUDE_WORKOUT, cb_workout.isChecked());
            i.putExtras(b);
            startActivity(i);
        }
    });

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Let dialog dismiss
        }
    });

    et_friendlyName = (EditText) detailsView.findViewById(R.id.editText_FriendlyName);
    et_age = (EditText) detailsView.findViewById(R.id.editText_Age);
    et_height = (EditText) detailsView.findViewById(R.id.editText_Height);
    et_weight = (EditText) detailsView.findViewById(R.id.editText_Weight);
    rb_female = (RadioButton) detailsView.findViewById(R.id.radioButton_Female);
    rb_male = (RadioButton) detailsView.findViewById(R.id.radioButton_Male);
    cb_workout = (CheckBox) detailsView.findViewById(R.id.checkBox_Workout);

    return builder.create();
}

From source file:com.android.talkback.eventprocessor.ProcessorEventQueue.java

/**
 * Provides feedback for the specified utterance.
 *
 * @param queueMode The queueMode of the Utterance.
 * @param utterance The utterance to provide feedback for.
 *///  w  w  w  .  j a  v a2 s.co m
private void provideFeedbackForUtterance(int queueMode, Utterance utterance) {
    final Bundle metadata = utterance.getMetadata();
    final float earconRate = metadata.getFloat(Utterance.KEY_METADATA_EARCON_RATE, 1.0f);
    final float earconVolume = metadata.getFloat(Utterance.KEY_METADATA_EARCON_VOLUME, 1.0f);
    final Bundle nonSpeechMetadata = new Bundle();
    nonSpeechMetadata.putFloat(Utterance.KEY_METADATA_EARCON_RATE, earconRate);
    nonSpeechMetadata.putFloat(Utterance.KEY_METADATA_EARCON_VOLUME, earconVolume);

    // Perform cleanup of spoken text for each separate part of the utterance, e.g. we do not
    // want to combine repeated characters if they span different parts, and we still want to
    // expand single-character symbols if a certain part is a single character.
    final SpannableStringBuilder textToSpeak = new SpannableStringBuilder();
    for (CharSequence text : utterance.getSpoken()) {
        if (!TextUtils.isEmpty(text)) {
            CharSequence processedText = SpeechCleanupUtils.collapseRepeatedCharactersAndCleanUp(mContext,
                    text);
            StringBuilderUtils.appendWithSeparator(textToSpeak, processedText);
        }
    }

    // Get speech settings from utterance.
    final int flags = metadata.getInt(Utterance.KEY_METADATA_SPEECH_FLAGS, 0);
    final Bundle speechMetadata = metadata.getBundle(Utterance.KEY_METADATA_SPEECH_PARAMS);

    final int utteranceGroup = utterance.getMetadata().getInt(Utterance.KEY_UTTERANCE_GROUP,
            SpeechController.UTTERANCE_GROUP_DEFAULT);

    mSpeechController.speak(textToSpeak, utterance.getAuditory(), utterance.getHaptic(), queueMode, flags,
            utteranceGroup, speechMetadata, nonSpeechMetadata);
}

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

@Override
public Parcelable onSaveInstanceState() {
    final Bundle state = new Bundle();
    state.putParcelable("super_state", super.onSaveInstanceState());
    state.putInt("page_position", pagePosition);
    state.putFloat("page_offset", pageOffset);
    return state;
}

From source file:nz.ac.auckland.lablet.script.components.ScriptComponentPotentialEnergy1View.java

@Override
public void toBundle(Bundle bundle) {
    super.toBundle(bundle);

    bundle.putFloat("mass", mass);
    bundle.putFloat("height", height);
    bundle.putFloat("energy", energy);
    bundle.putFloat("pbjValue", pbjValue);
}