title: View animated using CoordinatorLayout and AppBarLayout getting crazy (sometimes)
body: <p>This thing is getting me nuts.</p>
  
  <p>I have been able to get this behavior (exactly what I want): <a href="https://i.imgur.com/PGhL22k.gif" rel="nofollow noreferrer">http://i.imgur.com/PGhL22k.gif</a></p>
  
  <p>And this is the behavior is has when I scroll down very fast: <a href="https://i.imgur.com/kk7icAc.gif" rel="nofollow noreferrer">http://i.imgur.com/kk7icAc.gif</a> and <a href="https://i.imgur.com/YNPNiA6.gif" rel="nofollow noreferrer">http://i.imgur.com/YNPNiA6.gif</a></p>
  
  <p>I am sorry but the GIFs are larger than 2Mb and I cannot upload them here...</p>
  
  <p>I want the pagination bar at the bottom to hide the same amount the toolbar does. When scrolling slowly it goes very well, but when fast scrolling it has a really strange behavior as you can see at the GIFs provided above.</p>
  
  <p>This is the layout XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;android.support.design.widget.CoordinatorLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:kiosk="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
          &lt;include
              layout="@layout/android_toolbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              kiosk:layout_scrollFlags="scroll|enterAlways"/&gt;
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+id/vpPager"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          kiosk:layout_behavior="@string/appbar_scrolling_view_behavior"/&gt;
  
      &lt;include
          layout="@layout/paginator_layout"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="bottom"
          kiosk:layout_behavior="carl.fri.fer.views.KioskPaginator.KioskPaginatorScrollBehaviour"/&gt;
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>The "android_toolbar" include is as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;carl.fri.fer.views.KioskToolbar
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@color/primaryColor"
      android:minHeight="?attr/actionBarSize"/&gt;
  </code></pre>
  
  <p>And the "paginator_layout" is the following:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;carl.fri.fer.views.KioskPaginator.KioskPaginator
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/kpPaginator"
      android:layout_width="match_parent"
      android:layout_height="40dp"
      android:layout_alignParentBottom="true"
      android:animateLayoutChanges="true"
      android:background="@color/primaryColor"
      android:clickable="true"
      android:orientation="horizontal"&gt;
  
      &lt;TextView
          android:id="@+id/tvCurrentPage"
          android:layout_width="50dp"
          android:layout_height="wrap_content"
          android:layout_gravity="center_vertical"
          android:gravity="center"
          android:padding="10dp"
          android:textColor="@color/color_pure_black"
          android:textSize="17sp"/&gt;
  
      &lt;LinearLayout
          android:id="@+id/llMoreOptions"
          android:layout_width="0dp"
          android:layout_height="40dp"
          android:layout_weight="1"
          android:background="@android:color/transparent"
          android:gravity="center_vertical"
          android:orientation="horizontal"/&gt;
  
      &lt;TextView
          android:id="@+id/tvTotalPages"
          android:layout_width="50dp"
          android:layout_height="wrap_content"
          android:layout_gravity="center_vertical"
          android:gravity="center"
          android:padding="10dp"
          android:textColor="@color/color_pure_black"
          android:textSize="17sp"/&gt;
  &lt;/carl.fri.fer.views.KioskPaginator.KioskPaginator&gt;
  </code></pre>
  
  <p>And the ScrollBehavior is as follows:</p>
  
  <pre><code>public class KioskPaginatorScrollBehaviour extends AppBarLayout.ScrollingViewBehavior {
  
      public KioskPaginatorScrollBehaviour(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      @Override
      public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
          return dependency instanceof AppBarLayout;
      }
  
      @Override
      public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
          float depY = - dependency.getHeight();
          depY -= dependency.getY();
  
          Utils.log("dependency", "" + depY);
  
          child.setTranslationY(depY);
  
          return true;
      }
  }
  </code></pre>
  
  <p>Inside of every page of the <strong>ViewPager</strong>, there is a Fragment. And the content of this Fragment is a <strong>RecyclerView</strong> with dynamic content. All the content from the <strong>RecyclerView</strong> is loaded from database and images are loaded at runtime.</p>
  
  <p>Can someone please tell me why is this strange behavior happening? How can I fix it?</p>
  
  <p>Thank you in advance...</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>I just spotted the cause of the weird behavior! The ViewPager loads the current page and the adjoining ones. The content of the RecyclerView loads from the Internet and as soon as it is loaded, it goes into the RecyclerView. The ViewPager first loads the current page and then the adjoining ones. If I have scrolled down the current page RecyclerView (Toolbar is hidden) when the 2nd RecyclerView just loads and shows the content, it resets the current page AppBarLayout behavior, so it resets my custom view behavior... How can I fix that? I want to avoid not loading adjoining views..</p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>Ok, it happens when loading adjoining pages of <code>ViewPager</code> and <strong>also</strong> when loading from the Internet images inside the <code>RecyclerView</code>... this is crazy.</p>