Skip to content

Commit f90133a

Browse files
committed
[Mono.Android] Remove usages of JNINativeWrapper.CreateDelegate.
1 parent 18af3ac commit f90133a

File tree

2 files changed

+59
-62
lines changed

2 files changed

+59
-62
lines changed
Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
1-
#if ANDROID_11
2-
31
using System;
2+
using Java.Interop;
43
using Android.Runtime;
54

65
namespace Android.Animation
76
{
87
public partial class AnimatorSet
98
{
10-
private static IntPtr id_setDuration_J;
9+
static Delegate cb_setDuration_SetDuration_J_Landroid_animation_Animator_;
10+
1111
[Register ("setDuration", "(J)Landroid/animation/Animator;", "GetSetDuration_JHandler")]
12-
public override Animator SetDuration (long duration)
12+
public override unsafe Android.Animation.Animator SetDuration (long duration)
1313
{
14-
if (id_setDuration_J == IntPtr.Zero)
15-
id_setDuration_J = JNIEnv.GetMethodID (class_ref, "setDuration", "(J)Landroid/animation/Animator;");
16-
17-
if (base.GetType () == this.ThresholdType) {
18-
return Java.Lang.Object.GetObject<AnimatorSet> (
19-
JNIEnv.CallObjectMethod (base.Handle, id_setDuration_J, new JValue (duration)),
20-
JniHandleOwnership.TransferLocalRef)!;
21-
} else {
22-
return Java.Lang.Object.GetObject<AnimatorSet> (
23-
JNIEnv.CallNonvirtualObjectMethod (
24-
base.Handle,
25-
this.ThresholdClass,
26-
JNIEnv.GetMethodID (ThresholdClass, "setDuration", "(J)Landroid/animation/Animator;"),
27-
new JValue (duration)),
28-
JniHandleOwnership.TransferLocalRef)!;
14+
const string __id = "setDuration.(J)Landroid/animation/Animator;";
15+
try {
16+
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
17+
__args [0] = new JniArgumentValue (duration);
18+
var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, __args);
19+
return global::Java.Lang.Object.GetObject<Android.Animation.Animator> (__rm.Handle, JniHandleOwnership.TransferLocalRef);
20+
} finally {
2921
}
3022
}
3123

32-
private static Delegate? cb_setDuration_J;
33-
34-
private static Delegate GetSetDuration_JHandler ()
24+
#pragma warning disable 0169
25+
static Delegate GetSetDuration_JHandler ()
3526
{
36-
if (cb_setDuration_J == null)
37-
cb_setDuration_J = JNINativeWrapper.CreateDelegate (new Func<IntPtr, IntPtr, long, IntPtr> (n_SetDuration_J));
38-
return cb_setDuration_J;
27+
return cb_setDuration_SetDuration_J_Landroid_animation_Animator_ ??= new _JniMarshal_PPJ_L (n_SetDuration_J);
3928
}
40-
41-
private static IntPtr n_SetDuration_J (IntPtr jnienv, IntPtr native__this, long duration)
29+
30+
[global::System.Diagnostics.DebuggerDisableUserUnhandledExceptions]
31+
static IntPtr n_SetDuration_J (IntPtr jnienv, IntPtr native__this, long duration)
4232
{
43-
AnimatorSet @object = Java.Lang.Object.GetObject<AnimatorSet> (native__this, JniHandleOwnership.DoNotTransfer)!;
44-
return JNIEnv.ToJniHandle (@object.SetDuration (duration));
33+
if (!global::Java.Interop.JniEnvironment.BeginMarshalMethod (jnienv, out var __envp, out var __r))
34+
return default;
35+
36+
try {
37+
var __this = global::Java.Lang.Object.GetObject<Android.Animation.AnimatorSet> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);
38+
return JNIEnv.ToLocalJniHandle (__this.SetDuration (duration));
39+
} catch (global::System.Exception __e) {
40+
__r.OnUserUnhandledException (ref __envp, __e);
41+
return default;
42+
} finally {
43+
global::Java.Interop.JniEnvironment.EndMarshalMethod (ref __envp);
44+
}
4545
}
46+
#pragma warning restore 0169
4647
}
4748
}
48-
49-
#endif
Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,48 @@
1-
#if ANDROID_11
2-
31
using System;
2+
using Java.Interop;
43
using Android.Runtime;
54

