Skip to content

Commit

Permalink
fix(android): support use custom DisplayMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 committed Apr 26, 2024
1 parent 5e4e889 commit 7116703
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ public static HippyMap getDimensions(int ww, int wh, Context context,
if (context == null) {
return null;
}
DisplayMetrics windowDisplayMetrics = context.getResources().getDisplayMetrics();
DisplayMetrics windowDisplayMetrics = PixelUtil.getMetrics();
if (windowDisplayMetrics == null) {
windowDisplayMetrics = context.getResources().getDisplayMetrics();
}
DisplayMetrics screenDisplayMetrics = new DisplayMetrics();
screenDisplayMetrics.setTo(windowDisplayMetrics);
WindowManager windowManager = (WindowManager) context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class PixelUtil {

private static DisplayMetrics sDisplayMetrics = null;

private static DisplayMetrics getMetrics() {
public static DisplayMetrics getMetrics() {
if (sDisplayMetrics == null) {
sDisplayMetrics = ContextHolder.getAppContext().getResources().getDisplayMetrics();
}
Expand Down

0 comments on commit 7116703

Please sign in to comment.