Frames skipped when using Constraintset

0

I have a recyclerview, where each element is a cardview that contains a Constraintlayout for the disposition of the items.

Every time I click on the card view the idea is that, if you have the original constraints, apply another set of constrains (destiny constraints) and when you have the constraints destiny, that apply the original

When I click on the cardview, I change the constraints with a ConstraintSet. This logic is found in the onClickListener of the cardview.

My problem is that the interface freezes and skips a few frames before applying the corresponding constraintset. Once the animation to apply the constraints starts, no type of frame is noticed, so there is something between the moment I click and the constraints that the interface freezes apply.

This happens to me on a device with android 5.1.1, but on a device with android 7 or 8 it does not happen. I suspect that it is the power of the processor that does not skip frames on those devices. Add in the manifest to make use of hardware acceleration but it did not work.

Here I leave part of my code

ViewHolder

private ConstraintSet original, destino;

ViewHolder(View itemView){
    original = new ConstraintSet();
    original.clone(mContenedor); //constraint dentro del cardview
    destino = new ConstraintSet();
    destino.clone(mContenedor.getContext(), R.layout.item_alt); //constraint que voy a copiar
}


mCard.setOnClickListener(view -> {
    TransitionManager.beginDelayedTransition(mListaRecyclerView); //para que se produzca una animacion al momento de aplicar los constrains

    if(!mOriginal){  //flag para controlar si tiene los constraints originales o no
            original.applyTo(mContenedor);
        } else{
            destino.applyTo(mContenedor);
        }
        mOriginal=!mOriginal;
    }
});
    
asked by YorchSircam 08.03.2018 в 02:59
source

0 answers