65
namespace Android.Animation
76
{
87
public partial class ValueAnimator
98
{
10-
private static IntPtr id_setDuration_J;
9+
static Delegate cb_setDuration_SetDuration_J_Landroid_animation_Animator_;
1110

1211
[Register ("setDuration", "(J)Landroid/animation/Animator;", "GetSetDuration_JHandler")]
13-
public override Animator SetDuration (long duration)
12+
public override unsafe Android.Animation.Animator SetDuration (long duration)
1413
{
15-
if (id_setDuration_J == IntPtr.Zero)
16-
id_setDuration_J = JNIEnv.GetMethodID (class_ref, "setDuration", "(J)Landroid/animation/Animator;");
17-
18-
if (base.GetType () == this.ThresholdType) {
19-
return Java.Lang.Object.GetObject<ValueAnimator> (
20-
JNIEnv.CallObjectMethod (base.Handle, id_setDuration_J, new JValue (duration)),
21-
JniHandleOwnership.TransferLocalRef)!;
22-
} else {
23-
return Java.Lang.Object.GetObject<ValueAnimator> (
24-
JNIEnv.CallNonvirtualObjectMethod (
25-
base.Handle,
26-
this.ThresholdClass,
27-
JNIEnv.GetMethodID (ThresholdClass, "setDuration", "(J)Landroid/animation/Animator;"),
28-
new JValue (duration)),
29-
JniHandleOwnership.TransferLocalRef)!;
14+
const string __id = "setDuration.(J)Landroid/animation/Animator;";
15+
try {
16+
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
17+
__args [0] = new JniArgumentValue (duration);
18+
var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, __args);
19+
return global::Java.Lang.Object.GetObject<Android.Animation.Animator> (__rm.Handle, JniHandleOwnership.TransferLocalRef);
20+
} finally {
3021
}
3122
}
3223

33-
private static Delegate? cb_setDuration_J;
34-
35-
private static Delegate GetSetDuration_JHandler ()
24+
#pragma warning disable 0169
25+
static Delegate GetSetDuration_JHandler ()
3626
{
37-
if (cb_setDuration_J == null)
38-
cb_setDuration_J = JNINativeWrapper.CreateDelegate (new Func<IntPtr, IntPtr, long, IntPtr> (n_SetDuration_J));
39-
return cb_setDuration_J;
27+
return cb_setDuration_SetDuration_J_Landroid_animation_Animator_ ??= new _JniMarshal_PPJ_L (n_SetDuration_J);
4028
}
41-
42-
private static IntPtr n_SetDuration_J (IntPtr jnienv, IntPtr native__this, long duration)
29+
30+
[global::System.Diagnostics.DebuggerDisableUserUnhandledExceptions]
31+
static IntPtr n_SetDuration_J (IntPtr jnienv, IntPtr native__this, long duration)
4332
{
44-
ValueAnimator @object = Java.Lang.Object.GetObject<ValueAnimator> (native__this, JniHandleOwnership.DoNotTransfer)!;
45-
return JNIEnv.ToJniHandle (@object.SetDuration (duration));
33+
if (!global::Java.Interop.JniEnvironment.BeginMarshalMethod (jnienv, out var __envp, out var __r))
34+
return default;
35+
36+
try {
37+
var __this = global::Java.Lang.Object.GetObject<Android.Animation.ValueAnimator> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);
38+
return JNIEnv.ToLocalJniHandle (__this.SetDuration (duration));
39+
} catch (global::System.Exception __e) {
40+
__r.OnUserUnhandledException (ref __envp, __e);
41+
return default;
42+
} finally {
43+
global::Java.Interop.JniEnvironment.EndMarshalMethod (ref __envp);
44+
}
4645
}
46+
#pragma warning restore 0169
4747
}
4848
}
49-
50-
#endif

0 commit comments

Comments
 (0)