diff --git a/MusicApp/MusicApp.csproj b/MusicApp/MusicApp.csproj index 52bd031..b4b91b2 100644 --- a/MusicApp/MusicApp.csproj +++ b/MusicApp/MusicApp.csproj @@ -146,6 +146,7 @@ + @@ -316,6 +317,11 @@ + + + Designer + + diff --git a/MusicApp/Resources/Portable Class/Browse.cs b/MusicApp/Resources/Portable Class/Browse.cs index 0035894..edfe7b8 100644 --- a/MusicApp/Resources/Portable Class/Browse.cs +++ b/MusicApp/Resources/Portable Class/Browse.cs @@ -8,14 +8,20 @@ using MusicApp.Resources.values; using Android.Content; using Android; using Android.Support.Design.Widget; +using Android.Support.V7.Widget; using Android.Views; using Android.Content.PM; using Android.Support.V4.App; +using Android.Support.V4.View; using Android.Support.V7.App; +using Android.Support.V4.Widget; +using Android.Runtime; +using System; +using Java.Lang; namespace MusicApp.Resources.Portable_Class { - public class Browse : ListFragment//, ActionBar.ITabListener + public class Browse : ListFragment { public static Browse instance; public static Context act; @@ -34,43 +40,26 @@ namespace MusicApp.Resources.Portable_Class base.OnActivityCreated(savedInstanceState); act = Activity; inflater = LayoutInflater; + View tabs = LayoutInflater.Inflate(Resource.Layout.tabs, null); emptyView = LayoutInflater.Inflate(Resource.Layout.NoSong, null); ListView.EmptyView = emptyView; - //ActionBar.Tab tab = MainActivity.instance.SupportActionBar.NewTab(); - //tab.SetText("Songs"); - //tab.SetTabListener(this); - //MainActivity.instance.SupportActionBar.AddTab(tab); + TabLayout tabLayout = tabs.FindViewById(Resource.Id.tabs); + ViewPager pager = tabs.FindViewById(Resource.Id.pager); + ViewPagerAdapter adapter = new ViewPagerAdapter(FragmentManager); + adapter.AddFragment(this, "Songs"); + //adapter.AddFragment(new FolderBrowse(), "Folders"); - //tab = MainActivity.instance.SupportActionBar.NewTab(); - //tab.SetText("Folders"); - //tab.SetTabListener(this); - //MainActivity.instance.SupportActionBar.AddTab(tab); + pager.Adapter = adapter; + tabLayout.SetupWithViewPager(pager); - //tab = MainActivity.instance.SupportActionBar.NewTab(); - //tab.SetText("Albums"); - //tab.SetTabListener(this); - //MainActivity.instance.SupportActionBar.AddTab(tab); + tabs.SetPadding(0, 100, 0, 0); + Activity.AddContentView(tabs, View.LayoutParameters); GetStoragePermission(); InitialiseSearchService(); } - //public void OnTabReselected(ActionBar.Tab tab, FragmentTransaction ft) - //{ - // throw new System.NotImplementedException(); - //} - - //public void OnTabSelected(ActionBar.Tab tab, FragmentTransaction ft) - //{ - // throw new System.NotImplementedException(); - //} - - //public void OnTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) - //{ - // throw new System.NotImplementedException(); - //} - public override void OnDestroy() { MainActivity.instance.RemoveSearchService(0); @@ -132,7 +121,7 @@ namespace MusicApp.Resources.Portable_Class void PopulateList() { - Uri musicUri = MediaStore.Audio.Media.ExternalContentUri; + Android.Net.Uri musicUri = MediaStore.Audio.Media.ExternalContentUri; CursorLoader cursorLoader = new CursorLoader(Android.App.Application.Context, musicUri, null, null, null, null); ICursor musicCursor = (ICursor)cursorLoader.LoadInBackground(); @@ -262,7 +251,7 @@ namespace MusicApp.Resources.Portable_Class playList.Add("Create a playlist"); playListId.Add(0); - Uri uri = MediaStore.Audio.Playlists.ExternalContentUri; + Android.Net.Uri uri = MediaStore.Audio.Playlists.ExternalContentUri; CursorLoader loader = new CursorLoader(Android.App.Application.Context, uri, null, null, null, null); ICursor cursor = (ICursor)loader.LoadInBackground(); @@ -323,10 +312,46 @@ namespace MusicApp.Resources.Portable_Class public void CreatePlaylist(string name) { ContentResolver resolver = Activity.ContentResolver; - Uri uri = MediaStore.Audio.Playlists.ExternalContentUri; + Android.Net.Uri uri = MediaStore.Audio.Playlists.ExternalContentUri; ContentValues value = new ContentValues(); value.Put(MediaStore.Audio.Playlists.InterfaceConsts.Name, name); resolver.Insert(uri, value); } } + + public class ViewPagerAdapter : FragmentPagerAdapter + { + private List fragmentList = new List(); + private List titles = new List(); + + + public ViewPagerAdapter(FragmentManager fm) : base(fm) + { + + } + + protected ViewPagerAdapter(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) + { + + } + + public override int Count => fragmentList.Count; + + public override Fragment GetItem(int position) + { + return fragmentList[position]; + } + + public void AddFragment (Fragment fragment, string title) + { + fragmentList.Add(fragment); + titles.Add(title); + } + + public override ICharSequence GetPageTitleFormatted(int position) + { + ICharSequence title = CharSequence.ArrayFromStringArray(new string[] { titles[position] })[0]; + return title; + } + } } \ No newline at end of file diff --git a/MusicApp/Resources/Portable Class/FolderBrowse.cs b/MusicApp/Resources/Portable Class/FolderBrowse.cs new file mode 100644 index 0000000..a80cd4d --- /dev/null +++ b/MusicApp/Resources/Portable Class/FolderBrowse.cs @@ -0,0 +1,9 @@ +using Android.Support.V4.App; + +namespace MusicApp.Resources.Portable_Class +{ + public class FolderBrowse : ListFragment + { + + } +} \ No newline at end of file diff --git a/MusicApp/Resources/Resource.Designer.cs b/MusicApp/Resources/Resource.Designer.cs index 035a7a6..f36131b 100644 --- a/MusicApp/Resources/Resource.Designer.cs +++ b/MusicApp/Resources/Resource.Designer.cs @@ -2477,8 +2477,8 @@ namespace MusicApp // aapt resource value: 0x7f07008b public const int bottomView = 2131165323; - // aapt resource value: 0x7f0700bc - public const int browseLayout = 2131165372; + // aapt resource value: 0x7f0700be + public const int browseLayout = 2131165374; // aapt resource value: 0x7f070073 public const int browseList = 2131165299; @@ -2567,8 +2567,8 @@ namespace MusicApp // aapt resource value: 0x7f070012 public const int disableHome = 2131165202; - // aapt resource value: 0x7f0700bd - public const int downloadLayout = 2131165373; + // aapt resource value: 0x7f0700bf + public const int downloadLayout = 2131165375; // aapt resource value: 0x7f070066 public const int edit_query = 2131165286; @@ -2672,8 +2672,8 @@ namespace MusicApp // aapt resource value: 0x7f070088 public const int mainView = 2131165320; - // aapt resource value: 0x7f0700ba - public const int masked = 2131165370; + // aapt resource value: 0x7f0700bc + public const int masked = 2131165372; // aapt resource value: 0x7f070094 public const int media_actions = 2131165332; @@ -2687,8 +2687,8 @@ namespace MusicApp // aapt resource value: 0x7f070019 public const int multiply = 2131165209; - // aapt resource value: 0x7f0700bb - public const int musicLayout = 2131165371; + // aapt resource value: 0x7f0700bd + public const int musicLayout = 2131165373; // aapt resource value: 0x7f07007d public const int navigation_header_container = 2131165309; @@ -2714,6 +2714,9 @@ namespace MusicApp // aapt resource value: 0x7f070096 public const int notification_main_column_container = 2131165334; + // aapt resource value: 0x7f0700ba + public const int pager = 2131165370; + // aapt resource value: 0x7f070037 public const int parallax = 2131165239; @@ -2741,8 +2744,8 @@ namespace MusicApp // aapt resource value: 0x7f0700a8 public const int playerTitle = 2131165352; - // aapt resource value: 0x7f0700be - public const int playlistLayout = 2131165374; + // aapt resource value: 0x7f0700c0 + public const int playlistLayout = 2131165376; // aapt resource value: 0x7f070074 public const int playlistName = 2131165300; @@ -2825,8 +2828,8 @@ namespace MusicApp // aapt resource value: 0x7f070072 public const int select_dialog_listview = 2131165298; - // aapt resource value: 0x7f0700bf - public const int settings = 2131165375; + // aapt resource value: 0x7f0700c1 + public const int settings = 2131165377; // aapt resource value: 0x7f07005c public const int shortcut = 2131165276; @@ -2888,6 +2891,9 @@ namespace MusicApp // aapt resource value: 0x7f070011 public const int tabMode = 2131165201; + // aapt resource value: 0x7f0700b9 + public const int tabs = 2131165369; + // aapt resource value: 0x7f0700a3 public const int text = 2131165347; @@ -2954,8 +2960,8 @@ namespace MusicApp // aapt resource value: 0x7f07000e public const int view_offset_helper = 2131165198; - // aapt resource value: 0x7f0700b9 - public const int visible = 2131165369; + // aapt resource value: 0x7f0700bb + public const int visible = 2131165371; // aapt resource value: 0x7f070027 public const int withText = 2131165223; @@ -3275,10 +3281,13 @@ namespace MusicApp public const int support_simple_spinner_dropdown_item = 2130903125; // aapt resource value: 0x7f030056 - public const int TimerLayout = 2130903126; + public const int tabs = 2130903126; // aapt resource value: 0x7f030057 - public const int toolbar = 2130903127; + public const int TimerLayout = 2130903127; + + // aapt resource value: 0x7f030058 + public const int toolbar = 2130903128; static Layout() { diff --git a/MusicApp/Resources/layout/tabs.xml b/MusicApp/Resources/layout/tabs.xml new file mode 100644 index 0000000..d76519d --- /dev/null +++ b/MusicApp/Resources/layout/tabs.xml @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file