1
0
Kongzue 2 жил өмнө
parent
commit
fcae04a0b4

+ 7 - 3
DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java

@@ -445,10 +445,14 @@ public abstract class BaseDialog implements LifecycleOwner {
     }
 
     public static Activity getTopActivity() {
-        if (activityWeakReference == null) {
+        if (activityWeakReference == null || activityWeakReference.get() == null) {
+            //尝试反射初始化
             init(null);
-            if (activityWeakReference == null) {
-                return ActivityLifecycleImpl.getTopActivity();
+            if (activityWeakReference == null || activityWeakReference.get() == null) {
+                //若还为空,无奈,尝试直接反射拿顶层 activity
+                Activity topActivity = ActivityLifecycleImpl.getTopActivity();
+                init(topActivity);
+                return topActivity;
             }
             return activityWeakReference.get();
         }

+ 1 - 1
gradle.properties

@@ -19,7 +19,7 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.48.beta32
+BUILD_VERSION=0.0.48
 BUILD_VERSION_INT=47
 DIALOGX_STYLE_VERSION=5
 android.nonTransitiveRClass=true