forked from chenyangcun/MaterialDesignExample
-
Notifications
You must be signed in to change notification settings - Fork 0
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
chenyangcun
committed
Aug 1, 2015
1 parent
108f513
commit f0dd761
Showing
27 changed files
with
175 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,48 @@ | ||
package com.aswifter.material; | ||
|
||
import android.content.Context; | ||
import android.content.res.Resources; | ||
import android.graphics.Point; | ||
import android.os.Build; | ||
import android.view.Display; | ||
import android.view.WindowManager; | ||
|
||
/** | ||
* Created by froger_mcs on 05.11.14. | ||
*/ | ||
public class Utils { | ||
private static int screenWidth = 0; | ||
private static int screenHeight = 0; | ||
|
||
public static int dpToPx(int dp) { | ||
return (int) (dp * Resources.getSystem().getDisplayMetrics().density); | ||
} | ||
|
||
public static int getScreenHeight(Context c) { | ||
if (screenHeight == 0) { | ||
WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); | ||
Display display = wm.getDefaultDisplay(); | ||
Point size = new Point(); | ||
display.getSize(size); | ||
screenHeight = size.y; | ||
} | ||
|
||
return screenHeight; | ||
} | ||
|
||
public static int getScreenWidth(Context c) { | ||
if (screenWidth == 0) { | ||
WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); | ||
Display display = wm.getDefaultDisplay(); | ||
Point size = new Point(); | ||
display.getSize(size); | ||
screenWidth = size.x; | ||
} | ||
|
||
return screenWidth; | ||
} | ||
|
||
public static boolean isAndroid5() { | ||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; | ||
} | ||
} |
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
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
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
Oops, something went wrong.