private void SetUpDividersVisibility(View view, bool setForTop, bool setForBottom)
 {
     if (view == null)
         return;
     if (view is ScrollView)
     {
         ScrollView sv = (ScrollView)view;
         if (CanScrollViewScroll(sv))
         {
             AddScrollListener(sv, setForTop, setForBottom);
         }
         else
         {
             if (setForTop)
                 mDrawTopDivider = false;
             if (setForBottom)
                 mDrawBottomDivider = false;
         }
     }
     else if (view is AdapterView)
     {
         AdapterView sv = (AdapterView)view;
         if (CanAdapterViewScroll(sv))
         {
             AddScrollListener(sv, setForTop, setForBottom);
         }
         else
         {
             if (setForTop)
                 mDrawTopDivider = false;
             if (setForBottom)
                 mDrawBottomDivider = false;
         }
     }
     else if (view is WebView)
     {
         DelegatePreDrawListener listner = null;
         listner = new DelegatePreDrawListener
         {
             PreDraw = () =>
             {
                 if (view.MeasuredHeight != 0)
                 {
                     if (!CanWebViewScroll((WebView)view))
                     {
                         if (setForTop)
                             mDrawTopDivider = false;
                         if (setForBottom)
                             mDrawBottomDivider = false;
                     }
                     else
                     {
                         AddScrollListener((ViewGroup)view, setForTop, setForBottom);
                     }
                     view.ViewTreeObserver.RemoveOnPreDrawListener(listner);
                 }
                 return true;
             }
         };
         view.ViewTreeObserver.AddOnPreDrawListener(listner);
     }
     else if (view is RecyclerView)
     {
         bool canScroll = CanRecyclerViewScroll((RecyclerView)view);
         if (setForTop)
             mDrawTopDivider = canScroll;
         if (setForBottom)
             mDrawBottomDivider = canScroll;
     }
     else if (view is ViewGroup)
     {
         View topView = GetTopView((ViewGroup)view);
         SetUpDividersVisibility(topView, setForTop, setForBottom);
         View bottomView = GetBottomView((ViewGroup)view);
         if (bottomView != topView)
         {
             SetUpDividersVisibility(bottomView, false, true);
         }
     }
 }
Exemple #2
0
 private void SetUpDividersVisibility(View view, bool setForTop, bool setForBottom)
 {
     if (view == null)
     {
         return;
     }
     if (view is ScrollView)
     {
         ScrollView sv = (ScrollView)view;
         if (CanScrollViewScroll(sv))
         {
             AddScrollListener(sv, setForTop, setForBottom);
         }
         else
         {
             if (setForTop)
             {
                 mDrawTopDivider = false;
             }
             if (setForBottom)
             {
                 mDrawBottomDivider = false;
             }
         }
     }
     else if (view is AdapterView)
     {
         AdapterView sv = (AdapterView)view;
         if (CanAdapterViewScroll(sv))
         {
             AddScrollListener(sv, setForTop, setForBottom);
         }
         else
         {
             if (setForTop)
             {
                 mDrawTopDivider = false;
             }
             if (setForBottom)
             {
                 mDrawBottomDivider = false;
             }
         }
     }
     else if (view is WebView)
     {
         DelegatePreDrawListener listner = null;
         listner = new DelegatePreDrawListener
         {
             PreDraw = () =>
             {
                 if (view.MeasuredHeight != 0)
                 {
                     if (!CanWebViewScroll((WebView)view))
                     {
                         if (setForTop)
                         {
                             mDrawTopDivider = false;
                         }
                         if (setForBottom)
                         {
                             mDrawBottomDivider = false;
                         }
                     }
                     else
                     {
                         AddScrollListener((ViewGroup)view, setForTop, setForBottom);
                     }
                     view.ViewTreeObserver.RemoveOnPreDrawListener(listner);
                 }
                 return(true);
             }
         };
         view.ViewTreeObserver.AddOnPreDrawListener(listner);
     }
     else if (view is RecyclerView)
     {
         bool canScroll = CanRecyclerViewScroll((RecyclerView)view);
         if (setForTop)
         {
             mDrawTopDivider = canScroll;
         }
         if (setForBottom)
         {
             mDrawBottomDivider = canScroll;
         }
     }
     else if (view is ViewGroup)
     {
         View topView = GetTopView((ViewGroup)view);
         SetUpDividersVisibility(topView, setForTop, setForBottom);
         View bottomView = GetBottomView((ViewGroup)view);
         if (bottomView != topView)
         {
             SetUpDividersVisibility(bottomView, false, true);
         }
     }
 }