Progressidialog exiting (Ismiss) before executing the previous code

Asked

Viewed 37 times

0

Boa Tarde Personal!

I made a request screen, where basically there is a looping fed by a data vector of WS, where it goes including the "lines" in the linearlayout. During this process, I display a Progressidialog and it is finalized after the inclusion of the lines. The problem is that the Oader is finished and the lines all appear at once Follow the code excerpt:

        Vector<SoapObject> soAssinaturas = (Vector<SoapObject>) sobj.getProperty("assinaturas");
    for (int i = 0; i < soAssinaturas.size(); i++) {


        //INSTANCIA OS TEXTVIEW
        final String txtPedido =signBox.getDocumento();

        final View assinaturasb = getLayoutInflater().inflate(R.layout.assinaturabox, null);
        final TextView orcamento = assinaturasb.findViewById(R.id.orcamento);
        final TextView sign1 = assinaturasb.findViewById(R.id.sign1);
        final TextView sign2 = assinaturasb.findViewById(R.id.sign2);
        final TextView empresa = assinaturasb.findViewById(R.id.empresa);
        final TextView valor = assinaturasb.findViewById(R.id.valor);
        final TextView data = assinaturasb.findViewById(R.id.data);
        final TextView pedido = assinaturasb.findViewById(R.id.pedido);
        final TextView tipoDoc = assinaturasb.findViewById(R.id.tipoDoc);
        final CheckBox ckb = assinaturasb.findViewById(R.id.checkBox);

        Date date = new SimpleDateFormat("yyyy-MM-dd",Locale.US).parse(signBox.getData_entrega().subSequence(0,10).toString());
        String form = new SimpleDateFormat("dd/MM/yyyy",Locale.US).format(date);

        String lang = "";
        String coun= "";
        switch(signBox.getMoeda().trim()){
            case "R$":lang="pt";coun="BR";break;
            case "JPY":lang="ja";coun="JP";break;
            case "EUR":lang="es";coun="ES";break;
            default:lang="pt";coun="BR";break;
        }
        //MOEDA
        Double d = Double.parseDouble(signBox.getValor());
        Locale ptBr = new Locale(lang, coun);
        String valorString = NumberFormat.getCurrencyInstance(ptBr).format(d);
        valor.setText(valorString);

        //PEGA APENAS A PRIMEIRA LINHA DO PROJETO PARA EXIBIR
        String[] projeto = signBox.getTexto().split("\r\n|\r|\n", 2);
        empresa.setText(projeto[0].toUpperCase().replace("CUSTOMER:","").trim());//PROJETO (campo texto)
        pedido.setText(signBox.getPedido());
        tipoDoc.setText(signBox.getTipo_documento());
        data.setText(form.toString());
        orcamento.setText(signBox.getOrcamento());

        ckb.setEnabled(false);
        sign2.setText("AGUARDANDO");
        sign1.setText("AGUARDANDO");






        containerAssinaturas.addView(assinaturasb,0);



    }
    load.dismiss();
  • For that purpose, it would be interesting for you to use a View list, because depending on the size of your data, you can take a beautiful OutOfMemory. Use the RecyclerView which is more appropriate.

  • @Ivansilva Thanks for the suggestion , I will implement in a Recyclerview. But will solve the problem?

  • In short, if you want a line to appear at any time, you will need to create an animation for this or you can use a third party lib for animations on RecyclerView. See what you can get, and any mistake just open a new question.

  • @Ivansilva regarding Progressdialog leaving before loading the items in the UI, it would be some thread problem ?

  • Post the code you already have. As soon as I get I look

  • @Ivansilva I implemented recyclerview at your suggestion and solved all the problems. Thank you!! D

  • You’re welcome. I’m glad I could help!

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.