These are chat archives for dronekit/dronekit-android

19th
Jul 2016
pablomar13
@pablomar13
Jul 19 2016 01:36
@ne0fhyk would this be enough or the takeoff would stop?
// Take off
        boolean takeoff = false;
        do {
            if (!takeoff) {
                takeoff = true;
                ControlApi.getApi(drone).takeoff(altitude, new AbstractCommandListener() {
                    @Override
                    public void onSuccess() {
                        showToast(String.format(Locale.CANADA, "Taking off to %d meters...", altitude));
                    }

                    @Override
                    public void onError(int executionError) {
                        showToast("(!)Unable to take off.");
                        SetupButton.setEnabled(true);
                    }

                    @Override
                    public void onTimeout() {
                        showToast("(!)Unable to take off.");
                        SetupButton.setEnabled(true);
                    }
                });
            }
        } while (h_altitude <= altitude);
pablomar13
@pablomar13
Jul 19 2016 02:21
@ne0fhyk or is it prefered to do it like this?
Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                ControlApi.getApi(drone).takeoff(altitude, new AbstractCommandListener() {
                    @Override
                    public void onSuccess() {
                        showToast(String.format(Locale.CANADA, "Taking off to %d meters...", altitude));
                    }
                    @Override
                    public void onError(int executionError) {
                        showToast("(!)Unable to take off.");
                        SetupButton.setEnabled(true);
                    }
                    @Override
                    public void onTimeout() {
                        showToast("(!)Unable to take off.");
                        SetupButton.setEnabled(true);
                    }
                });
            }
        });
        thread.start();
@ne0fhyk if I ever meet you at some point, remember me to invite you to some beers.