using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using Shared;
|
using Shared.SimpleControl;
|
using Shared.SimpleControl.Phone.Music;
|
using Shared.SimpleControl.R;
|
|
namespace SmartHome.UI.SimpleControl.Phone.Music
|
{
|
class A31TidalSearchTrackPage : FrameLayout
|
{
|
public override void RemoveFromParent ()
|
{
|
base.RemoveFromParent ();
|
isExit = true;
|
}
|
public void Show ()
|
{
|
AddChidren (new Button {
|
Height = Application.GetRealHeight (36),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
});
|
|
var topFrameLayout = new FrameLayout {
|
Height = Application.GetRealHeight (100),
|
Y = Application.GetRealHeight (36),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
AddChidren (topFrameLayout);
|
|
var LocallistName = new Button {
|
Text =Language.StringByID(MyInternationalizationString.search).ToUpper(),
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
topFrameLayout.AddChidren (LocallistName);
|
|
var back = new Button {
|
Width = Application.GetRealWidth (82),
|
Height = Application.GetRealHeight (89),
|
X = Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/HomepageBack.png",
|
};
|
topFrameLayout.AddChidren (back);
|
back.MouseDownEventHandler += (sender, e) => {
|
RemoveFromParent ();
|
};
|
|
var searchfl = new FrameLayout {
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.MusicMiddleBackgroundColor,
|
Y = topFrameLayout.Bottom,
|
};
|
AddChidren (searchfl);
|
|
var middle = new VerticalScrolViewLayout ();
|
middle.Y = searchfl.Bottom;
|
middle.Height = Application.GetRealHeight (Application.DesignHeight - 136 - 80);
|
BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout;
|
AddChidren (middle);
|
|
//搜索音乐
|
var search = new EditText {
|
Width = Application.GetRealWidth (520),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (25),
|
Y = Application.GetRealHeight (10),
|
TextAlignment = TextAlignment.CenterLeft,
|
Radius = (uint)Application.GetRealHeight (6),
|
PlaceholderText = "关键字",
|
BackgroundColor = SkinStyle.Current.MusicEditTextBackgroundColor,
|
PlaceholderTextColor = SkinStyle.Current.MusicEditTextPlaceholderTextColor,
|
TextColor = SkinStyle.Current.MusicTextColor,
|
BorderWidth = 2,
|
BorderColor = SkinStyle.Current.MusicEditBorderColor,
|
};
|
searchfl.AddChidren (search);
|
|
var seek = new Button {
|
Width = Application.GetMinRealAverage (60),
|
Height = Application.GetMinRealAverage (80),
|
X = Application.GetRealWidth (555),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/seekdevice.png",
|
};
|
searchfl.AddChidren (seek);
|
|
seek.MouseUpEventHandler += (sender, e) => {
|
middle.RemoveAll ();
|
var text = search.Text;
|
var urlid = "tidal/search?q=" + text + "&t=tracks";
|
Tidal.ReadPlayList (urlid, () => {
|
Application.RunOnMainThread (() => {
|
RemoveFromParent ();
|
A31TidalLogin a31TidalLogin = new A31TidalLogin ();
|
MainPage.MainFrameLayout.AddChidren (a31TidalLogin);
|
a31TidalLogin.Show (A31MusicModel.Current);
|
});
|
}, (p) => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
var list = Tidal.TempMusicInfoList.FindAll ((obj) => obj.Tag.ToString () == p);
|
foreach (var musics in list) {
|
var row = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
|
};
|
middle.AddChidren (row);
|
var imageBtntrack = new Button {
|
Width = Application.GetRealWidth (61),
|
Height = Application.GetRealHeight (61),
|
X = Application.GetRealWidth (20),
|
Gravity = Gravity.CenterVertical,
|
Radius = (uint)Application.GetRealHeight (4),
|
UnSelectedImagePath = System.IO.File.Exists (musics.Image) ? musics.Image : "MusicIcon/musicplay1.png",
|
};
|
row.AddChidren (imageBtntrack);
|
|
var listmusic = new Button {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetRealHeight (50),
|
Text = musics.Title,
|
TextAlignment = TextAlignment.BottomLeft,
|
X = Application.GetRealWidth (100),
|
Tag = musics,
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
row.AddChidren (listmusic);
|
|
var artist = new Button {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetRealHeight (50),
|
TextAlignment = TextAlignment.TopLeft,
|
X = Application.GetRealWidth (100),
|
Y = listmusic.Bottom,
|
//TextColor = 0x75ffffff,
|
Text = musics.Artist,
|
Tag = musics,
|
TextColor = SkinStyle.Current.MusicArtistTextColor,
|
};
|
row.AddChidren (artist);
|
|
EventHandler<MouseEventArgs> TrackMusic = (sender1, e1) => {
|
row.BackgroundColor = 0xffFE5E00;
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
//移除当前控件界面
|
this.Parent.RemoveAt (this.Parent.ChildrenCount - 4);
|
this.Parent.RemoveAt (this.Parent.ChildrenCount - 3);
|
this.Parent.RemoveAt (this.Parent.ChildrenCount - 2);
|
this.RemoveFromParent ();
|
A31PlayMusicPage a31PlayMusicPage = new A31PlayMusicPage ();
|
MainPage.MainFrameLayout.AddChidren (a31PlayMusicPage);
|
a31PlayMusicPage.Show (new List<MusicInfo> ());
|
A31MusicModel.Current.A31PlayStatus.Title = listmusic.Text;
|
System.Threading.Tasks.Task.Run (() => {
|
A31NewPage.tidalpushList (listmusic.Tag as MusicInfo, list);
|
});
|
});
|
});
|
};
|
imageBtntrack.MouseUpEventHandler += TrackMusic;
|
listmusic.MouseUpEventHandler += TrackMusic;
|
artist.MouseUpEventHandler += TrackMusic;
|
}
|
|
System.Threading.Tasks.Task.Run (() => {
|
for (int i = 0; i < list.Count; i++) {
|
if (isExit) {
|
return;
|
}
|
Tidal.ReadRealUrl (list [i]);
|
}
|
});
|
});
|
|
});
|
|
};
|
|
}
|
bool isExit;
|
|
}
|
}
|