Open anonym24 opened 6 years ago
it only works with smooth parameter set to true, but it could result in bad user exepirence if someone changes position form 3 to 125, so in this case I need to change current fragment without any smooth and transformation, fastly, it should be done only if we change from 2 to 3 or from 3 to 2 (next, previous fragments), in this case transformation is ok
solved this by setting temporarily page transformer to null before setCurrentItem for big distances between position and then again set needed page transformer:
try {
mPager.setPageTransformer(true, new TransformerItem(ZoomOutSlideTransformer.class).clazz.newInstance());
} catch (Exception e) {
throw new RuntimeException(e);
}
// test bug
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
mPager.setPageTransformer(true, null);
mPager.setCurrentItem(4, false);
try {
mPager.setPageTransformer(true, new TransformerItem(ZoomOutSlideTransformer.class).clazz.newInstance());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}, 3000);
How to test bug: add next code in onCreate, run app, choose some transformation and wait for 6 seconds, it will change something but slider won't appear or animation would be frozen (paused at its start)
for example with ZoomOutSliderTransformer slider won't be fully 100% taking all space of layout (you can see white paddings or margin at right and bottom)