List of usage examples for android.os Bundle getFloatArray
@Override @Nullable public float[] getFloatArray(@Nullable String key)
From source file:ca.farrelltonsolar.classic.PVOutputUploader.java
private boolean doUpload(ChargeController controller) throws InterruptedException, IOException { String uploadDateString = controller.uploadDate(); String SID = controller.getSID(); String fName = controller.getPVOutputLogFilename(); if (fName != null && fName.length() > 0 && SID != null && SID.length() > 0) { DateTime logDate = PVOutputService.LogDate(); int numberOfDays = Constants.PVOUTPUT_RECORD_LIMIT; if (uploadDateString.length() > 0) { DateTime uploadDate = DateTime.parse(uploadDateString, DateTimeFormat.forPattern("yyyy-MM-dd")); numberOfDays = Days.daysBetween(uploadDate, logDate).getDays(); }/*from w w w. j a v a2s . c om*/ numberOfDays = numberOfDays > Constants.PVOUTPUT_RECORD_LIMIT ? Constants.PVOUTPUT_RECORD_LIMIT : numberOfDays; // limit to 20 days as per pvOutput limits if (numberOfDays > 0) { Log.d(getClass().getName(), String.format("PVOutput uploading: %s for %d days on thread: %s", fName, numberOfDays, Thread.currentThread().getName())); DateTime now = DateTime.now(); String UploadDate = DateTimeFormat.forPattern("yyyy-MM-dd").print(now); Bundle logs = load(fName); float[] mData = logs.getFloatArray(String.valueOf(Constants.CLASSIC_KWHOUR_DAILY_CATEGORY)); // kWh/day boolean uploadDateRecorded = false; for (int i = 0; i < numberOfDays; i++) { logDate = logDate.minusDays(1); // latest log entry is for yesterday Socket pvOutputSocket = Connect(pvOutput); DataOutputStream outputStream = new DataOutputStream( new BufferedOutputStream(pvOutputSocket.getOutputStream())); String dateStamp = DateTimeFormat.forPattern("yyyyMMdd").print(logDate); StringBuilder feed = new StringBuilder("GET /service/r2/addoutput.jsp"); feed.append("?key="); feed.append(APIKey); feed.append("&sid="); feed.append(SID); feed.append("&d="); feed.append(dateStamp); feed.append("&g="); String wh = String.valueOf(mData[i] * 100); feed.append(wh); feed.append("\r\n"); feed.append("Host: "); feed.append(pvOutput); feed.append("\r\n"); feed.append("\r\n"); String resp = feed.toString(); outputStream.writeBytes(resp); outputStream.flush(); pvOutputSocket.close(); if (uploadDateRecorded == false) { controller.setUploadDate(UploadDate); uploadDateRecorded = true; } Thread.sleep(Constants.PVOUTPUT_RATE_LIMIT); // rate limit } return true; } } return false; }
From source file:eu.geopaparazzi.library.core.dialogs.StrokeDashDialogFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle arguments = getArguments(); if (arguments != null) { mInitialDash = arguments.getFloatArray(PREFS_KEY_STROKEDASH); if (mInitialDash != null) { mCurrentDash = mInitialDash; }//from w w w .j a v a 2 s.c o m mDashShift = arguments.getFloat(PREFS_KEY_STROKEDASHSHIFT); } }
From source file:com.crcrch.chromatictuner.GraphFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_power_spectrum, container, false); graph = (LineChart) view.findViewById(R.id.graph); graph.setNoDataText(getString(R.string.graph_no_data)); graph.setDescription(graphDescription); if (savedInstanceState != null) { float[] savedData = savedInstanceState.getFloatArray(STATE_DATA); if (savedData != null) { setData(savedData);//from w w w. j a v a 2 s.c o m } } return view; }
From source file:com.glabs.homegenie.util.VoiceControl.java
@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, 20000).show(); interpretInput(s);/*from w w w . j ava 2 s. c o m*/ // msg += s; break; } } }
From source file:com.mrchandler.disableprox.ui.TaskerSensorSettingsActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); BundleScrubber.scrub(getIntent());/*from w ww . j a v a 2s .c o m*/ final Bundle localeBundle = getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE); BundleScrubber.scrub(localeBundle); if (null == savedInstanceState) { if (PluginBundleManager.isBundleValid(localeBundle)) { String sensorStatusKey = localeBundle.getString(PluginBundleManager.BUNDLE_EXTRA_SENSOR_STATUS_KEY); int sensorStatusValue = localeBundle.getInt(PluginBundleManager.BUNDLE_EXTRA_SENSOR_STATUS_VALUE); float[] sensorMockValues = localeBundle .getFloatArray(PluginBundleManager.BUNDLE_EXTRA_SENSOR_MOCK_VALUES_VALUES); Sensor sensor = SensorUtil.getSensorFromUniqueSensorKey(this, sensorStatusKey); TaskerSensorSettingsFragment fragment = TaskerSensorSettingsFragment.newInstance(sensorStatusKey, sensorStatusValue, sensorMockValues); getSupportFragmentManager().beginTransaction() .replace(R.id.fragment_container, fragment, CURRENT_FRAGMENT).commit(); String sensorTitle = SensorUtil.getHumanStringType(sensor); if (sensorTitle == null) { sensorTitle = sensor.getName(); //Probably won't really return null but who knows... if (sensorTitle == null) { sensorTitle = "Unknown Sensor"; } } setTitle(sensorTitle); currentFragment = fragment; if (drawer != null) { drawer.closeDrawer(GravityCompat.START); } if (currentFragment == null) { fab.hide(); } else { fab.show(); } } } initInAppBilling(); fab.setImageResource(R.drawable.ic_check_white_24dp); }
From source file:ai.api.unityhelper.RecognitionHelper.java
protected void onResults(final Bundle results) { JSONObject resultJson = new JSONObject(); try {/* w ww . j av a 2s. c o m*/ resultJson.put("status", "success"); final ArrayList<String> recognitionResults = results .getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); if (recognitionResults == null || recognitionResults.size() == 0) { resultJson.put("recognitionResults", new JSONArray()); } else { resultJson.put("recognitionResults", new JSONArray(recognitionResults)); float[] rates = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { rates = results.getFloatArray(SpeechRecognizer.CONFIDENCE_SCORES); if (rates != null && rates.length > 0) { final JSONArray ratesArray = new JSONArray(); for (int i = 0; i < rates.length; i++) { ratesArray.put(rates[i]); } resultJson.put("confidence", ratesArray); } } } } catch (JSONException je) { Log.e(TAG, je.getMessage(), je); } clearRecognizer(); String resultJsonString = resultJson.toString(); if (resultObject != null) { resultObject.setResult(resultJsonString); } }
From source file:atlc.granadaaccessibilityranking.VoiceActivity.java
/******************************************************************************************************** * This class implements the {@link android.speech.RecognitionListener} interface, * thus it implement its methods. However not all of them were interesting to us: * ****************************************************************************************************** *///from w w w . j a v a 2 s.c o m @SuppressLint("InlinedApi") /* * (non-Javadoc) * * Invoked when the ASR provides recognition results * * @see android.speech.RecognitionListener#onResults(android.os.Bundle) */ @Override public void onResults(Bundle results) { if (results != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { //Checks the API level because the confidence scores are supported only from API level 14: //http://developer.android.com/reference/android/speech/SpeechRecognizer.html#CONFIDENCE_SCORES //Processes the recognition results and their confidences processAsrResults(results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION), results.getFloatArray(SpeechRecognizer.CONFIDENCE_SCORES)); // Attention: It is not RecognizerIntent.EXTRA_RESULTS, that is for intents (see the ASRWithIntent app) } else { //Processes the recognition results and their confidences processAsrResults(results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION), null); } } else //Processes recognition errors processAsrError(SpeechRecognizer.ERROR_NO_MATCH); }
From source file:conversandroid.RichASR.java
/******************************************************************************************************** * Process ASR events// w w w . ja v a 2s. c o m * ****************************************************************************************************** */ /* * (non-Javadoc) * * Invoked when the ASR provides recognition results * * @see android.speech.RecognitionListener#onResults(android.os.Bundle) */ @Override public void onResults(Bundle results) { if (results != null) { Log.i(LOGTAG, "ASR results received ok"); ((TextView) findViewById(R.id.feedbackTxt)).setText("Results ready :D"); //Retrieves the N-best list and the confidences from the ASR result ArrayList<String> nBestList = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); float[] nBestConfidences = null; if (Build.VERSION.SDK_INT >= 14) //Checks the API level because the confidence scores are supported only from API level 14 nBestConfidences = results.getFloatArray(SpeechRecognizer.CONFIDENCE_SCORES); //Creates a collection of strings, each one with a recognition result and its confidence //following the structure "Phrase matched (conf: 0.5)" ArrayList<String> nBestView = new ArrayList<String>(); for (int i = 0; i < nBestList.size(); i++) { if (nBestConfidences != null) { if (nBestConfidences[i] >= 0) nBestView.add( nBestList.get(i) + " (conf: " + String.format("%.2f", nBestConfidences[i]) + ")"); else nBestView.add(nBestList.get(i) + " (no confidence value available)"); } else nBestView.add(nBestList.get(i) + " (no confidence value available)"); } //Includes the collection in the ListView of the GUI setListView(nBestView); } else { Log.e(LOGTAG, "ASR results null"); //There was a recognition error ((TextView) findViewById(R.id.feedbackTxt)).setText("Error"); } stopListening(); }
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 w w w . j a v a2 s. 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.facebook.LegacyTokenCacheTest.java
@Test public void testAllTypes() { Bundle originalBundle = new Bundle(); putBoolean(BOOLEAN_KEY, originalBundle); putBooleanArray(BOOLEAN_ARRAY_KEY, originalBundle); putByte(BYTE_KEY, originalBundle);//w ww . j a va2s.co m putByteArray(BYTE_ARRAY_KEY, originalBundle); putShort(SHORT_KEY, originalBundle); putShortArray(SHORT_ARRAY_KEY, originalBundle); putInt(INT_KEY, originalBundle); putIntArray(INT_ARRAY_KEY, originalBundle); putLong(LONG_KEY, originalBundle); putLongArray(LONG_ARRAY_KEY, originalBundle); putFloat(FLOAT_KEY, originalBundle); putFloatArray(FLOAT_ARRAY_KEY, originalBundle); putDouble(DOUBLE_KEY, originalBundle); putDoubleArray(DOUBLE_ARRAY_KEY, originalBundle); putChar(CHAR_KEY, originalBundle); putCharArray(CHAR_ARRAY_KEY, originalBundle); putString(STRING_KEY, originalBundle); putStringList(STRING_LIST_KEY, originalBundle); originalBundle.putSerializable(SERIALIZABLE_KEY, AccessTokenSource.FACEBOOK_APPLICATION_WEB); ensureApplicationContext(); LegacyTokenHelper cache = new LegacyTokenHelper(RuntimeEnvironment.application); cache.save(originalBundle); LegacyTokenHelper cache2 = new LegacyTokenHelper(RuntimeEnvironment.application); Bundle cachedBundle = cache2.load(); assertEquals(originalBundle.getBoolean(BOOLEAN_KEY), cachedBundle.getBoolean(BOOLEAN_KEY)); assertArrayEquals(originalBundle.getBooleanArray(BOOLEAN_ARRAY_KEY), cachedBundle.getBooleanArray(BOOLEAN_ARRAY_KEY)); assertEquals(originalBundle.getByte(BYTE_KEY), cachedBundle.getByte(BYTE_KEY)); assertArrayEquals(originalBundle.getByteArray(BYTE_ARRAY_KEY), cachedBundle.getByteArray(BYTE_ARRAY_KEY)); assertEquals(originalBundle.getShort(SHORT_KEY), cachedBundle.getShort(SHORT_KEY)); assertArrayEquals(originalBundle.getShortArray(SHORT_ARRAY_KEY), cachedBundle.getShortArray(SHORT_ARRAY_KEY)); assertEquals(originalBundle.getInt(INT_KEY), cachedBundle.getInt(INT_KEY)); assertArrayEquals(originalBundle.getIntArray(INT_ARRAY_KEY), cachedBundle.getIntArray(INT_ARRAY_KEY)); assertEquals(originalBundle.getLong(LONG_KEY), cachedBundle.getLong(LONG_KEY)); assertArrayEquals(originalBundle.getLongArray(LONG_ARRAY_KEY), cachedBundle.getLongArray(LONG_ARRAY_KEY)); assertEquals(originalBundle.getFloat(FLOAT_KEY), cachedBundle.getFloat(FLOAT_KEY), TestUtils.DOUBLE_EQUALS_DELTA); assertArrayEquals(originalBundle.getFloatArray(FLOAT_ARRAY_KEY), cachedBundle.getFloatArray(FLOAT_ARRAY_KEY)); assertEquals(originalBundle.getDouble(DOUBLE_KEY), cachedBundle.getDouble(DOUBLE_KEY), TestUtils.DOUBLE_EQUALS_DELTA); assertArrayEquals(originalBundle.getDoubleArray(DOUBLE_ARRAY_KEY), cachedBundle.getDoubleArray(DOUBLE_ARRAY_KEY)); assertEquals(originalBundle.getChar(CHAR_KEY), cachedBundle.getChar(CHAR_KEY)); assertArrayEquals(originalBundle.getCharArray(CHAR_ARRAY_KEY), cachedBundle.getCharArray(CHAR_ARRAY_KEY)); assertEquals(originalBundle.getString(STRING_KEY), cachedBundle.getString(STRING_KEY)); assertListEquals(originalBundle.getStringArrayList(STRING_LIST_KEY), cachedBundle.getStringArrayList(STRING_LIST_KEY)); assertEquals(originalBundle.getSerializable(SERIALIZABLE_KEY), cachedBundle.getSerializable(SERIALIZABLE_KEY)); }