fix: ranking page duplicate refresh

This commit is contained in:
Tsanie Lily 2020-05-15 02:14:47 +08:00
parent f83f533f5f
commit b5f19b0f30
14 changed files with 58 additions and 32 deletions

View File

@ -76,6 +76,7 @@
</u:SegmentedControl.Children>
</u:SegmentedControl>
<u:SegmentedControl Grid.Row="1" HorizontalOptions="Start"
IsVisible="{Binding SegmentTypeVisible}"
Margin="6, 3, 6, 6" VerticalOptions="Center"
SelectedSegmentIndex="{Binding SegmentType, Mode=TwoWay}"
SelectedTextColor="{DynamicResource TextColor}"

View File

@ -16,12 +16,14 @@ namespace Pixiview.Illust
public static readonly BindableProperty SegmentDateProperty = BindableProperty.Create(
nameof(SegmentDate), typeof(int), typeof(RankingPage), propertyChanged: OnSegmentDatePropertyChanged);
public static readonly BindableProperty SegmentTypeVisibleProperty = BindableProperty.Create(
nameof(SegmentTypeVisible), typeof(bool), typeof(RankingPage));
public static readonly BindableProperty SegmentTypeProperty = BindableProperty.Create(
nameof(SegmentType), typeof(int), typeof(RankingPage), propertyChanged: OnSegmentTypePropertyChanged);
public static readonly BindableProperty MaximumDateProperty = BindableProperty.Create(
nameof(MaximumDate), typeof(DateTime), typeof(RankingPage), DateTime.Now);
nameof(MaximumDate), typeof(DateTime), typeof(RankingPage), DateTime.Today);
public static readonly BindableProperty SelectedDateProperty = BindableProperty.Create(
nameof(SelectedDate), typeof(DateTime), typeof(RankingPage), DateTime.Now);
nameof(SelectedDate), typeof(DateTime), typeof(RankingPage), DateTime.Today);
private static void OnSegmentDatePropertyChanged(BindableObject obj, object old, object @new)
{
@ -59,6 +61,11 @@ namespace Pixiview.Illust
get => (int)GetValue(SegmentDateProperty);
set => SetValue(SegmentDateProperty, value);
}
public bool SegmentTypeVisible
{
get => (bool)GetValue(SegmentTypeVisibleProperty);
set => SetValue(SegmentTypeVisibleProperty, value);
}
public int SegmentType
{
get => (int)GetValue(SegmentTypeProperty);
@ -97,17 +104,33 @@ namespace Pixiview.Illust
InitializeComponent();
gridFilter.TranslationY = -100;
panelFilter.TranslationY = -100;
}
public override void OnLoad()
{
// preferences
SegmentDate = Preferences.Get(Configs.QueryModeKey, 0);
SegmentType = Preferences.Get(Configs.QueryTypeKey, 0);
lastQueryKey = QueryKey;
queryDate = Preferences.Get(Configs.QueryDateKey, null);
currentPage = 1;
datePicker.MinimumDate = new DateTime(2007, 9, 13);
MaximumDate = DateTime.Now;
MaximumDate = DateTime.Today;
}
protected override void OnAppearing()
{
var r18 = Configs.IsOnR18;
if (!r18)
{
SegmentType = 0;
var query = QueryKey;
if (lastQueryKey != query)
{
ReleaseCollection();
lastQueryKey = query;
}
}
SegmentTypeVisible = r18;
base.OnAppearing();
}
protected override void OnDisappearing()
@ -243,17 +266,11 @@ namespace Pixiview.Illust
ToggleFilterPanel(false);
}
// release
var collection = IllustCollection;
if (collection != null)
{
collection.Running = false;
IllustCollection = null;
}
ReleaseCollection();
previousEnabled = false;
dateEnabled = false;
nextEnabled = false;
queryDate = date;
currentPage = 1;
StartLoad(true);
}
}
@ -273,22 +290,17 @@ namespace Pixiview.Illust
private void DatePicker_DateSelected(object sender, DateChangedEventArgs e)
{
if (IsLoading)
if (e.OldDate == DateTime.Today || IsLoading)
{
// first load or loading
return;
}
// release
var collection = IllustCollection;
if (collection != null)
{
collection.Running = false;
IllustCollection = null;
}
ReleaseCollection();
previousEnabled = false;
dateEnabled = false;
nextEnabled = false;
queryDate = e.NewDate.ToString("yyyyMMdd");
currentPage = 1;
StartLoad(true);
}
@ -342,17 +354,11 @@ namespace Pixiview.Illust
{
return;
}
if (lastQueryKey != query)
//if (lastQueryKey != query)
{
// release
var collection = IllustCollection;
if (collection != null)
{
collection.Running = false;
IllustCollection = null;
}
ReleaseCollection();
// query changed.
currentPage = 1;
lastQueryKey = query;
refresh = true;
App.DebugPrint($"query changed: {query}");
@ -363,5 +369,16 @@ namespace Pixiview.Illust
StartLoad(true);
}
}
private void ReleaseCollection()
{
var collection = IllustCollection;
if (collection != null)
{
collection.Running = false;
IllustCollection = null;
}
currentPage = 1;
}
}
}

View File

@ -92,6 +92,7 @@ namespace Pixiview.Illust
return new Grid
{
RowSpacing = 0,
ColumnSpacing = 0,
RowDefinitions =
{
new RowDefinition { Height = 40 },

View File

@ -148,6 +148,7 @@ namespace Pixiview.Illust
protected override void OnDisappearing()
{
Screen.SetHomeIndicatorAutoHidden(Shell.Current, false);
base.OnDisappearing();
if (ugoira != null)
@ -160,7 +161,6 @@ namespace Pixiview.Illust
{
Stores.SaveFavoritesIllusts();
}
Screen.SetHomeIndicatorAutoHidden(Shell.Current, false);
}
private DataTemplate GetCarouseTemplate(bool multiPages)

View File

@ -450,7 +450,7 @@ namespace Pixiview.Utils
public const string QueryTypeKey = "query_type";
public const string QueryDateKey = "query_date";
public const int MaxThreads = 3;
public const int MaxThreads = 6;
public const string Referer = "https://www.pixiv.net/";
public const string RefererIllust = "https://www.pixiv.net/artworks/{0}";
public const string RefererIllustRanking = "https://www.pixiv.net/ranking.php?{0}";

View File

@ -3,7 +3,14 @@ iOS/Android client app for [Pixiv.net](https://pixiv.net/).
## Screenshot
![screenshot](Res/screenshot.png)
|![screenshot](Res/screenshot.png)|![screenshot2](Res/screenshot2.png)|
|:-|:-|
|![screenshot3](Res/screenshot3.png)|![screenshot4](Res/screenshot4.png)|
|:-|:-|
|![screenshot5](Res/screenshot5.png)|![screenshot6](Res/screenshot6.png)|
|:-|:-|
|![screenshot7](Res/screenshot7.png)|![screenshot8](Res/screenshot8.png)|
## Dependencies

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 KiB

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
Res/screenshot2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

BIN
Res/screenshot3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
Res/screenshot4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
Res/screenshot5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
Res/screenshot6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
Res/screenshot7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
Res/screenshot8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 KiB