Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when casting class extending activity #122

Merged
merged 1 commit into from
Oct 18, 2020

Conversation

starshipcoder
Copy link
Contributor

@starshipcoder starshipcoder commented Oct 1, 2020

Fix crash when casting class extending activity

Fix #102

@chinalwb
Copy link
Owner

@starshipcoder Thanks for this amazing PR! It works but I cannot fully understand how the below code works:

       ....
        while (!(context instanceof Activity)) {
            context = ((ContextWrapper)context).getBaseContext();
        }
        ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
       .....

Could you please help explain more about the code? Thanks!

@chinalwb chinalwb merged commit b2f604c into chinalwb:master Oct 18, 2020
@starshipcoder starshipcoder deleted the fix_crash_cast_activity branch October 21, 2020 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants