mirror of
https://github.com/zoriya/Opus.git
synced 2025-12-06 06:26:15 +00:00
Reworking viewpager and removing quickplay fab.
This commit is contained in:
@@ -11,18 +11,15 @@ using Android.Gms.Cast.Framework.Media;
|
||||
using Android.Gms.Common;
|
||||
using Android.Gms.Common.Apis;
|
||||
using Android.Graphics;
|
||||
using Android.Graphics.Drawables;
|
||||
using Android.Net;
|
||||
using Android.OS;
|
||||
using Android.Provider;
|
||||
using Android.Runtime;
|
||||
using Android.Support.Design.Widget;
|
||||
using Android.Support.V4.App;
|
||||
using Android.Support.V4.View;
|
||||
using Android.Support.V4.Widget;
|
||||
using Android.Support.V7.App;
|
||||
using Android.Support.V7.Preferences;
|
||||
using Android.Support.V7.Widget;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
@@ -41,9 +38,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using TagLib;
|
||||
using YoutubeExplode;
|
||||
using YoutubeExplode.Models;
|
||||
using CursorLoader = Android.Support.V4.Content.CursorLoader;
|
||||
using ICallback = Square.OkHttp.ICallback;
|
||||
using Playlist = MusicApp.Resources.Portable_Class.Playlist;
|
||||
@@ -57,7 +52,7 @@ namespace MusicApp
|
||||
[IntentFilter(new[] {Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataHost = "www.youtube.com", DataMimeType = "text/*")]
|
||||
[IntentFilter(new[] {Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataHost = "m.youtube.com", DataMimeType = "text/plain")]
|
||||
[IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault }, DataMimeTypes = new[] { "audio/*", "application/ogg", "application/x-ogg", "application/itunes" })]
|
||||
public class MainActivity : AppCompatActivity, ViewPager.IOnPageChangeListener, GoogleApiClient.IOnConnectionFailedListener, ICallback, IResultCallback, IMenuItemOnActionExpandListener, View.IOnFocusChangeListener, ISessionManagerListener
|
||||
public class MainActivity : AppCompatActivity, GoogleApiClient.IOnConnectionFailedListener, ICallback, IResultCallback, IMenuItemOnActionExpandListener, View.IOnFocusChangeListener, ISessionManagerListener
|
||||
{
|
||||
public static MainActivity instance;
|
||||
public new static int Theme = 1;
|
||||
@@ -66,7 +61,6 @@ namespace MusicApp
|
||||
public Android.Support.V7.Widget.Toolbar ToolBar;
|
||||
public bool NoToolbarMenu = false;
|
||||
public IMenu menu;
|
||||
public ViewPager viewPager;
|
||||
public SwipeRefreshLayout contentRefresh;
|
||||
public bool usePager;
|
||||
public bool HomeDetails = false;
|
||||
@@ -74,12 +68,6 @@ namespace MusicApp
|
||||
public bool StateSaved = false;
|
||||
|
||||
public bool prepared = false;
|
||||
private bool searchDisplayed;
|
||||
private string tab;
|
||||
private bool QuickPlayOpenned = false;
|
||||
private object sender;
|
||||
private Drawable playToCross;
|
||||
private Drawable crossToPlay;
|
||||
public BottomSheetBehavior SheetBehavior;
|
||||
|
||||
private const int RequestCode = 8539;
|
||||
@@ -118,10 +106,8 @@ namespace MusicApp
|
||||
|
||||
contentRefresh = FindViewById<SwipeRefreshLayout>(Resource.Id.contentRefresh);
|
||||
|
||||
playToCross = GetDrawable(Resource.Drawable.PlayToCross);
|
||||
crossToPlay = GetDrawable(Resource.Drawable.CrossToPlay);
|
||||
|
||||
Navigate(Resource.Id.musicLayout);
|
||||
if(savedInstanceState == null)
|
||||
Navigate(Resource.Id.musicLayout);
|
||||
|
||||
SheetBehavior = BottomSheetBehavior.From(FindViewById(Resource.Id.playerSheet));
|
||||
SheetBehavior.State = BottomSheetBehavior.StateCollapsed;
|
||||
@@ -382,14 +368,6 @@ namespace MusicApp
|
||||
}
|
||||
}
|
||||
|
||||
public void Scroll(object sender, View.ScrollChangeEventArgs e)
|
||||
{
|
||||
if(Home.instance != null)
|
||||
{
|
||||
contentRefresh.Enabled = ((LinearLayoutManager)Home.instance.ListView.GetLayoutManager()).FindFirstCompletelyVisibleItemPosition() == 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnCreateOptionsMenu(IMenu menu)
|
||||
{
|
||||
if (NoToolbarMenu)
|
||||
@@ -470,10 +448,7 @@ namespace MusicApp
|
||||
else if (YoutubeEngine.instances != null && !PlaylistTracks.openned)
|
||||
{
|
||||
YoutubeEngine.instances = null;
|
||||
HideTabs();
|
||||
SupportFragmentManager.PopBackStack();
|
||||
if (Home.instance != null)
|
||||
ShowQuickPlay();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -521,11 +496,6 @@ namespace MusicApp
|
||||
|
||||
public void HideSearch()
|
||||
{
|
||||
if (!searchDisplayed)
|
||||
return;
|
||||
|
||||
searchDisplayed = false;
|
||||
|
||||
if (menu == null)
|
||||
return;
|
||||
|
||||
@@ -533,41 +503,23 @@ namespace MusicApp
|
||||
var searchItem = item.ActionView;
|
||||
var searchView = searchItem.JavaCast<SearchView>();
|
||||
|
||||
searchView.SetQuery("", false);
|
||||
searchView.ClearFocus();
|
||||
searchView.OnActionViewCollapsed();
|
||||
|
||||
item.SetVisible(false);
|
||||
item.CollapseActionView();
|
||||
|
||||
SupportActionBar.SetHomeButtonEnabled(false);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(false);
|
||||
SupportActionBar.Title = "MusicApp";
|
||||
}
|
||||
|
||||
public void DisplaySearch(int id = 0)
|
||||
public void DisplaySearch()
|
||||
{
|
||||
if (searchDisplayed)
|
||||
return;
|
||||
|
||||
searchDisplayed = true;
|
||||
|
||||
var item = menu.FindItem(Resource.Id.filter);
|
||||
item.SetVisible(true);
|
||||
item.CollapseActionView();
|
||||
var searchItem = item.ActionView;
|
||||
var searchView = searchItem.JavaCast<SearchView>();
|
||||
|
||||
searchView.SetQuery("", false);
|
||||
searchView.ClearFocus();
|
||||
searchView.OnActionViewCollapsed();
|
||||
|
||||
if (id != 0)
|
||||
return;
|
||||
|
||||
SupportActionBar.SetHomeButtonEnabled(false);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(false);
|
||||
SupportActionBar.Title = "MusicApp";
|
||||
}
|
||||
|
||||
private void PreNavigate(object sender, BottomNavigationView.NavigationItemSelectedEventArgs e)
|
||||
@@ -606,7 +558,6 @@ namespace MusicApp
|
||||
switch (layout)
|
||||
{
|
||||
case Resource.Id.musicLayout:
|
||||
ShowQuickPlay();
|
||||
if (Home.instance != null && !specialSwitch)
|
||||
{
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
@@ -615,23 +566,21 @@ namespace MusicApp
|
||||
return;
|
||||
}
|
||||
|
||||
tab = "Home";
|
||||
HideTabs();
|
||||
HideSearch();
|
||||
fragment = Home.NewInstance();
|
||||
break;
|
||||
|
||||
case Resource.Id.browseLayout:
|
||||
Console.WriteLine("&Navigating to browse with browse instance value " + Browse.instance + " and with youtubeSwitch set to " + specialSwitch);
|
||||
Console.WriteLine("&Navigating to browse with browse instance value " + Browse.instance + ", pager instance: " + Pager.instance + " and with youtubeSwitch set to " + specialSwitch);
|
||||
if (Browse.instance != null && !specialSwitch)
|
||||
{
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
Browse.instance.Refresh();
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
return;
|
||||
}
|
||||
|
||||
tab = "Browse";
|
||||
DisplaySearch();
|
||||
HideQuickPlay();
|
||||
fragment = Pager.NewInstance(0, 0);
|
||||
break;
|
||||
|
||||
@@ -644,10 +593,7 @@ namespace MusicApp
|
||||
return;
|
||||
}
|
||||
|
||||
tab = "Playlist";
|
||||
HideTabs();
|
||||
HideSearch();
|
||||
HideQuickPlay();
|
||||
fragment = Playlist.NewInstance();
|
||||
break;
|
||||
}
|
||||
@@ -655,188 +601,7 @@ namespace MusicApp
|
||||
if (fragment == null)
|
||||
fragment = EmptyFragment.NewInstance();
|
||||
|
||||
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, fragment).Commit();
|
||||
}
|
||||
|
||||
public void SetBrowseTabs(ViewPager pager, int selectedTab = 0)
|
||||
{
|
||||
if (tab != "Browse")
|
||||
return;
|
||||
|
||||
usePager = true;
|
||||
|
||||
viewPager = pager;
|
||||
TabLayout tabs = FindViewById<TabLayout>(Resource.Id.tabs);
|
||||
((AppBarLayout.LayoutParams)FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsingToolbar).LayoutParameters).ScrollFlags = AppBarLayout.LayoutParams.ScrollFlagScroll | AppBarLayout.LayoutParams.ScrollFlagEnterAlways | AppBarLayout.LayoutParams.ScrollFlagSnap;
|
||||
|
||||
tabs.RemoveAllTabs();
|
||||
tabs.Visibility = ViewStates.Visible;
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.songs)));
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.folders)));
|
||||
|
||||
ViewPagerAdapter adapter = new ViewPagerAdapter(SupportFragmentManager);
|
||||
adapter.AddFragment(Browse.NewInstance(), Resources.GetString(Resource.String.songs));
|
||||
adapter.AddFragment(FolderBrowse.NewInstance(), Resources.GetString(Resource.String.folders));
|
||||
|
||||
pager.Adapter = adapter;
|
||||
pager.AddOnPageChangeListener(this);
|
||||
pager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabs));
|
||||
|
||||
tabs.SetupWithViewPager(pager);
|
||||
tabs.TabReselected += OnTabReselected;
|
||||
|
||||
pager.CurrentItem = selectedTab;
|
||||
tabs.TabMode = TabLayout.ModeFixed;
|
||||
tabs.SetScrollPosition(selectedTab, 0f, true);
|
||||
}
|
||||
|
||||
public void SetYtTabs(ViewPager pager, string querry, int selectedTab = 0)
|
||||
{
|
||||
usePager = true;
|
||||
|
||||
viewPager = pager;
|
||||
TabLayout tabs = FindViewById<TabLayout>(Resource.Id.tabs);
|
||||
((AppBarLayout.LayoutParams)FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsingToolbar).LayoutParameters).ScrollFlags = AppBarLayout.LayoutParams.ScrollFlagScroll | AppBarLayout.LayoutParams.ScrollFlagEnterAlways | AppBarLayout.LayoutParams.ScrollFlagSnap;
|
||||
|
||||
if (YoutubeEngine.instances != null)
|
||||
{
|
||||
tabs.Visibility = ViewStates.Visible;
|
||||
for (int i = 0; i < YoutubeEngine.instances.Length; i++)
|
||||
{
|
||||
if (YoutubeEngine.instances[i].focused)
|
||||
selectedTab = i;
|
||||
}
|
||||
|
||||
pager.CurrentItem = selectedTab;
|
||||
pager.SetCurrentItem(selectedTab, true);
|
||||
|
||||
YoutubeEngine.instances[selectedTab].focused = true;
|
||||
YoutubeEngine.instances[selectedTab].OnFocus();
|
||||
pager.RefreshDrawableState();
|
||||
return;
|
||||
}
|
||||
|
||||
tabs.Visibility = ViewStates.Visible;
|
||||
tabs.RemoveAllTabs();
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.all)));
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.tracks)));
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.playlists)));
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.lives)));
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.channels)));
|
||||
|
||||
ViewPagerAdapter adapter = new ViewPagerAdapter(SupportFragmentManager);
|
||||
Android.Support.V4.App.Fragment[] fragment = YoutubeEngine.NewInstances(querry);
|
||||
adapter.AddFragment(fragment[0], Resources.GetString(Resource.String.all));
|
||||
adapter.AddFragment(fragment[1], Resources.GetString(Resource.String.tracks));
|
||||
adapter.AddFragment(fragment[2], Resources.GetString(Resource.String.playlists));
|
||||
adapter.AddFragment(fragment[3], Resources.GetString(Resource.String.lives));
|
||||
adapter.AddFragment(fragment[4], Resources.GetString(Resource.String.channels));
|
||||
|
||||
pager.Adapter = adapter;
|
||||
pager.AddOnPageChangeListener(this);
|
||||
pager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabs));
|
||||
tabs.SetupWithViewPager(pager);
|
||||
tabs.TabReselected += OnTabReselected;
|
||||
|
||||
pager.CurrentItem = selectedTab;
|
||||
tabs.TabMode = TabLayout.ModeScrollable;
|
||||
tabs.SetScrollPosition(selectedTab, 0f, true);
|
||||
|
||||
YoutubeEngine.instances[selectedTab].focused = true;
|
||||
YoutubeEngine.instances[selectedTab].OnFocus();
|
||||
}
|
||||
|
||||
private void OnTabReselected(object sender, TabLayout.TabReselectedEventArgs e)
|
||||
{
|
||||
if (Browse.instance != null)
|
||||
{
|
||||
if (Browse.instance.focused)
|
||||
Browse.instance.ListView.SmoothScrollToPosition(0);
|
||||
else
|
||||
FolderBrowse.instance.ListView.SmoothScrollToPosition(0);
|
||||
}
|
||||
if(YoutubeEngine.instances != null)
|
||||
{
|
||||
foreach (YoutubeEngine instance in YoutubeEngine.instances)
|
||||
{
|
||||
if (instance.focused)
|
||||
{
|
||||
instance.ListView.SmoothScrollToPosition(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPageScrollStateChanged(int state)
|
||||
{
|
||||
contentRefresh.Enabled = state == ViewPager.ScrollStateIdle;
|
||||
}
|
||||
|
||||
public void OnPageScrolled(int position, float positionOffset, int positionOffsetPixels) { }
|
||||
|
||||
public void OnPageSelected(int position)
|
||||
{
|
||||
if (Browse.instance != null)
|
||||
{
|
||||
if(!FolderBrowse.instance.populated)
|
||||
FolderBrowse.instance.PopulateList();
|
||||
|
||||
if(position == 0)
|
||||
{
|
||||
if(Browse.instance.focused)
|
||||
Browse.instance.ListView.SmoothScrollToPosition(0);
|
||||
|
||||
Browse.instance.focused = true;
|
||||
FolderBrowse.instance.focused = false;
|
||||
DisplaySearch();
|
||||
}
|
||||
if(position == 1)
|
||||
{
|
||||
if(FolderBrowse.instance.focused)
|
||||
FolderBrowse.instance.ListView.SmoothScrollToPosition(0);
|
||||
|
||||
Browse.instance.focused = false;
|
||||
FolderBrowse.instance.focused = true;
|
||||
HideSearch();
|
||||
}
|
||||
}
|
||||
else if (YoutubeEngine.instances != null)
|
||||
{
|
||||
foreach(YoutubeEngine instance in YoutubeEngine.instances)
|
||||
{
|
||||
if (instance.focused)
|
||||
instance.OnUnfocus();
|
||||
instance.focused = false;
|
||||
}
|
||||
YoutubeEngine.instances[position].focused = true;
|
||||
YoutubeEngine.instances[position].OnFocus();
|
||||
}
|
||||
}
|
||||
|
||||
public void HideTabs()
|
||||
{
|
||||
usePager = false;
|
||||
TabLayout tabs = FindViewById<TabLayout>(Resource.Id.tabs);
|
||||
tabs.RemoveAllTabs();
|
||||
tabs.Visibility = ViewStates.Gone;
|
||||
|
||||
((AppBarLayout.LayoutParams)FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsingToolbar).LayoutParameters).ScrollFlags = 0;
|
||||
|
||||
if (viewPager == null)
|
||||
return;
|
||||
|
||||
ViewPagerAdapter adapter = (ViewPagerAdapter)viewPager.Adapter;
|
||||
if (adapter != null)
|
||||
{
|
||||
Browse.instance = null;
|
||||
FolderBrowse.instance = null;
|
||||
|
||||
for (int i = 0; i < adapter.Count; i++)
|
||||
SupportFragmentManager.BeginTransaction().Remove(adapter.GetItem(i)).Commit();
|
||||
|
||||
adapter.Dispose();
|
||||
viewPager.Adapter = null;
|
||||
}
|
||||
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, fragment).SetCustomAnimations(Android.Resource.Animation.FadeIn, Android.Resource.Animation.FadeOut).Commit();
|
||||
}
|
||||
|
||||
public void PrepareSmallPlayer()
|
||||
@@ -896,8 +661,6 @@ namespace MusicApp
|
||||
FindViewById<BottomNavigationView>(Resource.Id.bottomView).TranslationY = (int)(56 * Resources.DisplayMetrics.Density + 0.5f);
|
||||
FindViewById(Resource.Id.playerContainer).Alpha = 1;
|
||||
FindViewById(Resource.Id.smallPlayer).Alpha = 0;
|
||||
FindViewById(Resource.Id.quickPlayLinear).ScaleX = 0;
|
||||
FindViewById(Resource.Id.quickPlayLinear).ScaleY = 0;
|
||||
SheetBehavior.State = BottomSheetBehavior.StateExpanded;
|
||||
}
|
||||
|
||||
@@ -918,28 +681,21 @@ namespace MusicApp
|
||||
FindViewById<NestedScrollView>(Resource.Id.playerSheet).Visibility = ViewStates.Gone;
|
||||
}
|
||||
|
||||
public void ShowQuickPlay()
|
||||
{
|
||||
LinearLayout quickPlayLayout = FindViewById<LinearLayout>(Resource.Id.quickPlayLinear);
|
||||
quickPlayLayout.FindViewById<LinearLayout>(Resource.Id.quickPlayLinear).Animate().Alpha(1);
|
||||
if (!quickPlayLayout.FindViewById<FloatingActionButton>(Resource.Id.quickPlay).HasOnClickListeners)
|
||||
{
|
||||
quickPlayLayout.FindViewById<FloatingActionButton>(Resource.Id.quickPlay).Click += QuickPlay;
|
||||
quickPlayLayout.FindViewById<FloatingActionButton>(Resource.Id.localPlay).Click += LocalPlay;
|
||||
quickPlayLayout.FindViewById<FloatingActionButton>(Resource.Id.ytPlay).Click += YtPlay;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetStoragePermission()
|
||||
public async Task<bool> GetReadPermission()
|
||||
{
|
||||
const string permission = Manifest.Permission.ReadExternalStorage;
|
||||
if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this, permission) == (int)Permission.Granted)
|
||||
{
|
||||
PremissionAuthorized();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
PermissionGot = null;
|
||||
string[] permissions = new string[] { permission };
|
||||
RequestPermissions(permissions, RequestCode);
|
||||
|
||||
while (PermissionGot == null)
|
||||
await Task.Delay(10);
|
||||
|
||||
return (bool)PermissionGot;
|
||||
}
|
||||
|
||||
public async Task<bool> GetWritePermission()
|
||||
@@ -966,12 +722,11 @@ namespace MusicApp
|
||||
if (grantResults.Length > 0)
|
||||
{
|
||||
if (grantResults[0] == Permission.Granted)
|
||||
PremissionAuthorized();
|
||||
PermissionGot = true;
|
||||
else
|
||||
{
|
||||
Snackbar snackBar = Snackbar.Make(FindViewById<CoordinatorLayout>(Resource.Id.snackBar), "Permission denied, can't list musics.", Snackbar.LengthLong)
|
||||
.SetAction("Ask Again", (v) => { GetStoragePermission(); });
|
||||
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
||||
PermissionGot = false;
|
||||
Snackbar snackBar = Snackbar.Make(FindViewById<CoordinatorLayout>(Resource.Id.snackBar), "Permission denied, can't complete this action.", Snackbar.LengthLong); snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
||||
snackBar.Show();
|
||||
}
|
||||
}
|
||||
@@ -989,14 +744,6 @@ namespace MusicApp
|
||||
}
|
||||
}
|
||||
|
||||
void PremissionAuthorized()
|
||||
{
|
||||
Browse.instance?.PopulateList();
|
||||
Playlist.instance?.PopulateView();
|
||||
if (Browse.instance == null && Playlist.instance == null && PreferencesFragment.instance == null && Preferences.instance == null)
|
||||
LocalPlay(sender, new EventArgs());
|
||||
}
|
||||
|
||||
public async static Task<string> GetBestThumb(string[] thumbnails)
|
||||
{
|
||||
foreach (string thumb in thumbnails)
|
||||
@@ -1018,86 +765,6 @@ namespace MusicApp
|
||||
return thumbnails.Last();
|
||||
}
|
||||
|
||||
public void HideQuickPlay()
|
||||
{
|
||||
FindViewById<LinearLayout>(Resource.Id.quickPlayLinear).Animate().Alpha(0);
|
||||
}
|
||||
|
||||
public async void QuickPlay(object sender, EventArgs e)
|
||||
{
|
||||
FloatingActionButton quickPlay = FindViewById<FloatingActionButton>(Resource.Id.quickPlay);
|
||||
if (QuickPlayOpenned)
|
||||
{
|
||||
AnimatedVectorDrawable drawable = (AnimatedVectorDrawable)crossToPlay;
|
||||
quickPlay.SetImageDrawable(drawable);
|
||||
drawable.Start();
|
||||
QuickPlayOpenned = false;
|
||||
await Task.Delay(10);
|
||||
FindViewById<FloatingActionButton>(Resource.Id.ytPlay).Animate().Alpha(0);
|
||||
await Task.Delay(10);
|
||||
FindViewById<FloatingActionButton>(Resource.Id.localPlay).Visibility = ViewStates.Gone;
|
||||
FindViewById<FloatingActionButton>(Resource.Id.ytPlay).Animate().Alpha(0);
|
||||
await Task.Delay(10);
|
||||
FindViewById<FloatingActionButton>(Resource.Id.ytPlay).Visibility = ViewStates.Gone;
|
||||
}
|
||||
else
|
||||
{
|
||||
AnimatedVectorDrawable drawable = (AnimatedVectorDrawable)playToCross;
|
||||
quickPlay.SetImageDrawable(drawable);
|
||||
drawable.Start();
|
||||
QuickPlayOpenned = true;
|
||||
await Task.Delay(10);
|
||||
FindViewById<FloatingActionButton>(Resource.Id.ytPlay).Alpha = 0;
|
||||
FindViewById<FloatingActionButton>(Resource.Id.ytPlay).Visibility = ViewStates.Visible;
|
||||
FindViewById<FloatingActionButton>(Resource.Id.ytPlay).Animate().Alpha(1);
|
||||
await Task.Delay(10);
|
||||
FindViewById<FloatingActionButton>(Resource.Id.localPlay).Alpha = 0;
|
||||
FindViewById<FloatingActionButton>(Resource.Id.localPlay).Visibility = ViewStates.Visible;
|
||||
FindViewById<FloatingActionButton>(Resource.Id.localPlay).Animate().Alpha(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void LocalPlay(object sender, EventArgs e)
|
||||
{
|
||||
if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) != (int)Permission.Granted)
|
||||
{
|
||||
this.sender = sender;
|
||||
GetStoragePermission();
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender != null)
|
||||
QuickPlay(this, e);
|
||||
|
||||
ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(this);
|
||||
string shortcut = prefManager.GetString("localPlay", "Shuffle All Audio Files");
|
||||
if (shortcut == "Shuffle All Audio Files")
|
||||
{
|
||||
ShuffleAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
long playlistID = prefManager.GetLong("localPlaylistID", -1);
|
||||
if (playlistID != -1)
|
||||
{
|
||||
Playlist.RandomPlay(playlistID, this);
|
||||
ShowSmallPlayer();
|
||||
ShowPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar snackBar = Snackbar.Make(FindViewById<View>(Resource.Id.snackBar), "No playlist set on setting.", Snackbar.LengthLong)
|
||||
.SetAction("Set it now", (v) =>
|
||||
{
|
||||
Intent intent = new Intent(Application.Context, typeof(Preferences));
|
||||
StartActivity(intent);
|
||||
});
|
||||
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
||||
snackBar.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async void ShuffleAll()
|
||||
{
|
||||
List<Song> songs = new List<Song>();
|
||||
@@ -1154,39 +821,6 @@ namespace MusicApp
|
||||
ShowPlayer();
|
||||
}
|
||||
|
||||
public async void YtPlay(object sender, EventArgs e)
|
||||
{
|
||||
if (MusicPlayer.CurrentID() == -1 || MusicPlayer.queue[MusicPlayer.CurrentID()].YoutubeID == null || MusicPlayer.queue[MusicPlayer.CurrentID()].YoutubeID == "")
|
||||
{
|
||||
if (MusicPlayer.CurrentID() != -1)
|
||||
{
|
||||
Stream stream = new FileStream(MusicPlayer.queue[MusicPlayer.CurrentID()].Path, FileMode.Open, FileAccess.Read);
|
||||
|
||||
var meta = TagLib.File.Create(new StreamFileAbstraction(MusicPlayer.queue[MusicPlayer.CurrentID()].Path, stream, stream));
|
||||
string ytID = meta.Tag.Comment;
|
||||
stream.Dispose();
|
||||
|
||||
MusicPlayer.queue[MusicPlayer.CurrentID()].YoutubeID = ytID;
|
||||
if (ytID != null && ytID != "")
|
||||
goto YtMix;
|
||||
}
|
||||
|
||||
if(sender != null)
|
||||
QuickPlay(this, e);
|
||||
Snackbar snackBar = Snackbar.Make(FindViewById(Resource.Id.snackBar), "You need to be playing a youtube song in order to create a mix.", Snackbar.LengthLong);
|
||||
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
||||
snackBar.Show();
|
||||
return;
|
||||
}
|
||||
|
||||
YtMix:
|
||||
|
||||
if (sender != null)
|
||||
QuickPlay(this, e);
|
||||
|
||||
YoutubeEngine.CreateMix((await MusicPlayer.GetItem()));
|
||||
}
|
||||
|
||||
public void YoutubeEndPointChanged()
|
||||
{
|
||||
FindViewById<ProgressBar>(Resource.Id.ytProgress).Visibility = ViewStates.Gone;
|
||||
@@ -1450,7 +1084,6 @@ namespace MusicApp
|
||||
|
||||
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Pager.NewInstance(1, 0)).AddToBackStack(null).Commit();
|
||||
}
|
||||
HideQuickPlay();
|
||||
SearchableActivity.instance = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -511,16 +511,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\PlayToCross.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\CrossToPlay.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\YtPlay.png" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using Android.Content;
|
||||
using Android.Content.PM;
|
||||
using Android.Database;
|
||||
using Android.Net;
|
||||
using Android.OS;
|
||||
using Android.Provider;
|
||||
using Android.Runtime;
|
||||
using Android.Support.Design.Widget;
|
||||
using Android.Support.V4.App;
|
||||
using Android.Support.V7.App;
|
||||
@@ -15,6 +15,7 @@ using Google.Apis.YouTube.v3;
|
||||
using MusicApp.Resources.values;
|
||||
using SQLite;
|
||||
using Square.Picasso;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -22,6 +23,7 @@ using System.Threading.Tasks;
|
||||
using TagLib;
|
||||
using Color = Android.Graphics.Color;
|
||||
using CursorLoader = Android.Support.V4.Content.CursorLoader;
|
||||
using Uri = Android.Net.Uri;
|
||||
|
||||
namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
@@ -36,6 +38,8 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
private View EmptyView;
|
||||
|
||||
public Browse() { }
|
||||
protected Browse(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { }
|
||||
|
||||
public override void OnActivityCreated(Bundle savedInstanceState)
|
||||
{
|
||||
@@ -63,23 +67,25 @@ namespace MusicApp.Resources.Portable_Class
|
||||
ListView.SetLayoutManager(new LinearLayoutManager(Android.App.Application.Context));
|
||||
ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
PopulateList();
|
||||
|
||||
//if (ListView.GetAdapter() == null)
|
||||
// MainActivity.instance.GetStoragePermission();
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
return view;
|
||||
}
|
||||
|
||||
public static Fragment NewInstance()
|
||||
{
|
||||
instance = new Browse { Arguments = new Bundle() };
|
||||
if(instance == null)
|
||||
instance = new Browse { Arguments = new Bundle() };
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void PopulateList()
|
||||
public async Task PopulateList()
|
||||
{
|
||||
musicList = new List<Song>();
|
||||
if (await MainActivity.instance.GetReadPermission() == false)
|
||||
return;
|
||||
|
||||
musicList = new List<Song>();
|
||||
Uri musicUri = MediaStore.Audio.Media.ExternalContentUri;
|
||||
|
||||
CursorLoader cursorLoader = new CursorLoader(Android.App.Application.Context, musicUri, null, null, null, null);
|
||||
@@ -112,10 +118,10 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
while (musicCursor.MoveToNext());
|
||||
musicCursor.Close();
|
||||
List<Song> songList = musicList.OrderBy(x => x.Title).ToList();
|
||||
musicList = songList;
|
||||
}
|
||||
|
||||
List<Song> songList = musicList.OrderBy(x => x.Title).ToList();
|
||||
musicList = songList;
|
||||
adapter = new BrowseAdapter(result ?? musicList, result == null);
|
||||
ListView.SetAdapter(adapter);
|
||||
adapter.ItemClick += ListView_ItemClick;
|
||||
@@ -127,17 +133,17 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRefresh(object sender, System.EventArgs e)
|
||||
private async void OnRefresh(object sender, EventArgs e)
|
||||
{
|
||||
if (!focused)
|
||||
return;
|
||||
Refresh();
|
||||
await Refresh();
|
||||
MainActivity.instance.contentRefresh.Refreshing = false;
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
public async Task Refresh()
|
||||
{
|
||||
PopulateList();
|
||||
await PopulateList();
|
||||
}
|
||||
|
||||
public void Search(string search)
|
||||
@@ -153,7 +159,8 @@ namespace MusicApp.Resources.Portable_Class
|
||||
adapter = new BrowseAdapter(result, result.Count == musicList.Count);
|
||||
adapter.ItemClick += ListView_ItemClick;
|
||||
adapter.ItemLongCLick += ListView_ItemLongClick;
|
||||
ListView.SetAdapter(adapter);
|
||||
Console.WriteLine("&ListView: " + ListView);
|
||||
ListView.SetAdapter(adapter); //ListView reference is still null
|
||||
}
|
||||
|
||||
public void ListView_ItemClick(object sender, int position)
|
||||
@@ -181,7 +188,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
item = CompleteItem(item);
|
||||
|
||||
BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
|
||||
View bottomView = LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);
|
||||
View bottomView = MainActivity.instance.LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsTitle).Text = item.Title;
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsArtist).Text = item.Artist;
|
||||
if (item.Album == null)
|
||||
@@ -647,7 +654,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
if (name != playlistName)
|
||||
continue;
|
||||
|
||||
System.Console.WriteLine("&Playlist exist");
|
||||
return cursor.GetLong(plID);
|
||||
}
|
||||
while (cursor.MoveToNext());
|
||||
@@ -664,10 +670,10 @@ namespace MusicApp.Resources.Portable_Class
|
||||
MainActivity.instance.StartActivity(intent);
|
||||
}
|
||||
|
||||
public override void OnResume()
|
||||
public override void OnViewStateRestored(Bundle savedInstanceState)
|
||||
{
|
||||
base.OnResume();
|
||||
instance = this;
|
||||
base.OnViewStateRestored(savedInstanceState);
|
||||
instance.ListView = View.FindViewById<RecyclerView>(Resource.Id.recycler);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,8 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
public static Fragment NewInstance()
|
||||
{
|
||||
instance = new FolderBrowse { Arguments = new Bundle() };
|
||||
//if(instance == null)
|
||||
instance = new FolderBrowse { Arguments = new Bundle() };
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -230,7 +231,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
act.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
act.SupportActionBar.Title = displayPath;
|
||||
|
||||
MainActivity.instance.HideTabs();
|
||||
MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, FolderTracks.NewInstance(path, displayPath)).AddToBackStack(null).Commit();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
base.OnActivityCreated(savedInstanceState);
|
||||
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
||||
|
||||
MainActivity.instance.DisplaySearch(1);
|
||||
MainActivity.instance.DisplaySearch();
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
|
||||
@@ -36,13 +36,12 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
base.OnActivityCreated(savedInstanceState);
|
||||
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
||||
ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
//ListView.ScrollChange += MainActivity.instance.Scroll; //was executing the following: contentRefresh.Enabled = ((LinearLayoutManager)Home.instance.ListView.GetLayoutManager()).FindFirstCompletelyVisibleItemPosition() == 0;
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
MainActivity.instance.contentRefresh.Refresh -= OnRefresh;
|
||||
ListView.ScrollChange -= MainActivity.instance.Scroll;
|
||||
ViewGroup rootView = Activity.FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
base.OnDestroy();
|
||||
instance = null;
|
||||
@@ -126,7 +125,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
ListView.SetAdapter(adapter);
|
||||
adapter.ItemClick += ListView_ItemClick;
|
||||
ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager)MainActivity.instance.GetSystemService(Context.ConnectivityService);
|
||||
NetworkInfo activeNetworkInfo = connectivityManager.ActiveNetworkInfo;
|
||||
@@ -425,7 +423,8 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
public static Fragment NewInstance()
|
||||
{
|
||||
instance = new Home { Arguments = new Bundle() };
|
||||
if(instance == null)
|
||||
instance = new Home { Arguments = new Bundle() };
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
using Android.OS;
|
||||
using Android.Views;
|
||||
using Android.Support.Design.Widget;
|
||||
using Android.Support.V4.App;
|
||||
using Android.Support.V4.View;
|
||||
using Android.Views;
|
||||
|
||||
namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
public class Pager : Fragment
|
||||
public class Pager : Fragment, ViewPager.IOnPageChangeListener
|
||||
{
|
||||
private static Pager instance;
|
||||
public static Pager instance;
|
||||
private ViewPagerAdapter adapter;
|
||||
private int type;
|
||||
private int pos;
|
||||
|
||||
@@ -19,7 +21,8 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
public static Fragment NewInstance(int type, int pos)
|
||||
{
|
||||
instance = new Pager { Arguments = new Bundle() };
|
||||
if(instance == null)
|
||||
instance = new Pager { Arguments = new Bundle() };
|
||||
instance.type = type;
|
||||
instance.pos = pos;
|
||||
return instance;
|
||||
@@ -28,11 +31,146 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
View view = inflater.Inflate(Resource.Layout.ViewPager, container, false);
|
||||
TabLayout tabs = Activity.FindViewById<TabLayout>(Resource.Id.tabs);
|
||||
ViewPager pager = view.FindViewById<ViewPager>(Resource.Id.pager);
|
||||
|
||||
((AppBarLayout.LayoutParams)Activity.FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsingToolbar).LayoutParameters).ScrollFlags = AppBarLayout.LayoutParams.ScrollFlagScroll | AppBarLayout.LayoutParams.ScrollFlagEnterAlways | AppBarLayout.LayoutParams.ScrollFlagSnap;
|
||||
tabs.Visibility = ViewStates.Visible;
|
||||
tabs.RemoveAllTabs();
|
||||
|
||||
if (type == 0)
|
||||
MainActivity.instance.SetBrowseTabs(view.FindViewById<ViewPager>(Resource.Id.pager), pos);
|
||||
{
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.songs)));
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.folders)));
|
||||
|
||||
adapter = new ViewPagerAdapter(Activity.SupportFragmentManager);
|
||||
adapter.AddFragment(Browse.NewInstance(), Resources.GetString(Resource.String.songs));
|
||||
adapter.AddFragment(FolderBrowse.NewInstance(), Resources.GetString(Resource.String.folders));
|
||||
|
||||
pager.Adapter = adapter;
|
||||
pager.AddOnPageChangeListener(this);
|
||||
pager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabs));
|
||||
|
||||
tabs.SetupWithViewPager(pager);
|
||||
tabs.TabReselected += OnTabReselected;
|
||||
|
||||
pager.CurrentItem = pos;
|
||||
tabs.TabMode = TabLayout.ModeFixed;
|
||||
tabs.SetScrollPosition(pos, 0f, true);
|
||||
}
|
||||
else if (type == 1 || type == 2)
|
||||
MainActivity.instance.SetYtTabs(view.FindViewById<ViewPager>(Resource.Id.pager), YoutubeEngine.searchKeyWorld, pos);
|
||||
{
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.all)));
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.tracks)));
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.playlists)));
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.lives)));
|
||||
tabs.AddTab(tabs.NewTab().SetText(Resources.GetString(Resource.String.channels)));
|
||||
|
||||
ViewPagerAdapter adapter = new ViewPagerAdapter(Activity.SupportFragmentManager);
|
||||
Fragment[] fragment = YoutubeEngine.NewInstances(YoutubeEngine.searchKeyWorld);
|
||||
adapter.AddFragment(fragment[0], Resources.GetString(Resource.String.all));
|
||||
adapter.AddFragment(fragment[1], Resources.GetString(Resource.String.tracks));
|
||||
adapter.AddFragment(fragment[2], Resources.GetString(Resource.String.playlists));
|
||||
adapter.AddFragment(fragment[3], Resources.GetString(Resource.String.lives));
|
||||
adapter.AddFragment(fragment[4], Resources.GetString(Resource.String.channels));
|
||||
|
||||
pager.Adapter = adapter;
|
||||
pager.AddOnPageChangeListener(this);
|
||||
pager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabs));
|
||||
tabs.SetupWithViewPager(pager);
|
||||
tabs.TabReselected += OnTabReselected;
|
||||
|
||||
pager.CurrentItem = pos;
|
||||
tabs.TabMode = TabLayout.ModeScrollable;
|
||||
tabs.SetScrollPosition(pos, 0f, true);
|
||||
|
||||
YoutubeEngine.instances[pos].focused = true;
|
||||
YoutubeEngine.instances[pos].OnFocus();
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
private void OnTabReselected(object sender, TabLayout.TabReselectedEventArgs e)
|
||||
{
|
||||
if (Browse.instance != null)
|
||||
{
|
||||
if (Browse.instance.focused)
|
||||
Browse.instance.ListView.SmoothScrollToPosition(0);
|
||||
else
|
||||
FolderBrowse.instance.ListView.SmoothScrollToPosition(0);
|
||||
}
|
||||
if (YoutubeEngine.instances != null)
|
||||
{
|
||||
foreach (YoutubeEngine instance in YoutubeEngine.instances)
|
||||
{
|
||||
if (instance.focused)
|
||||
{
|
||||
instance.ListView.SmoothScrollToPosition(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPageScrollStateChanged(int state)
|
||||
{
|
||||
MainActivity.instance.contentRefresh.Enabled = state == ViewPager.ScrollStateIdle;
|
||||
}
|
||||
|
||||
public void OnPageScrolled(int position, float positionOffset, int positionOffsetPixels) { }
|
||||
|
||||
public void OnPageSelected(int position)
|
||||
{
|
||||
if (Browse.instance != null)
|
||||
{
|
||||
if (!FolderBrowse.instance.populated)
|
||||
FolderBrowse.instance.PopulateList();
|
||||
|
||||
if (position == 0)
|
||||
{
|
||||
if (Browse.instance.focused)
|
||||
Browse.instance.ListView.SmoothScrollToPosition(0);
|
||||
|
||||
Browse.instance.focused = true;
|
||||
FolderBrowse.instance.focused = false;
|
||||
MainActivity.instance.DisplaySearch();
|
||||
}
|
||||
else if (position == 1)
|
||||
{
|
||||
if (FolderBrowse.instance.focused)
|
||||
FolderBrowse.instance.ListView.SmoothScrollToPosition(0);
|
||||
|
||||
Browse.instance.focused = false;
|
||||
FolderBrowse.instance.focused = true;
|
||||
MainActivity.instance.HideSearch();
|
||||
}
|
||||
}
|
||||
else if (YoutubeEngine.instances != null)
|
||||
{
|
||||
foreach (YoutubeEngine instance in YoutubeEngine.instances)
|
||||
{
|
||||
if (instance.focused)
|
||||
instance.OnUnfocus();
|
||||
instance.focused = false;
|
||||
}
|
||||
YoutubeEngine.instances[position].focused = true;
|
||||
YoutubeEngine.instances[position].OnFocus();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDestroyView()
|
||||
{
|
||||
base.OnDestroyView();
|
||||
Browse.instance = null;
|
||||
FolderBrowse.instance = null;
|
||||
adapter.Dispose();
|
||||
|
||||
TabLayout tabs = Activity.FindViewById<TabLayout>(Resource.Id.tabs);
|
||||
tabs.RemoveAllTabs();
|
||||
tabs.Visibility = ViewStates.Gone;
|
||||
|
||||
((AppBarLayout.LayoutParams)Activity.FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsingToolbar).LayoutParameters).ScrollFlags = 0;
|
||||
|
||||
instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -659,7 +659,6 @@ namespace MusicApp
|
||||
private FrameLayout smallPlayer;
|
||||
private View playerContainer;
|
||||
//private View playerStatusBar;
|
||||
private LinearLayout quickPlay;
|
||||
private CoordinatorLayout snackBar;
|
||||
private bool Refreshed = false;
|
||||
private SheetMovement movement = SheetMovement.Unknow;
|
||||
@@ -672,7 +671,6 @@ namespace MusicApp
|
||||
smallPlayer = context.FindViewById<FrameLayout>(Resource.Id.smallPlayer);
|
||||
playerContainer = context.FindViewById(Resource.Id.playerContainer);
|
||||
//playerStatusBar = context.FindViewById(Resource.Id.playerStatus);
|
||||
quickPlay = context.FindViewById<LinearLayout>(Resource.Id.quickPlayLinear);
|
||||
snackBar = context.FindViewById<CoordinatorLayout>(Resource.Id.snackBar);
|
||||
}
|
||||
|
||||
@@ -695,8 +693,6 @@ namespace MusicApp
|
||||
playerContainer.Alpha = Math.Max(0, (slideOffset - 0.5f) * 2.5f);
|
||||
//playerStatusBar.ScaleY = slideOffset;
|
||||
smallPlayer.Alpha = Math.Max(0, 1 - slideOffset * 2);
|
||||
quickPlay.ScaleX = Math.Max(0, 1 - slideOffset * 2);
|
||||
quickPlay.ScaleY = Math.Max(0, 1 - slideOffset * 2);
|
||||
snackBar.TranslationY = (int)((50 * context.Resources.DisplayMetrics.Density + 0.5f) * slideOffset);
|
||||
|
||||
if (!Refreshed && slideOffset > .3)
|
||||
|
||||
@@ -127,7 +127,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
adapter.ItemClick += ListView_ItemClick;
|
||||
adapter.ItemLongCLick += ListView_ItemLongClick;
|
||||
ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
|
||||
//Youtube playlists
|
||||
if (!await MainActivity.instance.WaitForYoutube())
|
||||
@@ -345,7 +344,8 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
public static Fragment NewInstance()
|
||||
{
|
||||
instance = new Playlist { Arguments = new Bundle() };
|
||||
if(instance == null)
|
||||
instance = new Playlist { Arguments = new Bundle() };
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
base.OnActivityCreated(savedInstanceState);
|
||||
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
||||
MainActivity.instance.DisplaySearch(1);
|
||||
MainActivity.instance.DisplaySearch();
|
||||
|
||||
int statusHeight = Resources.GetDimensionPixelSize(Resources.GetIdentifier("status_bar_height", "dimen", "android"));
|
||||
MainActivity.instance.FindViewById(Resource.Id.collapsingToolbar).LayoutParameters.Height = ViewGroup.LayoutParams.WrapContent;
|
||||
|
||||
@@ -137,8 +137,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
|
||||
{
|
||||
AskForPermission();
|
||||
|
||||
instance = this;
|
||||
SetPreferencesFromResource(Resource.Layout.Preferences, rootKey);
|
||||
ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
|
||||
@@ -229,11 +227,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
}
|
||||
|
||||
private async void AskForPermission()
|
||||
{
|
||||
await Task.Delay(100);
|
||||
MainActivity.instance.GetStoragePermission();
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
|
||||
@@ -116,9 +116,9 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
};
|
||||
|
||||
holder.MixButton.Click += (sender, e) =>
|
||||
holder.MixButton.Click += async (sender, e) =>
|
||||
{
|
||||
MainActivity.instance.YtPlay(null, null);
|
||||
YoutubeEngine.CreateMix(await MusicPlayer.GetItem());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
ListView = view.FindViewById<RecyclerView>(Resource.Id.recycler);
|
||||
ListView.SetLayoutManager(new LinearLayoutManager(Android.App.Application.Context));
|
||||
ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
|
||||
#pragma warning disable CS4014
|
||||
Search(searchKeyWorld, querryType, true);
|
||||
|
||||
2566
MusicApp/Resources/Resource.Designer.cs
generated
2566
MusicApp/Resources/Resource.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,30 +0,0 @@
|
||||
<animated-vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt">
|
||||
<aapt:attr name="android:drawable">
|
||||
<vector
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="play"
|
||||
android:pathData="M 8 5 L 8 19 L 19 12 Z"
|
||||
android:fillColor="#000000"/>
|
||||
</vector>
|
||||
</aapt:attr>
|
||||
<target android:name="play">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:propertyName="pathData"
|
||||
android:duration="200"
|
||||
android:repeatCount="0"
|
||||
android:repeatMode="reverse"
|
||||
android:valueFrom="M 6.41 5 L 5 6.41 L 10.59 12 L 5 17.59 L 6.41 19 L 12 13.41 L 17.59 19 L 19 17.59 L 13.41 12 L 19 6.41 L 17.59 5 L 12 10.59 L 6.41 5"
|
||||
android:valueTo="M 8 5 L 8 8.5 L 8 12 L 8 15.5 L 8 19 L 10.2 17.6 L 12.4 16.2 L 14.6 14.8 L 16.8 13.4 L 19 12 L 15.333 9.667 L 11.667 7.333 L 8 5"
|
||||
android:valueType="pathType"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
</animated-vector>
|
||||
@@ -1,30 +0,0 @@
|
||||
<animated-vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt">
|
||||
<aapt:attr name="android:drawable">
|
||||
<vector
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="play"
|
||||
android:pathData="M 8 5 L 8 19 L 19 12 Z"
|
||||
android:fillColor="#000000"/>
|
||||
</vector>
|
||||
</aapt:attr>
|
||||
<target android:name="play">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:propertyName="pathData"
|
||||
android:duration="200"
|
||||
android:repeatCount="0"
|
||||
android:repeatMode="reverse"
|
||||
android:valueFrom="M 8 5 L 8 8.5 L 8 12 L 8 15.5 L 8 19 L 10.2 17.6 L 12.4 16.2 L 14.6 14.8 L 16.8 13.4 L 19 12 L 15.333 9.667 L 11.667 7.333 L 8 5"
|
||||
android:valueTo="M 6.41 5 L 5 6.41 L 10.59 12 L 5 17.59 L 6.41 19 L 12 13.41 L 17.59 19 L 19 17.59 L 13.41 12 L 19 6.41 L 17.59 5 L 12 10.59 L 6.41 5"
|
||||
android:valueType="pathType"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
</animated-vector>
|
||||
@@ -225,47 +225,4 @@
|
||||
app:layout_anchorGravity="top"
|
||||
android:layout_gravity="top"
|
||||
android:padding="10dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/quickPlayLinear"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp"
|
||||
app:layout_anchor="@id/snackBar"
|
||||
app:layout_anchorGravity="top|end"
|
||||
android:layout_gravity="top|end" >
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center"
|
||||
app:fabSize="mini"
|
||||
app:elevation="5dp"
|
||||
app:pressedTranslationZ="12dp"
|
||||
app:backgroundTint="?colorAccent"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:tint="#000"
|
||||
android:src="@drawable/PlaylistPlay"
|
||||
android:id="@+id/localPlay"/>
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center"
|
||||
app:fabSize="mini"
|
||||
app:elevation="5dp"
|
||||
app:pressedTranslationZ="12dp"
|
||||
app:backgroundTint="#c62828"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:src="@drawable/YtPlay"
|
||||
android:id="@+id/ytPlay"/>
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
app:elevation="5dp"
|
||||
app:pressedTranslationZ="12dp"
|
||||
android:src="@drawable/PlayToCross"
|
||||
android:id="@+id/quickPlay"/>
|
||||
</LinearLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
Reference in New Issue
Block a user