I have a PageTransfomer applied to a ViewPager, it works great but I want to launch the page\'s transformation as soon as I set the PageTransformer to the ViewPager. I alrea
Based on Oleg's answer is used the code below for my app.
My addition is to check the returned result of beginFakeDrag()
inside _invalidatePageTransformer
.
I call sendInvalidatePageTransformer()
from inside
onConfigurationChanged()
when the orientation changedinside the LoaderCallback
-methods in my Fragment
private Handler handler = new Handler()
{
public void handleMessage(Message msg)
{
switch(msg.what)
{
case 0:
_invalidatePageTransformer();
break;
}
}
};
private void _invalidatePageTransformer()
{
//no need to invalidate if we have no adapter or no items
if (this.getAdapter() != null && this.getAdapter().getCount() > 0)
{
//import check here, only fakeDrag if "beginFakeDrag()" returns true
if (this.beginFakeDrag())
{
this.fakeDragBy(0f);
this.endFakeDrag();
}
}
}
public void sendInvalidatePageTransformer()
{
this.handler.sendEmptyMessage(0);
}
EDIT: Note: This code is located inside a custom ViewPager-subclass