Ir para conteúdo
Fórum Script Brasil

maalonbarbosa

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Posts postados por maalonbarbosa

  1. 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();
        }
    }
×
×
  • Criar Novo...