Skip to content
Open
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
21 changes: 18 additions & 3 deletions src/Mono.Android/Android.Views/LayoutInflater.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
using System;

using Android.Content;
using Android.Runtime;

namespace Android.Views {

public partial class LayoutInflater {

[Register ("from", "(Landroid/content/Context;)Landroid/view/LayoutInflater;", "")]
public static LayoutInflater? From (Context? context)
{
ArgumentNullException.ThrowIfNull (context);

return FromContext (context);
}

public static LayoutInflater? FromContext (Context context)
{
return context.GetSystemService (Context.LayoutInflaterService!) as LayoutInflater;
var service = context.GetSystemService (Context.LayoutInflaterService!);
Comment thread
simonrozsival marked this conversation as resolved.

if (service is LayoutInflater inflater)
return inflater;

if (service?.Handle != IntPtr.Zero)
return Java.Lang.Object.GetObject<LayoutInflater> (service.Handle, JniHandleOwnership.DoNotTransfer);

return null;
}
}
}


1 change: 1 addition & 0 deletions src/Mono.Android/metadata
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<!-- FIXME: hack to workaround api-merge bug that brings two identical methods (it doesn't care generic type params) -->
<remove-node path="/api/package[@name='android.animation']/interface[@name='TypeEvaluator']/method[@name='evaluate' and @merge.SourceFile]" />
<remove-node path="/api/package[@name='android.view']/class[@name='LayoutInflater']/method[@name='from' and parameter[1][@type='android.content.Context']]" />

<!-- FIXME: this should NOT be exposed as public, but needs to exist. -->
<attr api-since="5" api-until="8" path="/api/package[@name='java.util.concurrent.locks']/class[@name='AbstractOwnableSynchronizer']" name="visibility">public</attr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ public void From ()
// Remapped to "net/dot/android/test/MyLayoutInflater"
var from = LayoutInflater.From (Application.Context);
Assert.IsNotNull (from);

var fromContext = LayoutInflater.FromContext (Application.Context);
Assert.IsNotNull (fromContext);
}
}