下面列出了android.os.Bundle#getFloatArray ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onResults(Bundle results) {
if ((results != null)
&& results.containsKey(SpeechRecognizer.RESULTS_RECOGNITION)) {
List<String> heard =
results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
float[] scores =
results.getFloatArray(SpeechRecognizer.CONFIDENCE_SCORES);
String msg = "";
for (String s : heard) {
Toast.makeText(_hgcontext.getApplicationContext(), "Executing: " + s, Toast.LENGTH_LONG).show();
interpretInput(s);
// msg += s;
break;
}
}
}
@Override
public void onRestoreInstanceState(Parcelable state)
{
if (state instanceof Bundle)
{
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
normalizedScale = bundle.getFloat("saveScale");
m = bundle.getFloatArray("matrix");
prevMatrix.setValues(m);
prevMatchViewHeight = bundle.getFloat("matchViewHeight");
prevMatchViewWidth = bundle.getFloat("matchViewWidth");
prevViewHeight = bundle.getInt("viewHeight");
prevViewWidth = bundle.getInt("viewWidth");
imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
return;
}
super.onRestoreInstanceState(state);
}
/**
* Takes and processes the results from a recognition action. It parses the confidence and
* string values and stores the processed results here so they are made available to the
* {@link AutocompleteController} and show up in the omnibox results. This method does not
* reorder the voice results that come back from the recognizer.
* @param extras The {@link Bundle} that contains the recognition results from a
* {@link RecognizerIntent#ACTION_RECOGNIZE_SPEECH} action.
*/
public void setVoiceResultsFromIntentBundle(Bundle extras) {
clearVoiceSearchResults();
if (extras == null) return;
ArrayList<String> strings = extras.getStringArrayList(
RecognizerIntent.EXTRA_RESULTS);
float[] confidences = extras.getFloatArray(
RecognizerIntent.EXTRA_CONFIDENCE_SCORES);
if (strings == null || confidences == null) return;
assert (strings.size() == confidences.length);
if (strings.size() != confidences.length) return;
for (int i = 0; i < strings.size(); ++i) {
// Remove any spaces in the voice search match when determining whether it
// appears to be a URL. This is to prevent cases like (
// "tech crunch.com" and "www. engadget .com" from not appearing like URLs)
// from not navigating to the URL.
// If the string appears to be a URL, then use it instead of the string returned from
// the voice engine.
String culledString = strings.get(i).replaceAll(" ", "");
String url = AutocompleteController.nativeQualifyPartialURLQuery(culledString);
mResults.add(new VoiceResult(
url == null ? strings.get(i) : culledString, confidences[i]));
}
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
colorHSV = bundle.getFloatArray("color");
updateAdjacentHue();
super.onRestoreInstanceState(bundle.getParcelable("super"));
} else {
super.onRestoreInstanceState(state);
}
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
colorHSV = bundle.getFloatArray("color");
super.onRestoreInstanceState(bundle.getParcelable("super"));
} else {
super.onRestoreInstanceState(state);
}
}
/**
* OpenAPIParser#parse(String) に testEnum.json を渡して解析を行う。
*
* parameter の type と異なる enum の宣言が存在する testEnum.json をよみこむ。
* <pre>
* 【期待する動作】
* ・Swagger オブジェクトが取得できること。
* ・parameter の enum が取得できること。
* </pre>
*/
@Test
public void testEnum() throws JSONException {
DevicePluginContext pluginContext = Mockito.mock(DevicePluginContext.class);
String jsonString = FileLoader.readString("parser/testEnum.json");
DConnectServiceSpec spec = new DConnectServiceSpec(pluginContext);
spec.addProfileSpec("testEnum", jsonString);
Bundle swagger = spec.findProfileSpec("testEnum").toBundle();
assertThat(swagger, is(notNullValue()));
Bundle paths = swagger.getBundle("paths");
assertThat(paths, is(notNullValue()));
assertThat(paths.size(), is(1));
Bundle a0 = paths.getBundle("/a0");
assertThat(a0, is(notNullValue()));
Bundle a0Get = a0.getBundle("get");
assertThat(a0Get, is(notNullValue()));
Parcelable[] parameters = a0Get.getParcelableArray("parameters");
assertThat(parameters, is(notNullValue()));
assertThat(parameters.length, is(7));
Bundle stringInt = (Bundle) parameters[1];
assertThat(stringInt.getString("type"), is("string"));
String[] stringIntEnum = stringInt.getStringArray("enum");
assertThat(stringIntEnum, is(notNullValue()));
assertThat(stringIntEnum[0], is("1"));
assertThat(stringIntEnum[1], is("2"));
assertThat(stringIntEnum[2], is("3"));
assertThat(stringIntEnum[3], is("4"));
Bundle stringNumber = (Bundle) parameters[2];
assertThat(stringNumber.getString("type"), is("string"));
String[] stringNumberEnum = stringNumber.getStringArray("enum");
assertThat(stringNumberEnum, is(notNullValue()));
assertThat(stringNumberEnum[0], is("1.1"));
assertThat(stringNumberEnum[1], is("2.2"));
assertThat(stringNumberEnum[2], is("3.3"));
assertThat(stringNumberEnum[3], is("4.4"));
Bundle intString = (Bundle) parameters[3];
assertThat(intString.getString("type"), is("integer"));
assertThat(intString.getString("format"), is("int32"));
int[] intStringEnum = intString.getIntArray("enum");
assertThat(intStringEnum, is(notNullValue()));
assertThat(intStringEnum[0], is(1));
assertThat(intStringEnum[1], is(2));
assertThat(intStringEnum[2], is(3));
assertThat(intStringEnum[3], is(4));
Bundle longString = (Bundle) parameters[4];
assertThat(longString.getString("type"), is("integer"));
assertThat(longString.getString("format"), is("int64"));
long[] longStringEnum = longString.getLongArray("enum");
assertThat(longStringEnum, is(notNullValue()));
assertThat(longStringEnum[0], is(1L));
assertThat(longStringEnum[1], is(2L));
assertThat(longStringEnum[2], is(3L));
assertThat(longStringEnum[3], is(4L));
Bundle floatString = (Bundle) parameters[5];
assertThat(floatString.getString("type"), is("number"));
assertThat(floatString.getString("format"), is("float"));
float[] floatStringEnum = floatString.getFloatArray("enum");
assertThat(floatStringEnum, is(notNullValue()));
assertThat(floatStringEnum[0], is(1.1F));
assertThat(floatStringEnum[1], is(2.2F));
assertThat(floatStringEnum[2], is(3.3F));
assertThat(floatStringEnum[3], is(4.4F));
Bundle doubleString = (Bundle) parameters[6];
assertThat(doubleString.getString("type"), is("number"));
assertThat(doubleString.getString("format"), is("double"));
double[] doubleStringEnum = doubleString.getDoubleArray("enum");
assertThat(doubleStringEnum, is(notNullValue()));
assertThat(doubleStringEnum[0], is(1.1D));
assertThat(doubleStringEnum[1], is(2.2D));
assertThat(doubleStringEnum[2], is(3.3D));
assertThat(doubleStringEnum[3], is(4.4D));
}