|
26 | 26 | import io.pslab.activity.AccelerometerActivity; |
27 | 27 | import io.pslab.activity.BarometerActivity; |
28 | 28 | import io.pslab.activity.CompassActivity; |
| 29 | +import io.pslab.activity.GasSensorActivity; |
29 | 30 | import io.pslab.activity.GyroscopeActivity; |
30 | 31 | import io.pslab.activity.LogicalAnalyzerActivity; |
31 | 32 | import io.pslab.activity.LuxMeterActivity; |
|
38 | 39 | import io.pslab.activity.WaveGeneratorActivity; |
39 | 40 | import io.pslab.models.AccelerometerData; |
40 | 41 | import io.pslab.models.BaroData; |
| 42 | +import io.pslab.models.GasSensorData; |
41 | 43 | import io.pslab.models.GyroData; |
42 | 44 | import io.pslab.models.CompassData; |
43 | 45 | import io.pslab.models.LogicAnalyzerData; |
@@ -131,6 +133,10 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, int position) { |
131 | 133 | holder.sensor.setText(R.string.logical_analyzer); |
132 | 134 | holder.tileIcon.setImageDrawable(context.getResources().getDrawable(R.drawable.tile_icon_logic_analyzer)); |
133 | 135 | break; |
| 136 | + case PSLabSensor.GAS_SENSOR: |
| 137 | + holder.sensor.setText(R.string.gas_sensor); |
| 138 | + holder.tileIcon.setImageDrawable(context.getResources().getDrawable(R.drawable.robotic_arm)); |
| 139 | + break; |
134 | 140 | default: |
135 | 141 | break; |
136 | 142 | } |
@@ -216,6 +222,11 @@ private void handleCardViewClick(SensorDataBlock block) { |
216 | 222 | laIntent.putExtra(KEY_LOG, true); |
217 | 223 | laIntent.putExtra(DATA_BLOCK, block.getBlock()); |
218 | 224 | context.startActivity(laIntent); |
| 225 | + } else if (block.getSensorType().equalsIgnoreCase(context.getResources().getString(R.string.gas_sensor))) { |
| 226 | + Intent gasSensorIntent = new Intent(context, GasSensorActivity.class); |
| 227 | + gasSensorIntent.putExtra(KEY_LOG, true); |
| 228 | + gasSensorIntent.putExtra(DATA_BLOCK, block.getBlock()); |
| 229 | + context.startActivity(gasSensorIntent); |
219 | 230 | } |
220 | 231 | } |
221 | 232 |
|
@@ -257,6 +268,8 @@ public void onClick(DialogInterface dialog, int whichButton) { |
257 | 268 | LocalDataLog.with().clearBlockOfMultimeterRecords(block.getBlock()); |
258 | 269 | } else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.LOGIC_ANALYZER)) { |
259 | 270 | LocalDataLog.with().clearBlockOfLARecords(block.getBlock()); |
| 271 | + } else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.GAS_SENSOR)) { |
| 272 | + LocalDataLog.with().clearBlockOfGasSensorRecords(block.getBlock()); |
260 | 273 | } |
261 | 274 | LocalDataLog.with().clearSensorBlock(block.getBlock()); |
262 | 275 | dialog.dismiss(); |
@@ -493,6 +506,22 @@ private void populateMapData(SensorDataBlock block) { |
493 | 506 | } |
494 | 507 | } |
495 | 508 | setMapDataToIntent(array); |
| 509 | + } else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.GAS_SENSOR)) { |
| 510 | + RealmResults<GasSensorData> data = LocalDataLog.with().getBlockOfGasSensorRecords(block.getBlock()); |
| 511 | + JSONArray array = new JSONArray(); |
| 512 | + for (GasSensorData d : data) { |
| 513 | + try { |
| 514 | + JSONObject i = new JSONObject(); |
| 515 | + i.put("date", CSVLogger.FILE_NAME_FORMAT.format(d.getTime())); |
| 516 | + i.put("ppmValue", d.getPpmValue()); |
| 517 | + i.put("lon", d.getLon()); |
| 518 | + i.put("lat", d.getLat()); |
| 519 | + if (d.getLat() != 0.0 && d.getLon() != 0.0) array.put(i); |
| 520 | + } catch (JSONException e) { |
| 521 | + e.printStackTrace(); |
| 522 | + } |
| 523 | + } |
| 524 | + setMapDataToIntent(array); |
496 | 525 | } |
497 | 526 | } |
498 | 527 |
|
|
0 commit comments