-
-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
imitate/src/main/java/com/engineer/imitate/util/ScreenUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.engineer.imitate.util; | ||
|
||
import android.content.Context; | ||
import android.graphics.Point; | ||
import android.view.WindowManager; | ||
|
||
public final class ScreenUtils { | ||
|
||
private ScreenUtils() { | ||
throw new UnsupportedOperationException("u can't instantiate me..."); | ||
} | ||
|
||
/** | ||
* Return the width of screen, in pixel. | ||
* | ||
* @return the width of screen, in pixel | ||
*/ | ||
public static int getScreenWidth(Context context) { | ||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); | ||
if (wm == null) { | ||
return -1; | ||
} | ||
Point point = new Point(); | ||
wm.getDefaultDisplay().getRealSize(point); | ||
return point.x; | ||
} | ||
|
||
/** | ||
* Return the height of screen, in pixel. | ||
* | ||
* @return the height of screen, in pixel | ||
*/ | ||
public static int getScreenHeight(Context context) { | ||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); | ||
if (wm == null) { | ||
return -1; | ||
} | ||
Point point = new Point(); | ||
wm.getDefaultDisplay().getRealSize(point); | ||
return point.y; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters