From 6a2013e982d78b5dd6c381c2da8e7be6fceb1b4e Mon Sep 17 00:00:00 2001 From: Kongzue Date: Tue, 26 Nov 2024 15:55:56 +0800 Subject: [PATCH] =?UTF-8?q?7.0.4.2=20-=20=E5=B0=9D=E8=AF=95=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=96=B0=E6=96=B9=E6=B3=95=E8=8E=B7=E5=8F=96ViewBindi?= =?UTF-8?q?ng=E5=AF=B9=E8=B1=A1=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/kongzue/baseframework/BaseBindingActivity.java | 3 ++- .../java/com/kongzue/baseframework/BaseBindingFragment.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/baseframework/src/main/java/com/kongzue/baseframework/BaseBindingActivity.java b/baseframework/src/main/java/com/kongzue/baseframework/BaseBindingActivity.java index 80a565c..51bd8e8 100644 --- a/baseframework/src/main/java/com/kongzue/baseframework/BaseBindingActivity.java +++ b/baseframework/src/main/java/com/kongzue/baseframework/BaseBindingActivity.java @@ -38,7 +38,8 @@ private View userDataBindingCreateLayout() { Type type = parameterizedType.getActualTypeArguments()[0]; try { Class clazz = (Class) type; - binding = (VB) clazz.getMethod("inflate", getLayoutInflater().getClass()).invoke(null, getLayoutInflater()); + LayoutInflater layoutInflater = LayoutInflater.from(this); + binding = (VB) clazz.getMethod("inflate", LayoutInflater.class).invoke(null, layoutInflater); return binding.getRoot(); } catch (Exception e) { throw new RuntimeException("ViewBinding creation failed", e); diff --git a/baseframework/src/main/java/com/kongzue/baseframework/BaseBindingFragment.java b/baseframework/src/main/java/com/kongzue/baseframework/BaseBindingFragment.java index 1fbdc13..754fd83 100644 --- a/baseframework/src/main/java/com/kongzue/baseframework/BaseBindingFragment.java +++ b/baseframework/src/main/java/com/kongzue/baseframework/BaseBindingFragment.java @@ -40,10 +40,11 @@ private View userDataBindingCreateLayout() { Type superclass = getClass().getGenericSuperclass(); if (superclass instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) superclass; - Type type = parameterizedType.getActualTypeArguments()[1]; + Type type = parameterizedType.getActualTypeArguments()[0]; try { Class clazz = (Class) type; - binding = (VB) clazz.getMethod("inflate", getLayoutInflater().getClass()).invoke(null, getLayoutInflater()); + LayoutInflater layoutInflater = LayoutInflater.from(getContext()); + binding = (VB) clazz.getMethod("inflate", LayoutInflater.class).invoke(null, layoutInflater); return binding.getRoot(); } catch (Exception e) { throw new RuntimeException("ViewBinding creation failed", e);