Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Compatibility/Core/src/Android/Cells/ViewCellRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ public void Update(ViewCell cell)
c.DisableLayout = false;

var viewAsLayout = cell.View as Layout;
if (viewAsLayout != null)
viewAsLayout.ForceLayout();
viewAsLayout?.ForceLayout();

Invalidate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,7 @@ protected override void UpdateItemSpacing()

var adapter = GetAdapter();

if (adapter != null)
{
adapter.NotifyItemChanged(_oldPosition);
}
adapter?.NotifyItemChanged(_oldPosition);

base.UpdateItemSpacing();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,7 @@ void UpdateOrientation()
if (_container.Parent != this)
{
_container.RemoveFromParent();
if (_hScrollView != null)
_hScrollView.RemoveFromParent();
_hScrollView?.RemoveFromParent();
AddView(_container);
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/Compatibility/Core/src/Tizen/Forms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,11 @@ internal static TizenTitleBarVisibility TitleBarVisibility
internal static void SendViewInitialized(this VisualElement self, NView nativeView)
{
EventHandler<ViewInitializedEventArgs> viewInitialized = Forms.ViewInitialized;
if (viewInitialized != null)
{
viewInitialized.Invoke(self, new ViewInitializedEventArgs
viewInitialized?.Invoke(self, new ViewInitializedEventArgs
{
View = self,
NativeView = nativeView
});
}
}

public static bool IsInitializedRenderers { get; private set; }
Expand Down
15 changes: 3 additions & 12 deletions src/Compatibility/Core/src/Tizen/FormsApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,19 @@ protected override void OnPreCreate()
protected override void OnTerminate()
{
base.OnTerminate();
if (_platform != null)
{
_platform.Dispose();
}
_platform?.Dispose();
}

protected override void OnPause()
{
base.OnPause();
if (_application != null)
{
_application.SendSleep();
}
_application?.SendSleep();
}

protected override void OnResume()
{
base.OnResume();
if (_application != null)
{
_application.SendResume();
}
_application?.SendResume();
}

[EditorBrowsable(EditorBrowsableState.Never)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,21 +599,15 @@ protected virtual void UpdateOpacity(bool initialize)
/// </summary>
protected virtual void OnFocused(object sender, EventArgs e)
{
if (null != Element)
{
Element.SetValue(VisualElement.IsFocusedPropertyKey, true);
}
Element?.SetValue(VisualElement.IsFocusedPropertyKey, true);
}

/// <summary>
/// Handles unfocus events.
/// </summary>
protected virtual void OnUnfocused(object sender, EventArgs e)
{
if (null != Element)
{
Element.SetValue(VisualElement.IsFocusedPropertyKey, false);
}
Element?.SetValue(VisualElement.IsFocusedPropertyKey, false);
}

/// <summary>
Expand Down
5 changes: 1 addition & 4 deletions src/Compatibility/Core/src/Windows/CellControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ protected FrameworkElement CellContent
// Children still need measure called on them
global::Windows.Foundation.Size result = base.MeasureOverride(availableSize);

if (lv != null)
{
lv.SetValue(MeasuredEstimateProperty, result.Height);
}
lv?.SetValue(MeasuredEstimateProperty, result.Height);

SetDefaultSwitchColor();

Expand Down
3 changes: 1 addition & 2 deletions src/Compatibility/Core/src/Windows/FlyoutPageControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ protected override void OnApplyTemplate()

UpdateMode();

if (_commandBarTcs != null)
_commandBarTcs.SetResult(_commandBar);
_commandBarTcs?.SetResult(_commandBar);

_titleViewManager = new TitleViewManager(this);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Compatibility/Core/src/Windows/FlyoutPageRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ protected VisualElementTracker<Page, FrameworkElement> Tracker
if (_tracker == value)
return;

if (_tracker != null)
_tracker.Dispose();
_tracker?.Dispose();

_tracker = value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ void OnTapped(object sender, TappedRoutedEventArgs tappedRoutedEventArgs)
zoom.ToggleActiveView();

var grid = zoom.ZoomedOutView as GridView;
if (grid != null)
{
grid.MakeVisible(new SemanticZoomLocation { Item = DataContext });
}
grid?.MakeVisible(new SemanticZoomLocation { Item = DataContext });

return;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Compatibility/Core/src/Windows/NavigationPageRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ protected VisualElementTracker<Page, PageControl> Tracker
if (_tracker == value)
return;

if (_tracker != null)
_tracker.Dispose();
_tracker?.Dispose();

_tracker = value;
}
Expand Down
6 changes: 2 additions & 4 deletions src/Compatibility/Core/src/Windows/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@ void RemovePage(Page page)
if (_container == null || page == null)
return;

if (_modalBackgroundPage != null)
_modalBackgroundPage.GetCurrentPage()?.SendAppearing();
_modalBackgroundPage?.GetCurrentPage()?.SendAppearing();

IVisualElementRenderer pageRenderer = GetRenderer(page);

Expand All @@ -449,8 +448,7 @@ void AddPage(Page page)
if (_container == null || page == null)
return;

if (_modalBackgroundPage != null)
_modalBackgroundPage.GetCurrentPage()?.SendDisappearing();
_modalBackgroundPage?.GetCurrentPage()?.SendDisappearing();



Expand Down
8 changes: 3 additions & 5 deletions src/Compatibility/Core/src/Windows/ScrollViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ void CleanUp(ScrollView scrollView, ScrollViewer scrollViewer)
}
}

