fix:android unwarp return activity
This commit is contained in:
parent
04c19992ad
commit
411c92f0f0
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package pub.doric.utils;
|
package pub.doric.utils;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
@ -323,10 +324,9 @@ public class DoricUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Context unwrap(Context context) {
|
public static Context unwrap(Context context) {
|
||||||
while (context instanceof ContextWrapper) {
|
while (!(context instanceof Activity) && context instanceof ContextWrapper) {
|
||||||
context = ((ContextWrapper) context).getBaseContext();
|
context = ((ContextWrapper) context).getBaseContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user