diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-08-04 18:49:03 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2013-08-04 18:49:03 +0200 |
commit | 724e4ae4d237c81385e9d0b6b242d1fa3124127a (patch) | |
tree | 8fbdbf3b575597e8c1e5251acd702002a88c02e9 /src/org/cyanogenmod/wallpapers/photophase/utils | |
parent | 9a4d4f244d9e2d24295bf89c2bbb01610aa33899 (diff) | |
download | android_packages_wallpapers_PhotoPhase-724e4ae4d237c81385e9d0b6b242d1fa3124127a.tar.gz android_packages_wallpapers_PhotoPhase-724e4ae4d237c81385e9d0b6b242d1fa3124127a.tar.bz2 android_packages_wallpapers_PhotoPhase-724e4ae4d237c81385e9d0b6b242d1fa3124127a.zip |
Touch actions (#5)
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/org/cyanogenmod/wallpapers/photophase/utils')
-rw-r--r-- | src/org/cyanogenmod/wallpapers/photophase/utils/Utils.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/utils/Utils.java b/src/org/cyanogenmod/wallpapers/photophase/utils/Utils.java new file mode 100644 index 0000000..03aa8c6 --- /dev/null +++ b/src/org/cyanogenmod/wallpapers/photophase/utils/Utils.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2013 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cyanogenmod.wallpapers.photophase.utils; + +import android.content.Context; +import android.content.res.Resources; +import android.graphics.RectF; +import android.util.DisplayMetrics; + +/** + * A helper class with utilities + */ +public class Utils { + + /** + * This method converts dp unit to equivalent device specific value in pixels. + * + * @param ctx The current context + * @param dp A value in dp (Device independent pixels) unit + * @return float A float value to represent Pixels equivalent to dp according to device + */ + public static float convertDpToPixel(Context ctx, float dp) { + Resources resources = ctx.getResources(); + DisplayMetrics metrics = resources.getDisplayMetrics(); + return dp * (metrics.densityDpi / 160f); + } + + + + /** + * Method that converts a rect from a vertex data + * + * @param vertex The vertex array + * @return RectF The rect data + */ + public static RectF rectFromVertex(float[] vertex) { + RectF rect = new RectF(); + rect.left = vertex[0]; + rect.top = vertex[1]; + rect.right = vertex[6]; + rect.bottom = vertex[7]; + return rect; + } +}
\ No newline at end of file |