Browse Source

Error Handling

master
Vanessa Bock 1 year ago
parent
commit
ce6ca27490

+ 5
- 14
MobileApp/app/src/main/java/com/example/lfrmobileapp/ui/home/HomeFragment.java View File

@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
boolean send = false;
if (System.currentTimeMillis() - lastOnMoveCall > 250){
send = true;
lastOnMoveCall = System.currentTimeMillis();
}
if (send && mainActivity.connected) {
if (mainActivity.connected) {
if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getAction() == MotionEvent.ACTION_UP) {
binding.rotateLeft.performClick(); binding.rotateLeft.performClick();
mainActivity.sendTelegram(com.telegram(new int[]{0, 0, 0, 0}, 0)); mainActivity.sendTelegram(com.telegram(new int[]{0, 0, 0, 0}, 0));
return true; return true;
} else { } else {
mainActivity.sendTelegram(com.telegram(new int[]{-1, 1, -1, 1}, 100));
mainActivity.sendTelegram(com.telegram(new int[]{-1, 1, -1, 1}, 50));
} }
} }
return false; return false;
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
boolean send = false;
if (System.currentTimeMillis() - lastOnMoveCall > 50){
send = true;
lastOnMoveCall = System.currentTimeMillis();
}
if (send && mainActivity.connected){
if (mainActivity.connected){
if(event.getAction() == MotionEvent.ACTION_UP){ if(event.getAction() == MotionEvent.ACTION_UP){
binding.rotateRight.performClick(); binding.rotateRight.performClick();
mainActivity.sendTelegram(com.telegram(new int[]{0, 0, 0, 0}, 0)); mainActivity.sendTelegram(com.telegram(new int[]{0, 0, 0, 0}, 0));
return true; return true;
}else{ }else{
mainActivity.sendTelegram(com.telegram(new int[]{1, -1, 1, -1}, 100));
mainActivity.sendTelegram(com.telegram(new int[]{1, -1, 1, -1}, 50));
} }
} }
return false; return false;
else{ else{
joystick.setBackgroundResource(R.mipmap.blank); joystick.setBackgroundResource(R.mipmap.blank);
telegram = com.telegram(new int[]{0, 0, 0, 0}, strength); telegram = com.telegram(new int[]{0, 0, 0, 0}, strength);
send=true;
} }
if (send && mainActivity.connected) if (send && mainActivity.connected)
{ {

Loading…
Cancel
Save