an image showing an example I use this code as a custom listview adapter

View vi = convertView;
    if (vi == null)
    {
        if(u.get(position).getLivreur().equalsIgnoreCase("NB"))
            vi = inflater.inflate(R.layout.row_livraison_non_assigne, null);
        else
            vi = inflater.inflate(R.layout.row_livraison, null);
    }

    TextView id_facture = (TextView) vi.findViewById(R.id.id_facture);
    TextView client = (TextView) vi.findViewById(R.id.client);
    TextView date = (TextView) vi.findViewById(R.id.date);
    TextView livreur = (TextView) vi.findViewById(R.id.livreur);
    TextView etat = (TextView) vi.findViewById(R.id.etat);
    id_facture.setText("BL / Facture N : "+ u.get(position).getFacture_id());
    client.setText("Client : "+u.get(position).getClient());
    date.setText("Date : "+u.get(position).getDate_facturation());
    livreur.setText("Livreur :  "+ u.get(position).getLivreur_name());
    etat.setText(u.get(position).getEtat());
    String et = etat.getText().toString();
    Toast.makeText(context, position+" "+et, Toast.LENGTH_SHORT).show();
    if(et.equalsIgnoreCase("Programmé"))
    {
        etat.setTextColor(Color.RED);
    }
    else
    if(et.equalsIgnoreCase("Livré"))
    {
        etat.setTextColor(Color.GREEN);

    }
    else
    if(et.equalsIgnoreCase("En cours")){

        ObjectAnimator animator =  ObjectAnimator.ofInt(etat,"textColor",Color.GREEN,Color.RED);
        animator.setDuration(500);
        animator.setEvaluator(new ArgbEvaluator());
        animator.setRepeatMode(ValueAnimator.REVERSE);
        animator.setRepeatCount(ValueAnimator.INFINITE);
        animator.start();
    }

return vi;

I use this code to fill the list passed to the adapter :

@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
    for(DataSnapshot snap : snapshot.getChildren()){
        if(snap.child("date_livraison").getValue(String.class).toString().equalsIgnoreCase(d)){
            livraison liv = new livraison();
            liv.setId(snap.child("id").getValue(String.class).toString());
            liv.setClient(snap.child("client").getValue(String.class).toString());
            liv.setAddr(snap.child("addr").getValue(String.class).toString());
            liv.setLivreur(snap.child("livreur").getValue(String.class).toString());
            liv.setFacture_id(snap.child("facture_id").getValue(String.class).toString());
            liv.setLivreur_name(snap.child("livreur_name").getValue(String.class).toString());
            liv.setDate_facturation(snap.child("date_facturation").getValue(String.class).toString());
            liv.setEtat(snap.child("etat").getValue(String.class).toString());
            livraisons.add(liv);
            adapter.notifyDataSetChanged();
        }
    }
}

I need that the last textview of every row to blink if its value is equal to "En cours" , I see that other rows are blinking despite of having a different value.

0

There are 0 best solutions below