dispose subscribers
This commit is contained in:
@@ -4,7 +4,7 @@ using TV_Player.ViewModels;
|
|||||||
|
|
||||||
namespace TV_Player
|
namespace TV_Player
|
||||||
{
|
{
|
||||||
public class ProgramsGroupViewModel : ObservableViewModelBase
|
public class ProgramsGroupViewModel : ObservableViewModelBase, IDisposable
|
||||||
{
|
{
|
||||||
private List<GroupInfo> _programs;
|
private List<GroupInfo> _programs;
|
||||||
public List<GroupInfo> Programs
|
public List<GroupInfo> Programs
|
||||||
@@ -15,12 +15,13 @@ namespace TV_Player
|
|||||||
|
|
||||||
public GroupInfo SelectedItem { get; set; }
|
public GroupInfo SelectedItem { get; set; }
|
||||||
public ICommand ItemSelectedCommand { get; }
|
public ICommand ItemSelectedCommand { get; }
|
||||||
|
public IDisposable _groupInformationSubscriber;
|
||||||
|
|
||||||
public ProgramsGroupViewModel()
|
public ProgramsGroupViewModel()
|
||||||
{
|
{
|
||||||
ItemSelectedCommand = new RelayCommand(OnItemSelected);
|
ItemSelectedCommand = new RelayCommand(OnItemSelected);
|
||||||
ProgramsData.Instance.GroupsInformation.Subscribe(x=>Programs = x);
|
_groupInformationSubscriber = ProgramsData.Instance.GroupsInformation.Subscribe(x=>Programs = x);
|
||||||
|
|
||||||
TVPlayerViewModel.Instance.TopPanelVisible(true, "Groups");
|
TVPlayerViewModel.Instance.TopPanelVisible(true, "Groups");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,5 +31,10 @@ namespace TV_Player
|
|||||||
var conrtrol = new ProgramsList();
|
var conrtrol = new ProgramsList();
|
||||||
TVPlayerViewModel.Instance.SetPageContext(conrtrol, programListViewModel);
|
TVPlayerViewModel.Instance.SetPageContext(conrtrol, programListViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_groupInformationSubscriber.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using TV_Player.ViewModels;
|
|||||||
|
|
||||||
namespace TV_Player
|
namespace TV_Player
|
||||||
{
|
{
|
||||||
public class ProgramsListViewModel : ObservableViewModelBase
|
public class ProgramsListViewModel : ObservableViewModelBase, IDisposable
|
||||||
{
|
{
|
||||||
private List<M3UInfo> _programs;
|
private List<M3UInfo> _programs;
|
||||||
public List<M3UInfo> Programs
|
public List<M3UInfo> Programs
|
||||||
@@ -15,12 +15,12 @@ namespace TV_Player
|
|||||||
|
|
||||||
public M3UInfo SelectedItem { get; set; }
|
public M3UInfo SelectedItem { get; set; }
|
||||||
public ICommand ItemSelectedCommand { get; }
|
public ICommand ItemSelectedCommand { get; }
|
||||||
|
private IDisposable _programSubscriber;
|
||||||
public ProgramsListViewModel(GroupInfo groupInfo)
|
public ProgramsListViewModel(GroupInfo groupInfo)
|
||||||
{
|
{
|
||||||
TVPlayerViewModel.Instance.TopPanelVisible(true, groupInfo.Name);
|
TVPlayerViewModel.Instance.TopPanelVisible(true, groupInfo.Name);
|
||||||
ItemSelectedCommand = new RelayCommand(OnItemSelected);
|
ItemSelectedCommand = new RelayCommand(OnItemSelected);
|
||||||
ProgramsData.Instance.AllPrograms.Subscribe(x => Programs = x.Where(p => p.GroupTitle == groupInfo.Name).ToList());
|
_programSubscriber = ProgramsData.Instance.AllPrograms.Subscribe(x => Programs = x.Where(p => p.GroupTitle == groupInfo.Name).ToList());
|
||||||
|
|
||||||
TVPlayerViewModel.Instance.SetBackButtonAction(new Action(() =>
|
TVPlayerViewModel.Instance.SetBackButtonAction(new Action(() =>
|
||||||
{
|
{
|
||||||
@@ -37,5 +37,10 @@ namespace TV_Player
|
|||||||
conrtrol.SourceUrl = SelectedItem.Url;
|
conrtrol.SourceUrl = SelectedItem.Url;
|
||||||
TVPlayerViewModel.Instance.SetPageContext(conrtrol, playerViewModel);
|
TVPlayerViewModel.Instance.SetPageContext(conrtrol, playerViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_programSubscriber.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user