diff --git a/MusicApp/MainActivity.cs b/MusicApp/MainActivity.cs index 79ef8b0..54a65a3 100644 --- a/MusicApp/MainActivity.cs +++ b/MusicApp/MainActivity.cs @@ -756,7 +756,7 @@ namespace MusicApp } public void ShowSmallPlayer() - { + { FindViewById(Resource.Id.playerSheet).Visibility = ViewStates.Visible; FindViewById(Resource.Id.playerContainer).Alpha = 0; FindViewById(Resource.Id.smallPlayer).Alpha = 1; diff --git a/MusicApp/MusicApp.csproj b/MusicApp/MusicApp.csproj index f7d53a9..0c62830 100644 --- a/MusicApp/MusicApp.csproj +++ b/MusicApp/MusicApp.csproj @@ -340,6 +340,7 @@ + diff --git a/MusicApp/Resources/Portable Class/FixedNestedScrollView.cs b/MusicApp/Resources/Portable Class/FixedNestedScrollView.cs new file mode 100644 index 0000000..5ae40c8 --- /dev/null +++ b/MusicApp/Resources/Portable Class/FixedNestedScrollView.cs @@ -0,0 +1,48 @@ +using Android.Content; +using Android.Runtime; +using Android.Support.V4.Widget; +using Android.Util; +using Android.Views; +using System; + +[Register("MusicApp/FixedNestedScrollView")] +public class FixedNestedScrollView : NestedScrollView +{ + public static bool PreventSlide = false; + + public FixedNestedScrollView(Context context) : base(context) { } + public FixedNestedScrollView(Context context, IAttributeSet attrs) : base(context, attrs) { } + public FixedNestedScrollView(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr) { } + protected FixedNestedScrollView(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { } + + ////Overriden because DrawerLayout need to be measured with MeasureSpecMode EXACLTY + //protected override void MeasureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) + //{ + // //if (child is DrawerLayout) + // //{ + // MarginLayoutParams lp = (MarginLayoutParams)child.LayoutParameters; + // int childWidthMeasureSpec = GetChildMeasureSpec(parentWidthMeasureSpec, PaddingLeft + PaddingRight + lp.LeftMargin + lp.RightMargin + widthUsed, lp.Width); + // int childHeightMeasureSpec = MeasureSpec.MakeMeasureSpec(parentWidthMeasureSpec, MeasureSpecMode.Exactly); + // child.Measure(childWidthMeasureSpec, childHeightMeasureSpec); + // Console.WriteLine("&Height: " + child.MeasuredHeight + " Child: " + child); + // //} + // //else + // // base.MeasureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, parentWidthMeasureSpec, heightUsed); + //} + + public override bool OnInterceptTouchEvent(MotionEvent ev) + { + if(PreventSlide) + return false; + + return base.OnInterceptTouchEvent(ev); + } + + public override bool OnTouchEvent(MotionEvent e) + { + if(PreventSlide) + return false; + + return base.OnTouchEvent(e); + } +} diff --git a/MusicApp/Resources/Portable Class/Player.cs b/MusicApp/Resources/Portable Class/Player.cs index 408bc59..f62952c 100644 --- a/MusicApp/Resources/Portable Class/Player.cs +++ b/MusicApp/Resources/Portable Class/Player.cs @@ -11,7 +11,6 @@ using Android.Runtime; using Android.Support.Design.Widget; using Android.Support.V4.Widget; using Android.Support.V7.Graphics; -using Android.Support.V7.Widget; using Android.Text; using Android.Text.Style; using Android.Util; @@ -41,7 +40,7 @@ namespace MusicApp private ProgressBar spBar; private TextView timer; private ImageView view; - private DrawerLayout DrawerLayout; + public DrawerLayout DrawerLayout; private bool prepared = false; private readonly int[] timers = new int[] { 0, 2, 10, 30, 60, 120 }; private int checkedItem = 0; @@ -179,7 +178,7 @@ namespace MusicApp view.SetImageBitmap(drawable); Palette.From(drawable).MaximumColorCount(28).Generate(this); - if(view.Width > 0) + if (view.Width > 0) { //The width of the view in pixel (we'll multiply this by 0.75f because the drawer has a width of 75%) int width = (int)(view.Width * (float)drawable.Height / view.Height); @@ -746,7 +745,10 @@ namespace MusicApp public void OnDrawerStateChanged(int newState) { - + if (newState == DrawerLayout.StateDragging) + FixedNestedScrollView.PreventSlide = true; + else if(newState == DrawerLayout.StateSettling) + FixedNestedScrollView.PreventSlide = false; } } } \ No newline at end of file diff --git a/MusicApp/Resources/Portable Class/PlayerBehavior.cs b/MusicApp/Resources/Portable Class/PlayerBehavior.cs index 611a19e..9e7a32a 100644 --- a/MusicApp/Resources/Portable Class/PlayerBehavior.cs +++ b/MusicApp/Resources/Portable Class/PlayerBehavior.cs @@ -40,14 +40,6 @@ public class PlayerBehavior : BottomSheetBehavior return base.OnStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type); } - public override bool OnNestedPreFling(CoordinatorLayout coordinatorLayout, Java.Lang.Object child, View target, float velocityX, float velocityY) - { - if (PreventSlide) - return false; - - return base.OnNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY); - } - public override void OnNestedPreScroll(CoordinatorLayout coordinatorLayout, Java.Lang.Object child, View target, int dx, int dy, int[] consumed, int type) { if (PreventSlide) @@ -63,4 +55,12 @@ public class PlayerBehavior : BottomSheetBehavior base.OnStopNestedScroll(coordinatorLayout, child, target, type); } + + public override bool OnNestedPreFling(CoordinatorLayout coordinatorLayout, Java.Lang.Object child, View target, float velocityX, float velocityY) + { + if (PreventSlide) + return false; + + return base.OnNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY); + } } \ No newline at end of file diff --git a/MusicApp/Resources/layout/Main.xml b/MusicApp/Resources/layout/Main.xml index ea1d001..3fdf468 100644 --- a/MusicApp/Resources/layout/Main.xml +++ b/MusicApp/Resources/layout/Main.xml @@ -4,7 +4,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:fitsSystemWindows="true" > - @@ -198,10 +198,10 @@ + android:layout_width="match_parent" + android:layout_height="match_parent" /> - +