|
|
@@ -4,9 +4,11 @@
|
|
|
package kr.co.zumo.app.lifeplus.util;
|
|
|
|
|
|
import android.content.res.ColorStateList;
|
|
|
+import android.graphics.drawable.Drawable;
|
|
|
import android.support.annotation.ArrayRes;
|
|
|
import android.support.annotation.ColorRes;
|
|
|
import android.support.annotation.DimenRes;
|
|
|
+import android.support.annotation.DrawableRes;
|
|
|
import android.support.annotation.IdRes;
|
|
|
import android.support.annotation.StringRes;
|
|
|
import android.support.v4.content.ContextCompat;
|
|
|
@@ -79,7 +81,6 @@ public class ResourceUtil {
|
|
|
*/
|
|
|
public static int getColor(@ColorRes int colorId) {
|
|
|
return ContextCompat.getColor(App.getInstance().getContext(), colorId);
|
|
|
-// return App.getInstance().getContext().getResources().getColor(colorId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -90,7 +91,16 @@ public class ResourceUtil {
|
|
|
*/
|
|
|
public static ColorStateList getColorStateList(@ColorRes int colorId) {
|
|
|
return ContextCompat.getColorStateList(App.getInstance().getContext(), colorId);
|
|
|
-// return App.getInstance().getContext().getResources().getColorStateList(colorId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Drawable 가져오기
|
|
|
+ *
|
|
|
+ * @param drawableId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Drawable getDrawable(@DrawableRes int drawableId) {
|
|
|
+ return ContextCompat.getDrawable(App.getInstance().getContext(), drawableId);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -108,11 +118,21 @@ public class ResourceUtil {
|
|
|
* DP to pixel
|
|
|
*
|
|
|
* @param dp
|
|
|
- * @return
|
|
|
+ * @return int
|
|
|
*/
|
|
|
public static int dpToPx(float dp) {
|
|
|
+ return (int) dpToFloat(dp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * DP to pixel (float)
|
|
|
+ *
|
|
|
+ * @param dp
|
|
|
+ * @return float
|
|
|
+ */
|
|
|
+ public static float dpToFloat(float dp) {
|
|
|
//(dp * App.getInstance().getContext().getResources().getDisplayMetrics().density + 0.5f);
|
|
|
- return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, App.getInstance().getContext().getResources().getDisplayMetrics());
|
|
|
+ return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, App.getInstance().getContext().getResources().getDisplayMetrics());
|
|
|
}
|
|
|
|
|
|
}
|