if (_currentView != null)
_currentView.Cleanup();
_currentView?.Cleanup();
}

protected override void OnElementChanged(ElementChangedEventArgs<ScrollView> e)
Expand Down Expand Up @@ -130,8 +129,7 @@ protected void OnContentElementPropertyChanged(object sender, PropertyChangedEve

void UpdateContent()
{
if (_currentView != null)
_currentView.Cleanup();
_currentView?.Cleanup();

if (Control?.Content is FrameworkElement oldElement)
{
Expand All @@ -148,7 +146,7 @@ void UpdateContent()
if (_currentView != null)
renderer = _currentView.GetOrCreateRenderer();

Control.Content = renderer != null ? renderer.ContainerElement : null;
Control.Content = renderer?.ContainerElement;

UpdateContentMargins();
if (renderer?.Element != null)
Expand Down
3 changes: 1 addition & 2 deletions src/Compatibility/Core/src/Windows/Shapes/ShapeRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ void UpdateStrokeThickness()

void UpdateStrokeDashArray()
{
if (Control.StrokeDashArray != null)
Control.StrokeDashArray.Clear();
Control.StrokeDashArray?.Clear();

if (Element.StrokeDashArray != null && Element.StrokeDashArray.Count > 0)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Compatibility/Core/src/Windows/TabbedPageRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ protected VisualElementTracker<Page, Pivot> Tracker
if (_tracker == value)
return;

if (_tracker != null)
_tracker.Dispose();
_tracker?.Dispose();

_tracker = value;
}
Expand Down
8 changes: 2 additions & 6 deletions src/Compatibility/Core/src/Windows/VisualElementRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ public void SetElement(VisualElement element)
// and may cause issues
//Loaded += (sender, args) =>
//{
if (Packager != null)
Packager.Load();
Packager?.Load();
//};
}

Expand Down Expand Up @@ -201,10 +200,7 @@ event EventHandler IVisualNativeElementRenderer.ControlChanged

var myRect = new WRect(0, 0, finalSize.Width, finalSize.Height);

if (Control != null)
{
Control.Arrange(myRect);
}
Control?.Arrange(myRect);

List<UIElement> arrangedChildren = null;
for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
Expand Down
3 changes: 1 addition & 2 deletions src/Compatibility/Core/src/Windows/WebViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ void SyncNativeCookies(string url)

void Load()
{
if (Element.Source != null)
Element.Source.Load(this);
Element.Source?.Load(this);

UpdateCanGoBackForward();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Compatibility/Core/src/iOS/Cells/CellTableViewCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ internal static UITableViewCell GetNativeCell(UITableView tableView, Cell cell,
}

// Because the layer was hidden we need to layout the cell by hand
if (cellWithContent != null)
cellWithContent.LayoutSubviews();
cellWithContent?.LayoutSubviews();

return nativeCell;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ protected virtual void UpdateLayout()
{
_layout = SelectLayout();

if (Controller != null)
{
Controller.UpdateLayout(_layout);
}
Controller?.UpdateLayout(_layout);
}

protected virtual void UpdateItemSizingStrategy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ internal void UpdateSubview(object view, DataTemplate viewTemplate, nint viewTag
RemeasureLayout(formsElement);
formsElement.MeasureInvalidated += OnFormsElementMeasureInvalidated;
}
else if (uiView != null)
else
{
uiView.SizeToFit();
uiView?.SizeToFit();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
[PortHandler]
void UpdateColor()
{
Control.Color = Element.Color == null ? null : Element.Color.ToPlatform();
Control.Color = Element.Color?.ToPlatform();
}

[PortHandler]
Expand Down
2 changes: 1 addition & 1 deletion src/Compatibility/Core/src/iOS/Renderers/ButtonRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected override void SetBackground(Brush brush)
if (Control == null)
return;

UIColor backgroundColor = Element.BackgroundColor == null ? null : Element.BackgroundColor.ToPlatform();
UIColor backgroundColor = Element.BackgroundColor?.ToPlatform();

if (!Brush.IsNullOrEmpty(brush))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public void SetElement(VisualElement element)

OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

if (element != null)
element.SendViewInitialized(NativeView);
element?.SendViewInitialized(NativeView);

_previousPage = Carousel?.CurrentPage;
}
Expand Down
6 changes: 2 additions & 4 deletions src/Compatibility/Core/src/iOS/Renderers/ListViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,7 @@ void UpdateHeader()
void UpdateIsRefreshing()
{
var refreshing = Element.IsRefreshing;
if (_tableViewController != null)
_tableViewController.UpdateIsRefreshing(refreshing);
_tableViewController?.UpdateIsRefreshing(refreshing);
}

void UpdateItems(NotifyCollectionChangedEventArgs e, int section, bool resetWhenGrouped)
Expand Down Expand Up @@ -779,8 +778,7 @@ void UpdateSpinnerColor()
{
var color = Element.RefreshControlColor;

if (_tableViewController != null)
_tableViewController.UpdateRefreshControlColor(color?.ToPlatform());
_tableViewController?.UpdateRefreshControlColor(color?.ToPlatform());
}

void UpdateVerticalScrollBarVisibility()
Expand Down
12 changes: 4 additions & 8 deletions src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public void SetElement(VisualElement element)
Element = element;
OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

if (element != null)
element.SendViewInitialized(NativeView);
element?.SendViewInitialized(NativeView);

EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);
}
Expand Down Expand Up @@ -271,8 +270,7 @@ protected override void Dispose(bool disposing)
foreach (var childViewController in ViewControllers)
childViewController.Dispose();

if (_tracker != null)
_tracker.Dispose();
_tracker?.Dispose();

_secondaryToolbar.RemoveFromSuperview();
_secondaryToolbar.Dispose();
Expand Down Expand Up @@ -1420,8 +1418,7 @@ void UpdateToolbarItems()
(primaries = primaries ?? new List<UIBarButtonItem>()).Add(item.ToUIBarButtonItem());
}

if (primaries != null)
primaries.Reverse();
primaries?.Reverse();
NavigationItem.SetRightBarButtonItems(primaries == null ? Array.Empty<UIBarButtonItem>() : primaries.ToArray(), false);
ToolbarItems = secondaries == null ? Array.Empty<UIBarButtonItem>() : secondaries.ToArray();

Expand Down Expand Up @@ -1656,8 +1653,7 @@ public UIImageView Icon
{
set
{
if (_icon != null)
_icon.RemoveFromSuperview();
_icon?.RemoveFromSuperview();

_icon = value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public void SetElement(VisualElement element)

EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);

if (element != null)
element.SendViewInitialized(NativeView);
element?.SendViewInitialized(NativeView);
}

public void SetElementSize(Size size)
Expand Down
Loading
Loading