mirror of
https://github.com/zoriya/Opus.git
synced 2025-12-06 06:26:15 +00:00
Making queue drawer trully slide by overriding touch listeners.
This commit is contained in:
@@ -756,7 +756,7 @@ namespace MusicApp
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ShowSmallPlayer()
|
public void ShowSmallPlayer()
|
||||||
{
|
{
|
||||||
FindViewById<NestedScrollView>(Resource.Id.playerSheet).Visibility = ViewStates.Visible;
|
FindViewById<NestedScrollView>(Resource.Id.playerSheet).Visibility = ViewStates.Visible;
|
||||||
FindViewById(Resource.Id.playerContainer).Alpha = 0;
|
FindViewById(Resource.Id.playerContainer).Alpha = 0;
|
||||||
FindViewById(Resource.Id.smallPlayer).Alpha = 1;
|
FindViewById(Resource.Id.smallPlayer).Alpha = 1;
|
||||||
|
|||||||
@@ -340,6 +340,7 @@
|
|||||||
<Compile Include="Resources\Portable Class\DownloadQueue.cs" />
|
<Compile Include="Resources\Portable Class\DownloadQueue.cs" />
|
||||||
<Compile Include="Resources\Portable Class\DownloadQueueAdapter.cs" />
|
<Compile Include="Resources\Portable Class\DownloadQueueAdapter.cs" />
|
||||||
<Compile Include="Resources\Portable Class\FixedLinearLayoutManager.cs" />
|
<Compile Include="Resources\Portable Class\FixedLinearLayoutManager.cs" />
|
||||||
|
<Compile Include="Resources\Portable Class\FixedNestedScrollView.cs" />
|
||||||
<Compile Include="Resources\Portable Class\PlayerBehavior.cs" />
|
<Compile Include="Resources\Portable Class\PlayerBehavior.cs" />
|
||||||
<Compile Include="Resources\Portable Class\PlaylistHolder.cs" />
|
<Compile Include="Resources\Portable Class\PlaylistHolder.cs" />
|
||||||
<Compile Include="Resources\Portable Class\PlaylistLocationAdapter.cs" />
|
<Compile Include="Resources\Portable Class\PlaylistLocationAdapter.cs" />
|
||||||
|
|||||||
48
MusicApp/Resources/Portable Class/FixedNestedScrollView.cs
Normal file
48
MusicApp/Resources/Portable Class/FixedNestedScrollView.cs
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,6 @@ using Android.Runtime;
|
|||||||
using Android.Support.Design.Widget;
|
using Android.Support.Design.Widget;
|
||||||
using Android.Support.V4.Widget;
|
using Android.Support.V4.Widget;
|
||||||
using Android.Support.V7.Graphics;
|
using Android.Support.V7.Graphics;
|
||||||
using Android.Support.V7.Widget;
|
|
||||||
using Android.Text;
|
using Android.Text;
|
||||||
using Android.Text.Style;
|
using Android.Text.Style;
|
||||||
using Android.Util;
|
using Android.Util;
|
||||||
@@ -41,7 +40,7 @@ namespace MusicApp
|
|||||||
private ProgressBar spBar;
|
private ProgressBar spBar;
|
||||||
private TextView timer;
|
private TextView timer;
|
||||||
private ImageView view;
|
private ImageView view;
|
||||||
private DrawerLayout DrawerLayout;
|
public DrawerLayout DrawerLayout;
|
||||||
private bool prepared = false;
|
private bool prepared = false;
|
||||||
private readonly int[] timers = new int[] { 0, 2, 10, 30, 60, 120 };
|
private readonly int[] timers = new int[] { 0, 2, 10, 30, 60, 120 };
|
||||||
private int checkedItem = 0;
|
private int checkedItem = 0;
|
||||||
@@ -179,7 +178,7 @@ namespace MusicApp
|
|||||||
view.SetImageBitmap(drawable);
|
view.SetImageBitmap(drawable);
|
||||||
Palette.From(drawable).MaximumColorCount(28).Generate(this);
|
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%)
|
//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);
|
int width = (int)(view.Width * (float)drawable.Height / view.Height);
|
||||||
@@ -746,7 +745,10 @@ namespace MusicApp
|
|||||||
|
|
||||||
public void OnDrawerStateChanged(int newState)
|
public void OnDrawerStateChanged(int newState)
|
||||||
{
|
{
|
||||||
|
if (newState == DrawerLayout.StateDragging)
|
||||||
|
FixedNestedScrollView.PreventSlide = true;
|
||||||
|
else if(newState == DrawerLayout.StateSettling)
|
||||||
|
FixedNestedScrollView.PreventSlide = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,14 +40,6 @@ public class PlayerBehavior : BottomSheetBehavior
|
|||||||
return base.OnStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type);
|
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)
|
public override void OnNestedPreScroll(CoordinatorLayout coordinatorLayout, Java.Lang.Object child, View target, int dx, int dy, int[] consumed, int type)
|
||||||
{
|
{
|
||||||
if (PreventSlide)
|
if (PreventSlide)
|
||||||
@@ -63,4 +55,12 @@ public class PlayerBehavior : BottomSheetBehavior
|
|||||||
|
|
||||||
base.OnStopNestedScroll(coordinatorLayout, child, target, type);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true" >
|
android:fitsSystemWindows="true" >
|
||||||
<android.support.design.widget.CoordinatorLayout
|
<android.support.design.widget.CoordinatorLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -82,11 +82,11 @@
|
|||||||
app:itemTextColor="@color/color_tint"
|
app:itemTextColor="@color/color_tint"
|
||||||
app:menu="@menu/bottom_items" />
|
app:menu="@menu/bottom_items" />
|
||||||
|
|
||||||
<android.support.v4.widget.NestedScrollView
|
<MusicApp.FixedNestedScrollView
|
||||||
android:id="@+id/playerSheet"
|
android:id="@+id/playerSheet"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:elevation="6dp"
|
android:elevation="6dp"
|
||||||
android:translationY="-56dp"
|
android:translationY="-56dp"
|
||||||
@@ -94,8 +94,8 @@
|
|||||||
app:behavior_peekHeight="70dp"
|
app:behavior_peekHeight="70dp"
|
||||||
app:layout_behavior="MusicApp.PlayerBehavior" >
|
app:layout_behavior="MusicApp.PlayerBehavior" >
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/playersHolder"
|
android:id="@+id/playersHolder"
|
||||||
android:background="#2b5568"
|
android:background="#2b5568"
|
||||||
android:fitsSystemWindows="true" >
|
android:fitsSystemWindows="true" >
|
||||||
@@ -198,10 +198,10 @@
|
|||||||
<fragment
|
<fragment
|
||||||
android:name="MusicApp.Player"
|
android:name="MusicApp.Player"
|
||||||
android:id="@+id/playerContainer"
|
android:id="@+id/playerContainer"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent" />
|
android:layout_height="match_parent" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</android.support.v4.widget.NestedScrollView>
|
</MusicApp.FixedNestedScrollView>
|
||||||
|
|
||||||
<android.support.design.widget.CoordinatorLayout
|
<android.support.design.widget.CoordinatorLayout
|
||||||
android:id="@+id/snackBar"
|
android:id="@+id/snackBar"
|
||||||
|
|||||||
Reference in New Issue
Block a user