Skip to content

Commit 62ae7b9

Browse files
committed
Add Hide Not Completed toggle
Adds an Hide Not Completed toggle in the Sorting menu. When turned on this hides all anime that haven't aired yet or are currently airing. This might mis some since the method for retrieving the air date is broken for anime that aren't airing, so it checks the total episodes count, and air date for airing anime.
1 parent 465c9fc commit 62ae7b9

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

MALClient.Android/Fragments/AnimeListPageFragment.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,15 @@ private void OpenSortingDrawer()
229229
descendingToggle.WithTextColorRes(ResourceExtension.BrushTextRes);
230230
items.Add(descendingToggle);
231231

232+
var hideCompletedToggle = new SwitchDrawerItem();
233+
hideCompletedToggle.WithName("Hide Not Completed");
234+
hideCompletedToggle.WithChecked(ViewModel.HideNotAired);
235+
hideCompletedToggle.WithOnCheckedChangeListener(
236+
new DrawerCheckedChangeListener(HideNotAiredToggleOnCheckedChange));
237+
hideCompletedToggle.WithIdentifier(998878);
238+
hideCompletedToggle.WithTextColorRes(ResourceExtension.BrushTextRes);
239+
items.Add(hideCompletedToggle);
240+
232241
RightDrawer.SetItems(items);
233242
RightDrawer.SetSelection((int)ViewModel.SortOption);
234243

@@ -244,6 +253,11 @@ private void OpenSortingDrawer()
244253
ViewModel.SortDescending = !ViewModel.SortDescending;
245254
ViewModel.RefreshList();
246255
}
256+
else if (arg3.Identifier == 998878)
257+
{
258+
ViewModel.HideNotAired = !ViewModel.HideNotAired;
259+
ViewModel.RefreshList();
260+
}
247261
else
248262
{
249263
ViewModel.SetSortOrder((SortOptions)arg3.Identifier);
@@ -265,6 +279,12 @@ private void DescendingToggleOnCheckedChange(IDrawerItem item, bool check)
265279
ViewModel.RefreshList();
266280
}
267281

282+
private void HideNotAiredToggleOnCheckedChange(IDrawerItem item, bool check)
283+
{
284+
ViewModel.HideNotAired = check;
285+
ViewModel.RefreshList();
286+
}
287+
268288
private void OpenViewModeDrawer()
269289
{
270290
var f1 = HamburgerUtilities.GetBaseSecondaryItem();

MALClient.Mobile/Pages/Main/AnimeListPage.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
<ToggleMenuFlyoutItem x:Name="SortNone" Text="None" Click="SelectSortMode" Style="{StaticResource SortBtnStyle}"/>
146146
<MenuFlyoutSeparator Margin="-90,0,0,0" Width="150"/>
147147
<ToggleMenuFlyoutItem x:Name="BtnOrderDescending" Text="Descending" Click="ChangeSortOrder" Style="{StaticResource SortBtnStyle}"/>
148+
<ToggleMenuFlyoutItem x:Name="BtnHideUncompleted" Text="Uncompleted" Click="ChangeSortOrder" Style="{StaticResource SortBtnStyle}"/>
148149
</MenuFlyout>
149150
</AppBarButton.Flyout>
150151
</AppBarButton>

MALClient.XShared/NavArgs/AnimeListPageNavigationArgs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class AnimeListPageNavigationArgs
1010
public int SelectedItemIndex = -1;
1111
public bool ResetBackNav = true;
1212
public readonly bool Descending;
13+
public readonly bool HideNotAired;
1314
public readonly bool NavArgs;
1415
public readonly int Status;
1516
public readonly int? StatusIndex;

MALClient.XShared/ViewModels/Main/AnimeListViewModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,10 @@ public async void RefreshList(bool searchSource = false, bool fakeDelay = false)
444444

445445
items = items.Where(item => status == AnimeStatus.AllOrAiring || item.MyStatus == status || (item.IsRewatching && status == AnimeStatus.Watching));
446446

447-
if(!queryCondition)
447+
if (HideNotAired)
448+
items = items.Where(item => item.AirDay == -1 && item.AllEpisodes != 0);
449+
450+
if (!queryCondition)
448451
_prevAnimeStatus = status;
449452

450453
if (queryCondition)

MALClient.XShared/ViewModels/Main/AnimeListViewModels.ui.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,18 @@ public bool SortDescending
280280
}
281281
}
282282

283+
private bool _hideNotAired;
284+
285+
public bool HideNotAired
286+
{
287+
get { return _hideNotAired; }
288+
set
289+
{
290+
_hideNotAired = value;
291+
RaisePropertyChanged(() => HideNotAired);
292+
}
293+
}
294+
283295
private string _sort3Label = "Watched";
284296

285297
public string Sort3Label

0 commit comments

Comments
 (0)