Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 1a6cd0b

Browse files
committed
Added bindings for NestedScrollingEnabled override
See https://bugzilla.xamarin.com/show_bug.cgi?id=60052 for more info. Basically, we’re having some issues at runtime on API < 21 with setNestedScrollingEnabled and isNestedScrollingEnabled since we compile the bindings themselves against > API 21 where View has these methods (they didn’t get introduced until API 21), so our generator does not emit override methods on RecyclerView for them, and when we lookup the jmethodID at runtime on API < 21, the methods don’t exist and we hit a missing method exception. The fix here is to manually add the RecyclerView binding overrides.
1 parent 252bd60 commit 1a6cd0b

File tree

1 file changed

+57
-26
lines changed

1 file changed

+57
-26
lines changed
Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,61 @@
11
using System;
2+
using Android.Runtime;
3+
24
namespace Android.Support.V7.Widget
3-
//.RecyclerView.RequestDisallowInterceptTouchEventEventArgs
45
{
5-
public partial class RecyclerView
6-
{
7-
public partial class InterceptTouchEventEventArgs
8-
{
9-
public RecyclerView RecyclerView {
10-
get { return this.Rv; }
11-
}
12-
}
13-
14-
public partial class RequestDisallowInterceptTouchEventEventArgs
15-
{
16-
public bool Disallow
17-
{
18-
get { return this.DisallowIntercept; }
19-
}
20-
}
21-
22-
public partial class TouchEventEventArgs
23-
{
24-
public RecyclerView RecyclerView
25-
{
26-
get { return this.Rv; }
27-
}
28-
}
29-
}
6+
public partial class RecyclerView
7+
{
8+
public partial class InterceptTouchEventEventArgs
9+
{
10+
public RecyclerView RecyclerView {
11+
get { return this.Rv; }
12+
}
13+
}
14+
15+
public partial class RequestDisallowInterceptTouchEventEventArgs
16+
{
17+
public bool Disallow {
18+
get { return this.DisallowIntercept; }
19+
}
20+
}
21+
22+
public partial class TouchEventEventArgs
23+
{
24+
public RecyclerView RecyclerView {
25+
get { return this.Rv; }
26+
}
27+
}
28+
29+
private static IntPtr id_isNestedScrollingEnabled = IntPtr.Zero;
30+
private static IntPtr id_setNestedScrollingEnabled = IntPtr.Zero;
31+
32+
public unsafe virtual bool NestedScrollingEnabled {
33+
[Register("isNestedScrollingEnabled", "()Z", "GetIsNestedScrollingEnabledHandler")]
34+
get {
35+
if (id_isNestedScrollingEnabled == IntPtr.Zero) {
36+
id_isNestedScrollingEnabled = JNIEnv.GetMethodID(class_ref, "isNestedScrollingEnabled", "()Z");
37+
}
38+
if (base.GetType() == ThresholdType) {
39+
return JNIEnv.CallBooleanMethod(base.Handle, id_isNestedScrollingEnabled);
40+
}
41+
return JNIEnv.CallNonvirtualBooleanMethod(base.Handle, ThresholdClass, JNIEnv.GetMethodID(ThresholdClass, "isNestedScrollingEnabled", "()Z"));
42+
}
43+
44+
[Register("setNestedScrollingEnabled", "(Z)V", "GetSetNestedScrollingEnabledHandler")]
45+
set {
46+
if (id_setNestedScrollingEnabled == IntPtr.Zero) {
47+
id_setNestedScrollingEnabled = JNIEnv.GetMethodID(class_ref, "setNestedScrollingEnabled", "(Z)V");
48+
}
49+
JValue* ptr = stackalloc JValue[1];
50+
*ptr = new JValue(value);
51+
if (base.GetType() == ThresholdType) {
52+
JNIEnv.CallVoidMethod(base.Handle, id_setNestedScrollingEnabled, ptr);
53+
return;
54+
}
55+
JNIEnv.CallNonvirtualVoidMethod(base.Handle, ThresholdClass, JNIEnv.GetMethodID(ThresholdClass, "setNestedScrollingEnabled", "(Z)V"), ptr);
56+
}
57+
}
58+
59+
60+
}
3061
}

0 commit comments

Comments
 (0)