Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

265
Vistas
Rama duplicada en 'interruptor'. Cómo evitar la advertencia

Tengo un código para mi MotionEvent en la aplicación de Android. Tiene la condición cuando suelto el último dedo (ACTION_UP), y la condición cuando suelto el dedo, pero cualquier otro dedo sigue en la pantalla (ACTION_POINTER_UP). Entonces, estas son dos condiciones diferentes y necesito ejecutar el código en ambos casos. Pero el compilador me dice que tengo exactamente el mismo código y ofrece fusionar estas dos secciones en una.

¿Cómo puedo evitar esta advertencia?

Hay un código:

 switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: // first touch // some code for a touch break; case MotionEvent.ACTION_POINTER_DOWN: // second and more touch // some code for a second touch break; case MotionEvent.ACTION_MOVE: // code when the finger moves break; case MotionEvent.ACTION_UP: // left side if (event.getPointerId(event.getActionIndex()) == fingerOnALeftSide) { Log.d("tag", "Now we release the finger that was on a left side"); leftFingerInTouch = false; } // right side if (event.getPointerId(event.getActionIndex()) == fingerOnARightSide) { Log.d("tag", "Now we release the finger that was on a right side"); myBluetooth.send(COMMAND_STOP_ENGINE); } break; case MotionEvent.ACTION_POINTER_UP: // left side if (event.getPointerId(event.getActionIndex()) == fingerOnALeftSide) { Log.d("tag", "Now we release the finger that was on a left side"); leftFingerInTouch = false; } // right side if (event.getPointerId(event.getActionIndex()) == fingerOnARightSide) { Log.d("tag", "Now we release the finger that was on a right side"); myBluetooth.send(COMMAND_STOP_ENGINE); } break; default: break; }
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Se parece a esto y funciona.

 case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: // left side if (event.getPointerId(event.getActionIndex()) == fingerOnALeftSide) { Log.d("tag", "Now we release the finger that was on a left side"); leftFingerInTouch = false; } // right side if (event.getPointerId(event.getActionIndex()) == fingerOnARightSide) { Log.d("tag", "Now we release the finger that was on a right side"); myBluetooth.send(COMMAND_STOP_ENGINE); } break; default: break;
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda