make ugoira disposable
This commit is contained in:
parent
da8da3be4d
commit
2fe66d4f8d
@ -504,7 +504,7 @@ namespace Pixiview.Illust
|
|||||||
public abstract class IllustScrollableCollectionPage<T> : IllustCollectionPage<T>
|
public abstract class IllustScrollableCollectionPage<T> : IllustCollectionPage<T>
|
||||||
{
|
{
|
||||||
protected const int SCROLL_OFFSET = 33;
|
protected const int SCROLL_OFFSET = 33;
|
||||||
protected static readonly object sync = new object();
|
protected readonly object sync = new object();
|
||||||
|
|
||||||
private double lastScrollY = double.MinValue;
|
private double lastScrollY = double.MinValue;
|
||||||
private double offset;
|
private double offset;
|
||||||
|
@ -153,8 +153,10 @@ namespace Pixiview.Illust
|
|||||||
|
|
||||||
if (ugoira != null)
|
if (ugoira != null)
|
||||||
{
|
{
|
||||||
ugoira.TogglePlay(false);
|
|
||||||
IllustItem.IsPlaying = false;
|
IllustItem.IsPlaying = false;
|
||||||
|
ugoira.TogglePlay(false);
|
||||||
|
ugoira.Dispose();
|
||||||
|
ugoira = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saveFavorites)
|
if (saveFavorites)
|
||||||
|
@ -292,8 +292,10 @@ namespace Pixiview.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Ugoira
|
public class Ugoira : IDisposable
|
||||||
{
|
{
|
||||||
|
private readonly object sync = new object();
|
||||||
|
|
||||||
private readonly IllustUgoiraBody ugoira;
|
private readonly IllustUgoiraBody ugoira;
|
||||||
private readonly IllustDetailItem detailItem;
|
private readonly IllustDetailItem detailItem;
|
||||||
private readonly ImageSource[] frames;
|
private readonly ImageSource[] frames;
|
||||||
@ -315,21 +317,39 @@ namespace Pixiview.Utils
|
|||||||
Task.Run(LoadFrames);
|
Task.Run(LoadFrames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
lock (sync)
|
||||||
|
{
|
||||||
|
if (IsPlaying)
|
||||||
|
{
|
||||||
|
TogglePlay(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (timer != null)
|
||||||
|
{
|
||||||
|
timer.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void TogglePlay(bool flag)
|
public void TogglePlay(bool flag)
|
||||||
{
|
{
|
||||||
if (IsPlaying == flag)
|
lock (sync)
|
||||||
{
|
{
|
||||||
return;
|
if (IsPlaying == flag)
|
||||||
}
|
{
|
||||||
if (flag)
|
return;
|
||||||
{
|
}
|
||||||
IsPlaying = true;
|
if (flag)
|
||||||
timer.Change(0, Timeout.Infinite);
|
{
|
||||||
}
|
IsPlaying = true;
|
||||||
else
|
timer.Change(0, Timeout.Infinite);
|
||||||
{
|
}
|
||||||
IsPlaying = false;
|
else
|
||||||
timer.Change(Timeout.Infinite, Timeout.Infinite);
|
{
|
||||||
|
IsPlaying = false;
|
||||||
|
timer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,9 +379,12 @@ namespace Pixiview.Utils
|
|||||||
|
|
||||||
private void OnTimerCallback(object state)
|
private void OnTimerCallback(object state)
|
||||||
{
|
{
|
||||||
if (!IsPlaying)
|
lock (sync)
|
||||||
{
|
{
|
||||||
return;
|
if (!IsPlaying)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageSource frame;
|
ImageSource frame;
|
||||||
@ -384,7 +407,13 @@ namespace Pixiview.Utils
|
|||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
index = i;
|
index = i;
|
||||||
timer.Change(info.delay, Timeout.Infinite);
|
lock (sync)
|
||||||
|
{
|
||||||
|
if (IsPlaying)
|
||||||
|
{
|
||||||
|
timer.Change(info.delay, Timeout.Infinite);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private const int BUFFER_SIZE = 300000;
|
private const int BUFFER_SIZE = 300000;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user