Jump to content
Fórum Script Brasil
  • 0

Botão accept


Question

Pessoal sou novato em java e estou editando um app, nesse app quando chega uma solicitação e eu clico no botão de aceitar ele invés de aceitar acaba rejeitando... vou deixar o codigo abaixo se alguém conseguir descobrir algum erro nele... ficarei muito grato, abraços!

 

    @OnClick({R.id.btnReject, R.id.btnAccept})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btnReject:
                if (DATUM != null) {
                    Request_ datum = DATUM;
                    showLoading();
                    presenter.cancel(datum.getId());
                    time_to_left = 60;
                }
                break;
            case R.id.btnAccept:
                if (DATUM != null) {
                    Request_ datum = DATUM;
                    showLoading();
                    presenter.accept(datum.getId());
                    time_to_left = 60;
                }
                break;
        }
    }

    @Override
    public void onSuccessAccept(Object message) {
        countDownTimer.cancel();
        hideLoading();

        if(message.toString().equals("{error=Tempo esgotado!}")){
            Toasty.error(getContext(), "Tempo esgotado. Chamada finalizada!", Toast.LENGTH_LONG).show();
        }else if(message.toString().equals("{error=Viagem aceita por outro motorista!}")){
            Toasty.error(getContext(), "Viagem aceita por outro motorista!", Toast.LENGTH_LONG).show();
        }else{
            Toasty.success(getContext(), getString(R.string.ride_accepted), Toast.LENGTH_LONG).show();
        }

        getContext().sendBroadcast(new Intent("INTENT_FILTER"));
        try {
            getActivity().getSupportFragmentManager().beginTransaction().remove(IncomingRequestFragment.this).commitAllowingStateLoss();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onSuccessCancel(Object object) {
        countDownTimer.cancel();
        hideLoading();
        getActivity().getSupportFragmentManager().beginTransaction().remove(IncomingRequestFragment.this).commitAllowingStateLoss();
        Toasty.success(context, getString(R.string.ride_cancelled), Toast.LENGTH_SHORT, true).show();
        context.sendBroadcast(new Intent("INTENT_FILTER"));
    }

    @Override
    public void onError(Throwable e) {
        try {
            hideLoading();
            if (mPlayer.isPlaying()) mPlayer.stop();
            if (e != null)
                onErrorBase(e);
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }

    @Override
    public void onStart() {
        super.onStart();
        if (!mPlayer.isPlaying())
            mPlayer.start();
    }

    @Override
    public void onPause() {
        super.onPause();
        if (mPlayer.isPlaying())
            mPlayer.stop();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPlayer.isPlaying())
            mPlayer.stop();
    }
}
Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      149300
    • Total Posts
      645709
×
×
  • Create New...