mirror of
https://github.com/zoriya/Opus.git
synced 2026-06-09 08:44:02 +00:00
Adding empty view on playlist tracks.
This commit is contained in:
@@ -444,11 +444,6 @@ namespace MusicApp
|
||||
else if (FolderTracks.instance != null)
|
||||
{
|
||||
HideSearch();
|
||||
if (FolderTracks.instance.isEmpty)
|
||||
{
|
||||
ViewGroup rootView = FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
rootView.RemoveView(PlaylistTracks.instance.emptyView);
|
||||
}
|
||||
SupportActionBar.SetHomeButtonEnabled(false);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(false);
|
||||
SupportActionBar.Title = "MusicApp";
|
||||
|
||||
@@ -389,11 +389,6 @@
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ic_play_arrow_black_24dp.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\NoPlaylist.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\NoQueue.xml">
|
||||
<SubType>Designer</SubType>
|
||||
@@ -703,6 +698,9 @@
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\Delete.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\EmptyView.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" />
|
||||
<Import Project="..\packages\Xamarin.Android.Support.v7.Preference.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.v7.Preference.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.Preference.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.v7.Preference.targets')" />
|
||||
|
||||
@@ -18,9 +18,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public static FolderTracks instance;
|
||||
public string folderName;
|
||||
public Adapter adapter;
|
||||
public View emptyView;
|
||||
public List<Song> result;
|
||||
public bool isEmpty = false;
|
||||
public string path;
|
||||
|
||||
private List<Song> tracks = new List<Song>();
|
||||
@@ -30,8 +28,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public override void OnActivityCreated(Bundle savedInstanceState)
|
||||
{
|
||||
base.OnActivityCreated(savedInstanceState);
|
||||
emptyView = LayoutInflater.Inflate(Resource.Layout.NoPlaylist, null);
|
||||
ListView.EmptyView = emptyView;
|
||||
ListView.Scroll += MainActivity.instance.Scroll;
|
||||
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
||||
MainActivity.instance.OnPaddingChanged += OnPaddingChanged;
|
||||
@@ -121,12 +117,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
ListView.TextFilterEnabled = true;
|
||||
ListView.ItemClick += ListView_ItemClick;
|
||||
ListView.ItemLongClick += ListView_ItemLongClick;
|
||||
|
||||
if (adapter == null || adapter.Count == 0)
|
||||
{
|
||||
isEmpty = true;
|
||||
Activity.AddContentView(emptyView, View.LayoutParameters);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRefresh(object sender, System.EventArgs e)
|
||||
@@ -177,12 +167,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
listPadding = MainActivity.paddingBot - MainActivity.defaultPaddingBot
|
||||
};
|
||||
ListAdapter = adapter;
|
||||
|
||||
if (adapter == null || adapter.Count == 0)
|
||||
{
|
||||
isEmpty = true;
|
||||
Activity.AddContentView(emptyView, View.LayoutParameters);
|
||||
}
|
||||
MainActivity.instance.contentRefresh.Refreshing = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,11 @@ namespace MusicApp.Resources.Portable_Class
|
||||
private List<Google.Apis.YouTube.v3.Data.Playlist> YtPlaylists = new List<Google.Apis.YouTube.v3.Data.Playlist>();
|
||||
|
||||
private PlaylistAdapter adapter;
|
||||
private View emptyView;
|
||||
|
||||
public override void OnActivityCreated(Bundle savedInstanceState)
|
||||
{
|
||||
base.OnActivityCreated(savedInstanceState);
|
||||
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
||||
emptyView = LayoutInflater.Inflate(Resource.Layout.NoPlaylist, null);
|
||||
MainActivity.instance.OnPaddingChanged += OnPaddingChanged;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,12 +94,12 @@ namespace MusicApp.Resources.Portable_Class
|
||||
}
|
||||
else if (position == 1 && playlistsName[1].StartsWith("EMPTY - "))
|
||||
{
|
||||
EmptyCategoryHolder holder = (EmptyCategoryHolder)viewHolder;
|
||||
EmptyHolder holder = (EmptyHolder)viewHolder;
|
||||
holder.text.Text = playlistsName[1].Substring(8);
|
||||
}
|
||||
else if (position - playlistsName.Count == 1 && ytPlaylists[1].Title == "EMPTY")
|
||||
{
|
||||
EmptyCategoryHolder holder = (EmptyCategoryHolder)viewHolder;
|
||||
EmptyHolder holder = (EmptyHolder)viewHolder;
|
||||
holder.text.Text = ytPlaylists[1].Artist;
|
||||
}
|
||||
else if (position == playlistsName.Count + ytPlaylists.Count)
|
||||
@@ -125,7 +125,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
else if(position >= playlistsName.Count && ytPlaylists[position - playlistsName.Count].Title == "Loading" && ytPlaylists[position - playlistsName.Count].youtubeID == null) { }
|
||||
else if(position - playlistsName.Count == 1 && ytPlaylists[1].Title == "Error" && ytPlaylists[1].youtubeID == null)
|
||||
{
|
||||
EmptyCategoryHolder holder = (EmptyCategoryHolder)viewHolder;
|
||||
EmptyHolder holder = (EmptyHolder)viewHolder;
|
||||
holder.text.Text = "Error while loading.\nCheck your internet connection and check if your logged in.";
|
||||
holder.text.SetTextColor(Color.Red);
|
||||
}
|
||||
@@ -239,7 +239,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
else
|
||||
{
|
||||
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.EmptyListCategory, parent, false);
|
||||
return new EmptyCategoryHolder(itemView);
|
||||
return new EmptyHolder(itemView);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public event EventHandler<int> ItemClick;
|
||||
public event EventHandler<int> ItemLongClick;
|
||||
public int listPadding;
|
||||
private bool empty = false;
|
||||
|
||||
public PlaylistTrackAdapter(List<Song> songList)
|
||||
{
|
||||
@@ -39,10 +40,32 @@ namespace MusicApp.Resources.Portable_Class
|
||||
NotifyItemRemoved(position);
|
||||
}
|
||||
|
||||
public override int ItemCount => songList.Count + (PlaylistTracks.instance.fullyLoadded ? 0 : 1) + (PlaylistTracks.instance.useHeader ? 0 : 1);
|
||||
public override int ItemCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = songList.Count + (PlaylistTracks.instance.fullyLoadded ? 0 : 1) + (PlaylistTracks.instance.useHeader ? 0 : 1);
|
||||
if (count == 0 || (count == 1 && !PlaylistTracks.instance.useHeader))
|
||||
{
|
||||
empty = true;
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
|
||||
{
|
||||
if(empty && position + 1 == ItemCount)
|
||||
{
|
||||
if(PlaylistTracks.instance.tracks.Count == 0)
|
||||
((TextView)viewHolder.ItemView).Text = "This playlist is empty.";
|
||||
else
|
||||
((TextView)viewHolder.ItemView).Text = "No track found.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PlaylistTracks.instance.useHeader)
|
||||
position--;
|
||||
|
||||
@@ -147,15 +170,23 @@ namespace MusicApp.Resources.Portable_Class
|
||||
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.smallLoading, parent, false);
|
||||
return new UslessHolder(itemView);
|
||||
}
|
||||
else
|
||||
else if(viewType == 2)
|
||||
{
|
||||
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.PlaylistSmallHeader, parent, false);
|
||||
return new UslessHolder(itemView);
|
||||
}
|
||||
else
|
||||
{
|
||||
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.EmptyView, parent, false);
|
||||
return new EmptyHolder(itemView);
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetItemViewType(int position)
|
||||
{
|
||||
if (empty && position + 1 == ItemCount)
|
||||
return 3;
|
||||
|
||||
if (position == 0 && !PlaylistTracks.instance.useHeader)
|
||||
return 2;
|
||||
else if (position - (PlaylistTracks.instance.useHeader ? 0 : 1) >= songList.Count)
|
||||
@@ -173,23 +204,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
ItemLongClick?.Invoke(this, position);
|
||||
}
|
||||
|
||||
public void ItemMoved(int fromPosition, int toPosition)
|
||||
{
|
||||
//Enable this only if the user is editing the playlist
|
||||
|
||||
//if (fromPosition < toPosition)
|
||||
//{
|
||||
// for (int i = fromPosition; i < toPosition; i++)
|
||||
// songList = Swap(songList, i, i + 1);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// for (int i = fromPosition; i > toPosition; i--)
|
||||
// songList = Swap(songList, i, i - 1);
|
||||
//}
|
||||
|
||||
//NotifyItemMoved(fromPosition, toPosition);
|
||||
}
|
||||
public void ItemMoved(int fromPosition, int toPosition) { }
|
||||
|
||||
public void ItemMoveEnded(int fromPosition, int toPosition) { }
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public string playlistName;
|
||||
public RecyclerView ListView;
|
||||
public PlaylistTrackAdapter adapter;
|
||||
public View emptyView;
|
||||
private Android.Support.V7.Widget.Helper.ItemTouchHelper itemTouchHelper;
|
||||
public List<Song> result = null;
|
||||
public long playlistId;
|
||||
@@ -206,11 +205,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
if (Player.instance == null)
|
||||
{
|
||||
MainActivity.instance.HideSearch();
|
||||
if (isEmpty)
|
||||
{
|
||||
ViewGroup rootView = Activity.FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
rootView.RemoveView(emptyView);
|
||||
}
|
||||
MainActivity.instance.SupportActionBar.SetHomeButtonEnabled(false);
|
||||
MainActivity.instance.SupportActionBar.SetDisplayHomeAsUpEnabled(false);
|
||||
MainActivity.instance.SupportActionBar.SetDisplayShowTitleEnabled(true);
|
||||
@@ -411,12 +405,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
itemTouchHelper = new Android.Support.V7.Widget.Helper.ItemTouchHelper(callback);
|
||||
itemTouchHelper.AttachToRecyclerView(ListView);
|
||||
|
||||
if (adapter == null || adapter.ItemCount == 0)
|
||||
{
|
||||
isEmpty = true;
|
||||
Activity.AddContentView(emptyView, View.LayoutParameters);
|
||||
}
|
||||
|
||||
Activity.FindViewById<TextView>(Resource.Id.headerNumber).Text = tracks.Count.ToString() + " songs";
|
||||
var songCover = Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, tracks[0].AlbumArt);
|
||||
@@ -455,12 +443,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
Android.Support.V7.Widget.Helper.ItemTouchHelper.Callback callback = new ItemTouchCallback(adapter);
|
||||
itemTouchHelper = new Android.Support.V7.Widget.Helper.ItemTouchHelper(callback);
|
||||
itemTouchHelper.AttachToRecyclerView(ListView);
|
||||
|
||||
if (adapter == null || adapter.ItemCount == 0)
|
||||
{
|
||||
isEmpty = true;
|
||||
Activity.AddContentView(emptyView, View.LayoutParameters);
|
||||
}
|
||||
}
|
||||
else if(tracks.Count != 0)
|
||||
{
|
||||
@@ -472,12 +454,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
adapter.ItemClick += ListView_ItemClick;
|
||||
adapter.ItemLongClick += ListView_ItemLongClick;
|
||||
ListView.SetAdapter(adapter);
|
||||
|
||||
if (adapter == null || adapter.ItemCount == 0)
|
||||
{
|
||||
isEmpty = true;
|
||||
Activity.AddContentView(emptyView, View.LayoutParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,11 +708,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
adapter.Remove(item);
|
||||
tracks.Remove(item);
|
||||
result?.Remove(item);
|
||||
if (adapter == null || adapter.ItemCount == 0)
|
||||
{
|
||||
isEmpty = true;
|
||||
Activity.AddContentView(emptyView, View.LayoutParameters);
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveFromPlaylist(Song item)
|
||||
@@ -747,11 +718,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
adapter.Remove(item);
|
||||
tracks.Remove(item);
|
||||
result?.Remove(item);
|
||||
if (adapter == null || adapter.ItemCount == 0)
|
||||
{
|
||||
isEmpty = true;
|
||||
Activity.AddContentView(emptyView, View.LayoutParameters);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResume()
|
||||
|
||||
Generated
+19
-19
@@ -4267,61 +4267,61 @@ namespace MusicApp
|
||||
public const int EmptyLoadingLayout = 2130903086;
|
||||
|
||||
// aapt resource value: 0x7f03002f
|
||||
public const int EmptyYoutubeSearch = 2130903087;
|
||||
public const int EmptyView = 2130903087;
|
||||
|
||||
// aapt resource value: 0x7f030030
|
||||
public const int exo_list_divider = 2130903088;
|
||||
public const int EmptyYoutubeSearch = 2130903088;
|
||||
|
||||
// aapt resource value: 0x7f030031
|
||||
public const int exo_playback_control_view = 2130903089;
|
||||
public const int exo_list_divider = 2130903089;
|
||||
|
||||
// aapt resource value: 0x7f030032
|
||||
public const int exo_player_control_view = 2130903090;
|
||||
public const int exo_playback_control_view = 2130903090;
|
||||
|
||||
// aapt resource value: 0x7f030033
|
||||
public const int exo_player_view = 2130903091;
|
||||
public const int exo_player_control_view = 2130903091;
|
||||
|
||||
// aapt resource value: 0x7f030034
|
||||
public const int exo_simple_player_view = 2130903092;
|
||||
public const int exo_player_view = 2130903092;
|
||||
|
||||
// aapt resource value: 0x7f030035
|
||||
public const int exo_track_selection_dialog = 2130903093;
|
||||
public const int exo_simple_player_view = 2130903093;
|
||||
|
||||
// aapt resource value: 0x7f030036
|
||||
public const int folderList = 2130903094;
|
||||
public const int exo_track_selection_dialog = 2130903094;
|
||||
|
||||
// aapt resource value: 0x7f030037
|
||||
public const int HomeChannel = 2130903095;
|
||||
public const int folderList = 2130903095;
|
||||
|
||||
// aapt resource value: 0x7f030038
|
||||
public const int HomeChannels = 2130903096;
|
||||
public const int HomeChannel = 2130903096;
|
||||
|
||||
// aapt resource value: 0x7f030039
|
||||
public const int HomePlaylists = 2130903097;
|
||||
public const int HomeChannels = 2130903097;
|
||||
|
||||
// aapt resource value: 0x7f03003a
|
||||
public const int HomeTopic = 2130903098;
|
||||
public const int HomePlaylists = 2130903098;
|
||||
|
||||
// aapt resource value: 0x7f03003b
|
||||
public const int LineSong = 2130903099;
|
||||
public const int HomeTopic = 2130903099;
|
||||
|
||||
// aapt resource value: 0x7f03003c
|
||||
public const int LineSongs = 2130903100;
|
||||
public const int LineSong = 2130903100;
|
||||
|
||||
// aapt resource value: 0x7f03003d
|
||||
public const int ListPopupLayout = 2130903101;
|
||||
public const int LineSongs = 2130903101;
|
||||
|
||||
// aapt resource value: 0x7f03003e
|
||||
public const int LogOutButton = 2130903102;
|
||||
public const int ListPopupLayout = 2130903102;
|
||||
|
||||
// aapt resource value: 0x7f03003f
|
||||
public const int Main = 2130903103;
|
||||
public const int LogOutButton = 2130903103;
|
||||
|
||||
// aapt resource value: 0x7f030040
|
||||
public const int MusicLayout = 2130903104;
|
||||
public const int Main = 2130903104;
|
||||
|
||||
// aapt resource value: 0x7f030041
|
||||
public const int NoPlaylist = 2130903105;
|
||||
public const int MusicLayout = 2130903105;
|
||||
|
||||
// aapt resource value: 0x7f030042
|
||||
public const int NoQueue = 2130903106;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="50dp"
|
||||
android:textSize="15sp"
|
||||
android:gravity="center" />
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:text="This playlist is empty"
|
||||
android:gravity="center"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:id="@+id/noPlaylist"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent" />
|
||||
</LinearLayout>
|
||||
@@ -1,8 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:text="No playlist found on your youtube account"
|
||||
android:gravity="center"
|
||||
|
||||
@@ -4,10 +4,10 @@ using Android.Widget;
|
||||
|
||||
namespace MusicApp.Resources.values
|
||||
{
|
||||
public class EmptyCategoryHolder : RecyclerView.ViewHolder
|
||||
public class EmptyHolder : RecyclerView.ViewHolder
|
||||
{
|
||||
public TextView text;
|
||||
public EmptyCategoryHolder(View itemView) : base(itemView)
|
||||
public EmptyHolder(View itemView) : base(itemView)
|
||||
{
|
||||
text = (TextView)itemView;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user