using Shared;
|
using System;
|
using HDL_ON.UI.Music;
|
using HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView;
|
|
using HDL_ON.UI.UI2.FuntionControlView.Aks.Entity;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock;
|
|
namespace HDL_ON.UI.UI2.FuntionControlView.Aks
|
{
|
/// <summary>
|
/// 影片详情界面
|
/// </summary>
|
public class DetailPage : FrameLayout
|
{
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="remoteControlEntity">遥控器对象</param>
|
/// <param name="movieLibrary">影片对象</param>
|
public DetailPage(RemoteControlEntity remoteControlEntity, MovieLibrary movieLibrary)
|
{
|
this.remoteControl = remoteControlEntity;
|
this.movieLibrary = movieLibrary;
|
//从缓存获取
|
this.movieLibraryInfo = AksCommonMethod.Current.GetMovieLibraryInfo(remoteControl.rcId + "_" + movieLibrary.movieId);
|
}
|
/// <summary>
|
/// 当前的遥控器对象
|
/// </summary>
|
RemoteControlEntity remoteControl;
|
/// <summary>
|
/// 影片详情
|
/// </summary>
|
MovieLibraryInfoEntity movieLibraryInfo;
|
|
/// <summary>
|
/// 头部布局
|
/// </summary>
|
private TopView topView;
|
|
/// <summary>
|
/// 立即播放
|
/// </summary>
|
Button btnPaly;
|
|
/// <summary>
|
/// 影片
|
/// </summary>
|
MovieLibrary movieLibrary;
|
|
/// <summary>
|
/// 年份
|
/// </summary>
|
Button btnYear;
|
/// <summary>
|
/// 地区
|
/// </summary>
|
Button btnRegion;
|
/// <summary>
|
/// 收藏
|
/// </summary>
|
Button btnCollectImage;
|
Button btnCollectText;
|
/// <summary>
|
/// 电影简介内容
|
/// </summary>
|
Button btnIntroduceContent;
|
/// <summary>
|
/// 演员图片列表容器
|
/// </summary>
|
HorizontalScrolViewLayout horizontalFram;
|
|
public Action<bool> action;
|
|
|
private bool isOldState;
|
|
|
public void Show()
|
{
|
//初始化UI
|
this.InitTop();
|
this.InitMiddle();
|
//初始化事件
|
this.EventListener();
|
//读取数据
|
ReadData();
|
|
}
|
/// <summary>
|
/// 初始化头部界面
|
/// </summary>
|
private void InitTop()
|
{
|
this.BackgroundColor = MusicColor.ViewColor;
|
this.topView = new TopView();
|
this.topView.setBtn.Visible = false;
|
this.topView.topNameBtn.TextID = StringId.yingpianjieshao;
|
this.AddChidren(topView.TopFLayoutView());
|
}
|
/// <summary>
|
/// 初始化中部界面
|
/// </summary>
|
private void InitMiddle()
|
{
|
var vv = new VerticalRefreshLayout
|
{
|
Y = topView.fLayout.Bottom,
|
Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
|
BackgroundColor = MusicColor.WhiteColor,
|
};
|
this.AddChidren(vv);
|
vv.BeginHeaderRefreshingAction += () =>
|
{
|
vv.EndHeaderRefreshing();
|
movieLibraryInfo = null;
|
ReadData();
|
};
|
|
BaseFramLayout baseFramLayout = new BaseFramLayout();
|
vv.AddChidren(baseFramLayout);
|
|
ImageView btnImage = new ImageView
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(16),
|
Width = Application.GetRealWidth(140),
|
Height = Application.GetRealHeight(180),
|
Radius = (uint)Application.GetRealHeight(12),
|
ImageBytes = movieLibrary.imageBytes,
|
};
|
baseFramLayout.AddChidren(btnImage);
|
//电影名称
|
Button btnName = new Button
|
{
|
X = btnImage.Right + Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(36),
|
Width = Application.GetRealWidth(178),
|
Height = Application.GetRealHeight(45),
|
Text = movieLibrary.name,
|
TextColor = MusicColor.TextColor,
|
TextSize = TextSize.Text16,
|
TextAlignment = TextAlignment.CenterLeft,
|
IsBold = true,
|
IsMoreLines = true,
|
};
|
baseFramLayout.AddChidren(btnName);
|
this.AdjustRealWidth(btnName, 178);
|
|
//年份
|
btnYear = new Button
|
{
|
X = btnImage.Right + Application.GetRealWidth(16),
|
Y = btnName.Bottom + Application.GetRealHeight(12),
|
Width = Application.GetRealWidth(34),
|
Height = Application.GetRealHeight(20),
|
TextColor = MusicColor.TextColor,
|
TextSize = TextSize.Text14,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = movieLibraryInfo == null ? "" : movieLibraryInfo.releaseDate,
|
};
|
baseFramLayout.AddChidren(btnYear);
|
this.AdjustRealWidth(btnYear, 34);
|
|
//"/"
|
Button btnSlope = new Button
|
{
|
X = btnYear.Right + Application.GetRealWidth(8),
|
Y = btnName.Bottom + Application.GetRealHeight(12),
|
Width = Application.GetRealWidth(34),
|
Height = Application.GetRealHeight(20),
|
Text = "/",
|
TextColor = MusicColor.LineColor,
|
TextSize = TextSize.Text14,
|
};
|
baseFramLayout.AddChidren(btnSlope);
|
|
//地区
|
btnRegion = new Button
|
{
|
X = btnSlope.Right + Application.GetRealWidth(8),
|
Y = btnName.Bottom + Application.GetRealHeight(12),
|
Width = Application.GetRealWidth(140),
|
Height = Application.GetRealHeight(20),
|
TextColor = MusicColor.TextColor,
|
TextSize = TextSize.Text14,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = movieLibraryInfo == null ? "" : movieLibraryInfo.area,
|
};
|
baseFramLayout.AddChidren(btnRegion);
|
this.AdjustRealWidth(btnRegion, 140);
|
|
|
//电影分数
|
Button btnGrade = new Button
|
{
|
X = btnImage.Right + Application.GetRealWidth(16),
|
Y = btnYear.Bottom + Application.GetRealHeight(20),
|
Width = Application.GetRealWidth(45),
|
Height = Application.GetRealHeight(43),
|
Text = movieLibraryInfo == null ? "" : movieLibraryInfo.rating,
|
TextSize = 32,
|
TextColor = MusicColor.TextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
IsBold = true,
|
};
|
baseFramLayout.AddChidren(btnGrade);
|
this.AdjustRealWidth(btnGrade, 45);
|
|
//
|
Button btnScore = new Button
|
{
|
X = btnGrade.Right + Application.GetRealWidth(8),
|
Y = btnYear.Bottom + Application.GetRealHeight(46),
|
Width = Application.GetRealWidth(26),
|
Height = Application.GetRealHeight(17),
|
TextID = StringId.pingfen,
|
TextColor = 0xffA5AEBC,
|
TextSize = TextSize.Text12,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
baseFramLayout.AddChidren(btnScore);
|
|
|
btnCollectImage = new Button
|
{
|
X = btnImage.Right + Application.GetRealWidth(167),
|
Y = btnRegion.Bottom + Application.GetRealHeight(12),
|
Width = Application.GetRealWidth(32),
|
Height = Application.GetRealWidth(32),
|
UnSelectedImagePath = "MusicIcon/collect.png",
|
SelectedImagePath = "MusicIcon/collectSelected.png",
|
IsSelected = movieLibraryInfo == null ? false : movieLibraryInfo.collect,
|
};
|
baseFramLayout.AddChidren(btnCollectImage);
|
|
|
btnCollectText = new Button
|
{
|
X = btnImage.Right + Application.GetRealWidth(169),
|
Y = btnCollectImage.Bottom + Application.GetRealHeight(2),
|
Width = Application.GetRealWidth(36),
|
Height = Application.GetRealHeight(17),
|
TextID = StringId.weishoucang,
|
TextColor = 0xffA5AEBC,
|
TextSize = TextSize.Text12,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
baseFramLayout.AddChidren(btnCollectText);
|
if (btnCollectImage.IsSelected) {
|
btnCollectText.TextID = StringId.yishoucang;
|
} else {
|
btnCollectText.TextID = StringId.weishoucang;
|
}
|
isOldState = btnCollectImage.IsSelected;
|
|
//电影简介
|
Button btnIntroduceTitle = new Button
|
{
|
X = Application.GetRealWidth(16),
|
Y = btnImage.Bottom + Application.GetRealHeight(28),
|
Width = Application.GetRealWidth(300),
|
Height = Application.GetRealHeight(23),
|
//TextID = StringId.,
|
Text = "电影简介",
|
TextColor = MusicColor.TextColor,
|
TextSize = TextSize.Text16,
|
TextAlignment = TextAlignment.CenterLeft,
|
IsBold = true,
|
};
|
baseFramLayout.AddChidren(btnIntroduceTitle);
|
|
|
//电影简介内容
|
btnIntroduceContent = new Button
|
{
|
X = Application.GetRealWidth(16),
|
Y = btnIntroduceTitle.Bottom + Application.GetRealHeight(12),
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(140),
|
//TextID = StringId.,
|
TextColor = MusicColor.TextCancelColor,
|
TextSize = TextSize.Text14,
|
TextAlignment = TextAlignment.TopLeft,
|
IsBold = true,
|
IsMoreLines = true,
|
Text = movieLibraryInfo == null ? "" : movieLibraryInfo.introduction,
|
};
|
baseFramLayout.AddChidren(btnIntroduceContent);
|
|
#region -----演员照片 名称------
|
//演员
|
Button btnActor = new Button
|
{
|
X = Application.GetRealWidth(16),
|
Y = btnIntroduceContent.Bottom + Application.GetRealHeight(28),
|
Width = Application.GetRealWidth(300),
|
Height = Application.GetRealHeight(23),
|
//TextID = StringId.yan,
|
Text = "演员",
|
TextColor = MusicColor.TextColor,
|
TextSize = TextSize.Text16,
|
TextAlignment = TextAlignment.CenterLeft,
|
IsBold = true,
|
};
|
baseFramLayout.AddChidren(btnActor);
|
|
|
horizontalFram = new HorizontalScrolViewLayout
|
{
|
Y = btnActor.Bottom + Application.GetRealHeight(12),
|
X = Application.GetRealWidth(16),
|
Height = Application.GetRealHeight(112),
|
Width = Application.GetRealWidth(375 - 16),
|
};
|
baseFramLayout.AddChidren(horizontalFram);
|
LoadActorPage();
|
|
#endregion
|
|
//立即播放
|
btnPaly = new Button
|
{
|
Y = horizontalFram.Bottom + Application.GetRealHeight(70),
|
Width = Application.GetRealWidth(220),
|
Height = Application.GetRealHeight(44),
|
TextID = StringId.lijibofang,
|
TextColor = MusicColor.WhiteColor,
|
TextSize = TextSize.Text16,
|
TextAlignment = TextAlignment.Center,
|
Gravity = Gravity.CenterHorizontal,
|
BackgroundColor = MusicColor.SelectedColor,
|
Radius = (uint)Application.GetRealHeight(22),
|
};
|
baseFramLayout.AddChidren(btnPaly);
|
|
baseFramLayout.AdjustRealHeight(37);
|
}
|
/// <summary>
|
/// 加载演员图片列表
|
/// </summary>
|
private void LoadActorPage()
|
{
|
if (this.movieLibraryInfo == null || this.movieLibraryInfo.actors.Count == 0)
|
{
|
return;
|
}
|
for (int i = 0; i < this.movieLibraryInfo.actors.Count; i++)
|
{
|
var actors = this.movieLibraryInfo.actors[i];
|
FrameLayout actorFrame = new FrameLayout
|
{
|
Height = Application.GetRealHeight(112),
|
Width = Application.GetRealWidth(72),
|
};
|
horizontalFram.AddChidren(actorFrame);
|
|
ImageView btnActorImage = new ImageView
|
{
|
Width = Application.GetRealWidth(72),
|
Height = Application.GetRealHeight(84),
|
Radius = (uint)Application.GetRealHeight(8),
|
ImageBytes = actors.imageBytes,
|
};
|
actorFrame.AddChidren(btnActorImage);
|
|
|
Button btnActorName = new Button
|
{
|
Y = btnActorImage.Bottom + Application.GetRealHeight(8),
|
Width = Application.GetRealWidth(72),
|
Height = Application.GetRealHeight(20),
|
TextSize = TextSize.Text14,
|
TextColor = MusicColor.TextColor,
|
TextAlignment = TextAlignment.Center,
|
IsMoreLines = true,
|
Text = actors.actorName,
|
};
|
actorFrame.AddChidren(btnActorName);
|
|
//间隔,弄个空的进去占位置
|
Button btnSpacing = new Button
|
{
|
Width = Application.GetRealWidth(8),
|
};
|
horizontalFram.AddChidren(btnSpacing);
|
}
|
}
|
|
/// <summary>
|
/// 注册事件
|
/// </summary>
|
private void EventListener()
|
{
|
//返回
|
this.topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
action?.Invoke(isOldState != btnCollectImage.IsSelected);
|
this.RemoveFromParent();
|
};
|
//立即播放
|
this.btnPaly.MouseUpEventHandler += (sender, e) =>
|
{
|
CommonMethod.Current.Loading.Start();
|
CommonMethod.Current.SunThread(() =>
|
{
|
try
|
{
|
SendMethod.Current.MovieLibraryPlay(remoteControl.deviceId, remoteControl.rcId, movieLibrary.movieId);
|
}
|
catch { }
|
finally
|
{
|
CommonMethod.Current.MainThread(() =>
|
{
|
CommonMethod.Current.Loading.Hide();
|
});
|
}
|
});
|
};
|
//收藏
|
EventHandler<MouseEventArgs> CollectClick = (sender, e) =>
|
{
|
btnCollectImage.IsSelected = !btnCollectImage.IsSelected;
|
if (btnCollectImage.IsSelected)
|
{
|
btnCollectText.TextID = StringId.yishoucang;
|
}
|
else
|
{
|
btnCollectText.TextID = StringId.weishoucang;
|
}
|
CommonMethod.Current.Loading.Start();
|
CommonMethod.Current.SunThread(() =>
|
{
|
try
|
{
|
var isBool = SendMethod.Current.IsCollect(remoteControl.deviceId, remoteControl.rcId, movieLibrary.movieId, btnCollectImage.IsSelected);
|
if (isBool)
|
{
|
//更新缓存数据
|
movieLibraryInfo.collect = btnCollectImage.IsSelected;
|
//成功后才更新缓存数据
|
if (btnCollectImage.IsSelected)
|
{
|
|
AksCommonMethod.Current.AddCollectMovie(movieLibrary);
|
}
|
else
|
{
|
AksCommonMethod.Current.DelCollectMovie(movieLibrary);
|
}
|
|
}
|
}
|
catch { }
|
finally
|
{
|
CommonMethod.Current.MainThread(() =>
|
{
|
CommonMethod.Current.Loading.Hide();
|
});
|
}
|
});
|
};
|
btnCollectImage.MouseUpEventHandler += CollectClick;
|
btnCollectText.MouseUpEventHandler += CollectClick;
|
|
}
|
|
/// <summary>
|
/// 初始数据
|
/// </summary>
|
private void ReadData()
|
{
|
if (this.movieLibraryInfo != null)
|
{
|
return;
|
}
|
|
|
|
CommonMethod.Current.Loading.Start();
|
CommonMethod.Current.SunThread(() =>
|
{
|
try
|
{
|
this.movieLibraryInfo = SendMethod.Current.GetMovieLibraryInfo(remoteControl.deviceId, remoteControl.rcId, movieLibrary.movieId);
|
if (movieLibraryInfo.actors.Count == 0)
|
{
|
return;
|
}
|
for (int i = 0; i < movieLibraryInfo.actors.Count; i++)
|
{
|
movieLibraryInfo.actors[i].imageBytes = SendMethod.Current.GetImage(movieLibraryInfo.actors[i].actorUrl);
|
}
|
}
|
catch { }
|
finally
|
{
|
CommonMethod.Current.MainThread(() =>
|
{
|
CommonMethod.Current.Loading.Hide();
|
btnYear.Text = movieLibraryInfo.releaseDate;
|
btnRegion.Text = movieLibraryInfo.area;
|
btnCollectImage.IsSelected = movieLibraryInfo.collect;
|
btnIntroduceContent.Text = movieLibraryInfo.introduction;
|
LoadActorPage();
|
AksCommonMethod.Current.AddMovieLibraryInfo(movieLibraryInfo);
|
});
|
}
|
});
|
}
|
/// <summary>
|
/// 重新计算button宽度
|
/// </summary>
|
/// <param name="button">控件</param>
|
/// <param name="widthMax">宽度最大最</param>
|
/// <param name="padding">内边距</param>
|
private void AdjustRealWidth(Button button, int widthMax = 0, int padding = 0)
|
{
|
if (button == null)
|
{
|
return;
|
}
|
int width;
|
if (widthMax == 0)
|
{
|
//内边距
|
width = button.GetTextWidth() + Application.GetRealWidth(padding * 2);
|
}
|
else
|
{
|
if (button.GetTextWidth() > Application.GetRealWidth(widthMax))
|
{
|
|
width = Application.GetRealWidth(widthMax);
|
}
|
else
|
{
|
width = button.GetTextWidth();
|
}
|
|
}
|
|
button.Width = width;
|
}
|
}
|
}
|