/** @param enabled */ public void setInterfaceEnabled(boolean enabled) { // Enable interface elements. findViewById(R.id.startButton).setEnabled(enabled); findViewById(R.id.stopButton).setEnabled(enabled); findViewById(R.id.removeButton).setEnabled(enabled); for (CheckBoxSource cbs : checkboxs) cbs.getCheckbox().setEnabled(enabled); // Always disabled. // findViewById(R.id.xText).setEnabled(enabled); // findViewById(R.id.yText).setEnabled(enabled); }
public boolean equals(Object o) { CheckBoxSource checkBoxSource = (CheckBoxSource) o; return checkBoxSource.getSourceId().equals(sourceId) && checkBoxSource.getSignalTypeId().equals(signalType); }
public void onStartTap(View v) { // Get point object from map. try { currentPoint = getCurrentPoint(); } catch (Exception e) { Toast.makeText(this, R.string.error_invalid_coordinate, Toast.LENGTH_LONG).show(); return; } // Stores the list of listened signals. recordedSignalTypes = new ArrayList<String>(); // Stores, for each signal type, the desired samples amount. HashMap<String, Integer> signalsSamplesCount = new HashMap<String, Integer>(); for (CheckBoxSource cbs : checkboxs) { if (cbs.getCheckbox().isChecked()) { Preferences.writeBoolean( this.getClass().getSimpleName(), "Source_" + cbs.getSourceId(), true); String signalTypeId = cbs.getSignalTypeId(); if (!recordedSignalTypes.contains(signalTypeId)) recordedSignalTypes.add(signalTypeId); if (!signalsSamplesCount.containsKey(signalTypeId)) { ArrayList<View> containers = AndroidUtil.getViewsByTag(this, signalTypeId + "-samples"); EditText samplesEditText = (EditText) containers.get(0); try { int samplesCount = Integer.parseInt(samplesEditText.getText().toString()); Preferences.writeString( this.getClass().getSimpleName(), "Signal_" + signalTypeId, samplesCount + ""); signalsSamplesCount.put(signalTypeId, samplesCount); } catch (Exception e) { Toast.makeText(this, R.string.error_samples_count, Toast.LENGTH_LONG).show(); return; } } } else { Preferences.writeBoolean( this.getClass().getSimpleName(), "Source_" + cbs.getSourceId(), false); } } // Stores, for each signal type, the desired sources. HashMap<String, List<String>> signalSources = new HashMap<String, List<String>>(); for (CheckBoxSource cbs : checkboxs) { if (cbs.getCheckbox().isChecked()) { if (!signalSources.containsKey(cbs.getSignalTypeId())) signalSources.put(cbs.getSignalTypeId(), new ArrayList<String>()); List<String> sources = signalSources.get(cbs.getSignalTypeId()); sources.add(cbs.getSourceId()); } } // Begins record process at each sensor. for (BaseSensor sensor : sensors) { String signalTypeId = sensor.getSignalTypeId(); if (signalSources.containsKey(signalTypeId)) { // Log.i("NewPointActivity", "starting record: "+signalTypeId+ " // ("+signalsSamplesCount.get(signalTypeId)+" samples)"); List<String> sources = signalSources.get(signalTypeId); sensor.beginRecord(sources, signalsSamplesCount.get(signalTypeId)); } } }