2424
2525public class CaptureActivity extends Activity implements ICaptureActivity {
2626
27- private static Intent serviceIntent ;
2827 private CaptureService captureService ;
2928
3029 private Vibrator vibratorService ;
@@ -40,7 +39,7 @@ public void onServiceDisconnected(ComponentName name) {
4039
4140 public void onServiceConnected (ComponentName name , IBinder service ) {
4241 captureService = ((CaptureService .CaptureServiceBinder ) service ).getService ();
43- captureService .setCaptureActivity (CaptureActivity .this );
42+ CaptureService .setCaptureActivity (CaptureActivity .this );
4443 initButtons ();
4544 updateRouteName ();
4645 updateDistance ();
@@ -55,7 +54,7 @@ public void onServiceConnected(ComponentName name, IBinder service) {
5554 protected void onCreate (Bundle savedInstanceState ) {
5655 super .onCreate (savedInstanceState );
5756 setContentView (R .layout .activity_capture );
58- serviceIntent = new Intent (this , CaptureService .class );
57+ Intent serviceIntent = new Intent (this , CaptureService .class );
5958 startService (serviceIntent );
6059
6160 bindService (serviceIntent , caputreServiceConnection , Context .BIND_AUTO_CREATE );
@@ -106,13 +105,13 @@ protected void onCreate(Bundle savedInstanceState) {
106105 switch (v .getId ()) {
107106
108107 case R .id .botonIniciarCaptura :
109- if (!captureService .capturing ) {
108+ if (!CaptureService .capturing ) {
110109 startCapture ();
111110 }
112111 break ;
113112
114113 case R .id .botonFinalizarCaptura :
115- if (captureService .capturing ) {
114+ if (CaptureService .capturing ) {
116115 DialogInterface .OnClickListener dialogClickListener = (dialog , which ) -> {
117116 switch (which ) {
118117 case DialogInterface .BUTTON_POSITIVE :
@@ -166,16 +165,11 @@ protected void onCreate(Bundle savedInstanceState) {
166165 ImageButton botonBajaronPasajeros = (ImageButton ) findViewById (R .id .botonBajaronPasajeros );
167166 botonBajaronPasajeros .setOnClickListener (listener );
168167
169- //ImageView passengerImageView = (ImageView) findViewById(R.id.passengerImageView);
170- //passengerImageView.setAlpha(128);
171-
172168 initButtons ();
173-
174169 updateRouteName ();
175170 updateDistance ();
176171 updateStopCount ();
177172 updatePassengerCountDisplay ();
178-
179173 }
180174
181175
@@ -185,18 +179,18 @@ private void initButtons() {
185179 botonIniciarCaptura .setImageResource (R .drawable .start_button );
186180 ImageButton botonFinalizarCaptura = (ImageButton ) findViewById (R .id .botonFinalizarCaptura );
187181 botonFinalizarCaptura .setImageResource (R .drawable .stop_button_gray );
188- } else if (captureService .capturing ) {
182+ } else if (CaptureService .capturing ) {
189183 ImageButton botonIniciarCaptura = (ImageButton ) findViewById (R .id .botonIniciarCaptura );
190184 botonIniciarCaptura .setImageResource (R .drawable .start_button_gray );
191185 ImageButton botonFinalizarCaptura = (ImageButton ) findViewById (R .id .botonFinalizarCaptura );
192186 botonFinalizarCaptura .setImageResource (R .drawable .stop_button );
193- } else if (! captureService . capturing && captureService .currentCapture == null ) {
187+ } else if (CaptureService .currentCapture == null ) {
194188 ImageButton botonIniciarCaptura = (ImageButton ) findViewById (R .id .botonIniciarCaptura );
195189 botonIniciarCaptura .setImageResource (R .drawable .start_button_gray );
196190 ImageButton botonFinalizarCaptura = (ImageButton ) findViewById (R .id .botonFinalizarCaptura );
197191 botonFinalizarCaptura .setImageResource (R .drawable .stop_button_gray );
198192 }
199- if (!captureService .capturing && captureService .currentCapture == null && captureService .atStop ()) {
193+ if (!CaptureService .capturing && CaptureService .currentCapture == null && captureService .atStop ()) {
200194 ImageButton botonMarcarParada = (ImageButton ) findViewById (R .id .botonMarcarParada );
201195 botonMarcarParada .setImageResource (R .drawable .transit_stop_button_red );
202196 }
@@ -223,7 +217,7 @@ private void startCapture() {
223217 private void stopCapture () {
224218 if (captureService != null ) {
225219 vibratorService .vibrate (100 );
226- if (captureService .currentCapture .points .size () > 0 ) {
220+ if (CaptureService .currentCapture .points .size () > 0 ) {
227221 Toast .makeText (CaptureActivity .this , "Trazado completo" , Toast .LENGTH_SHORT ).show ();
228222 } else {
229223 Toast .makeText (CaptureActivity .this , "No se generó ningún dato" , Toast .LENGTH_SHORT ).show ();
@@ -238,22 +232,22 @@ private void stopCapture() {
238232 }
239233
240234 private void passengerAlight () {
241- if (captureService != null && captureService .capturing ) {
242- if (captureService .currentCapture .totalPassengerCount == 0 ) {
235+ if (captureService != null && CaptureService .capturing ) {
236+ if (CaptureService .currentCapture .totalPassengerCount == 0 ) {
243237 return ;
244238 }
245239 vibratorService .vibrate (5 );
246- captureService .currentCapture .totalPassengerCount --;
247- captureService .currentCapture .alightCount ++;
240+ CaptureService .currentCapture .totalPassengerCount --;
241+ CaptureService .currentCapture .alightCount ++;
248242 updatePassengerCountDisplay ();
249243 }
250244 }
251245
252246 private void passengerBoard () {
253- if (captureService != null && captureService .capturing ) {
254- captureService .currentCapture .totalPassengerCount ++;
247+ if (captureService != null && CaptureService .capturing ) {
248+ CaptureService .currentCapture .totalPassengerCount ++;
255249 vibratorService .vibrate (5 );
256- captureService .currentCapture .boardCount ++;
250+ CaptureService .currentCapture .boardCount ++;
257251 updatePassengerCountDisplay ();
258252 }
259253 }
@@ -268,14 +262,14 @@ public void triggerTransitStopDepature() {
268262
269263 private void transitStop () {
270264
271- if (captureService != null && captureService .capturing ) {
265+ if (captureService != null && CaptureService .capturing ) {
272266 try {
273267 if (captureService .atStop ()) {
274268 checkStopValidator .setEnabled (false );
275269 boolean banSignal = checkStopValidator .isChecked ();
276- captureService .departStopStop (captureService .currentCapture .boardCount , captureService .currentCapture .alightCount , banSignal );
277- captureService .currentCapture .alightCount = 0 ;
278- captureService .currentCapture .boardCount = 0 ;
270+ captureService .departStopStop (CaptureService .currentCapture .boardCount , CaptureService .currentCapture .alightCount , banSignal );
271+ CaptureService .currentCapture .alightCount = 0 ;
272+ CaptureService .currentCapture .boardCount = 0 ;
279273
280274 ImageButton botonMarcarParada = (ImageButton ) findViewById (R .id .botonMarcarParada );
281275 botonMarcarParada .setImageResource (R .drawable .transit_stop_button );
@@ -310,14 +304,9 @@ private void transitStop() {
310304 }
311305
312306 private void checkStopSignal () {
313- if (captureService != null && captureService .capturing ) {
314- StringBuffer OUTPUT = new StringBuffer ();
315- if (checkStopValidator .isChecked ()) {
316- OUTPUT .append ("Parada marcada" );
317- } else {
318- OUTPUT .append ("Parada no marcada" );
319- }
320- Toast .makeText (CaptureActivity .this , OUTPUT .toString (), Toast .LENGTH_LONG ).show ();
307+ if (captureService != null && CaptureService .capturing ) {
308+ String estatus = checkStopValidator .isChecked () ? "Parada marcada" : "Parada no marcada" ;
309+ Toast .makeText (CaptureActivity .this , estatus , Toast .LENGTH_LONG ).show ();
321310 }
322311 }
323312
@@ -329,18 +318,20 @@ private void updateRouteName() {
329318 @ SuppressLint ("SetTextI18n" )
330319 private void updateStopCount () {
331320 TextView contadorParadasText = (TextView ) findViewById (R .id .contadorParadasText );
332- contadorParadasText .setText (Integer .valueOf (captureService .currentCapture .stops .size ()).toString ());
321+ contadorParadasText .setText (Integer .valueOf (CaptureService .currentCapture .stops .size ()).toString ());
333322 }
334323
335324 public void updateDistance () {
336- TextView distanciaText = (TextView ) findViewById (R .id .distanciaText );
337- DecimalFormat distanceFormat = new DecimalFormat ("#,##0.00" );
338- distanciaText .setText (String .format ("%skm" , distanceFormat .format ((double ) (captureService .currentCapture .distance ) / 1000 )));
325+ if (CaptureService .capturing ) {
326+ TextView distanciaText = (TextView ) findViewById (R .id .distanciaText );
327+ DecimalFormat distanceFormat = new DecimalFormat ("#,##0.00" );
328+ distanciaText .setText (String .format ("%s Km" , distanceFormat .format ((double ) (CaptureService .currentCapture .distance ) / 1000 )));
329+ }
339330 }
340331
341332 public void updateDuration () {
342- if (captureService .capturing ) {
343- ((Chronometer ) findViewById (R .id .cronometroDuracion )).setBase (captureService .currentCapture .startMs );
333+ if (CaptureService .capturing ) {
334+ ((Chronometer ) findViewById (R .id .cronometroDuracion )).setBase (CaptureService .currentCapture .startMs );
344335 ((Chronometer ) findViewById (R .id .cronometroDuracion )).start ();
345336 } else {
346337 ((Chronometer ) findViewById (R .id .cronometroDuracion )).setBase (SystemClock .elapsedRealtime ());
@@ -352,24 +343,25 @@ public void updateGpsStatus() {
352343 estatusGpsLabel .setText (captureService .getGpsStatus ());
353344 }
354345
346+ @ SuppressLint ({"SetTextI18n" , "DefaultLocale" })
355347 private void updatePassengerCountDisplay () {
356348
357- if (captureService != null && captureService .capturing ) {
349+ if (captureService != null && CaptureService .capturing ) {
358350
359351 TextView subieronPasajerosText = (TextView ) findViewById (R .id .subieronPasajerosText );
360352 TextView totalPasajerosText = (TextView ) findViewById (R .id .totalPasajerosText );
361353 TextView bajaronpasajerosText = (TextView ) findViewById (R .id .bajaronpasajerosText );
362354
363- if (captureService .currentCapture .boardCount > 0 ) {
364- subieronPasajerosText .setText ("+" + captureService .currentCapture .boardCount .toString ());
355+ if (CaptureService .currentCapture .boardCount > 0 ) {
356+ subieronPasajerosText .setText (String . format ( "+%s" , CaptureService .currentCapture .boardCount .toString () ));
365357 } else {
366358 subieronPasajerosText .setText ("0" );
367359 }
368360
369361 totalPasajerosText .setText (CaptureService .currentCapture .totalPassengerCount .toString ());
370362
371- if (captureService .currentCapture .alightCount > 0 ) {
372- bajaronpasajerosText .setText (String .format ("-%d" , captureService .currentCapture .alightCount ));
363+ if (CaptureService .currentCapture .alightCount > 0 ) {
364+ bajaronpasajerosText .setText (String .format ("-%d" , CaptureService .currentCapture .alightCount ));
373365 } else {
374366 bajaronpasajerosText .setText ("0" );
375367 }
0 commit comments