зеркало из https://github.com/DeGsoft/maui-linux.git
Update BottomNavigationViewUtils.cs: removing redundant Dispose() calls (#5298)
* Update BottomNavigationViewUtils.cs Remove Dispose() and using statement as we don't destroy items. Casting objects to classes that implements IDisposable interface dosen't mean we need call Dispose() on them, and surely we don't want call it here. * Update BottomNavigationViewUtils.cs Fixed typo: removed closing parenthesis, added semicolon
This commit is contained in:
Родитель
a0fcf30bc3
Коммит
e120e7d15a
|
@ -24,46 +24,40 @@ namespace Xamarin.Forms.Platform.Android
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var menuView = bottomNavigationView.GetChildAt(0) as BottomNavigationMenuView)
|
||||
var menuView = bottomNavigationView.GetChildAt(0) as BottomNavigationMenuView;
|
||||
if (menuView == null)
|
||||
{
|
||||
if (menuView == null)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Unable to find BottomNavigationMenuView");
|
||||
return;
|
||||
}
|
||||
|
||||
#if __ANDROID_28__
|
||||
if (enableShiftMode)
|
||||
bottomNavigationView.LabelVisibilityMode = ALabelVisibilityMode.LabelVisibilityAuto;
|
||||
else
|
||||
bottomNavigationView.LabelVisibilityMode = ALabelVisibilityMode.LabelVisibilityLabeled;
|
||||
#else
|
||||
var shiftMode = menuView.Class.GetDeclaredField("mShiftingMode");
|
||||
shiftMode.Accessible = true;
|
||||
shiftMode.SetBoolean(menuView, enableShiftMode);
|
||||
shiftMode.Accessible = false;
|
||||
shiftMode.Dispose();
|
||||
#endif
|
||||
for (int i = 0; i < menuView.ChildCount; i++)
|
||||
{
|
||||
var child = menuView.GetChildAt(i);
|
||||
var item = child as BottomNavigationItemView;
|
||||
if (item != null)
|
||||
{
|
||||
#if __ANDROID_28__
|
||||
item.SetShifting(enableItemShiftMode);
|
||||
#else
|
||||
item.SetShiftingMode(enableItemShiftMode);
|
||||
#endif
|
||||
item.SetChecked(item.ItemData.IsChecked);
|
||||
}
|
||||
|
||||
child.Dispose();
|
||||
}
|
||||
|
||||
|
||||
menuView.UpdateMenuView();
|
||||
System.Diagnostics.Debug.WriteLine("Unable to find BottomNavigationMenuView");
|
||||
return;
|
||||
}
|
||||
|
||||
#if __ANDROID_28__
|
||||
if (enableShiftMode)
|
||||
bottomNavigationView.LabelVisibilityMode = ALabelVisibilityMode.LabelVisibilityAuto;
|
||||
else
|
||||
bottomNavigationView.LabelVisibilityMode = ALabelVisibilityMode.LabelVisibilityLabeled;
|
||||
#else
|
||||
var shiftMode = menuView.Class.GetDeclaredField("mShiftingMode");
|
||||
shiftMode.Accessible = true;
|
||||
shiftMode.SetBoolean(menuView, enableShiftMode);
|
||||
shiftMode.Accessible = false;
|
||||
shiftMode.Dispose();
|
||||
#endif
|
||||
for (int i = 0; i < menuView.ChildCount; i++)
|
||||
{
|
||||
var child = menuView.GetChildAt(i);
|
||||
var item = child as BottomNavigationItemView;
|
||||
if (item != null)
|
||||
{
|
||||
#if __ANDROID_28__
|
||||
item.SetShifting(enableItemShiftMode);
|
||||
#else
|
||||
item.SetShiftingMode(enableItemShiftMode);
|
||||
#endif
|
||||
item.SetChecked(item.ItemData.IsChecked);
|
||||
}
|
||||
}
|
||||
menuView.UpdateMenuView();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -71,4 +65,4 @@ namespace Xamarin.Forms.Platform.Android
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче