|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.baka.ambient.views.ViewUtils
public final class ViewUtils
Utility methods for views. Not thread safe.
| Nested Class Summary | |
|---|---|
static interface |
ViewUtils.OnTextSubmit
Fired when a text has been successfully entered. |
| Field Summary | |
|---|---|
static DialogInterface.OnClickListener |
CANCEL
Cancels the dialog on invocation. |
Point |
measuredText
The result of measureTextCache(Paint, String) is stored here. |
Point |
translated
A result of translate* operations is stored here. |
(package private) int[] |
translatedPoint
Here the temporary results of all translate* methods are stored. |
| Constructor Summary | |
|---|---|
ViewUtils()
|
|
| Method Summary | |
|---|---|
static Point |
clone(Point point)
Clones given point |
static int |
getTextHeight(Paint paint,
String text)
Returns the text height. |
static boolean |
isCancel(MotionEvent event)
Checks if given event is a MotionEvent.ACTION_CANCEL event. |
static boolean |
isPenUp(MotionEvent event)
Checks if given event is a MotionEvent.ACTION_UP or
MotionEvent.ACTION_CANCEL event. |
static Point |
measureText(Paint paint,
String text)
Measures given text width/height and returns the result as a point. |
static void |
measureText(Paint paint,
String text,
Point point)
Measures given text width/height and sets them to the given point. |
void |
measureTextCache(Paint paint,
String text)
Measures given text width/height and sets them to the cached point. |
static void |
recycleBitmaps(Collection<Bitmap> bitmaps)
Recycles given collection of bitmap. |
static Dialog |
showTextEditor(Context context,
String submitButtonCaption,
String cancelButtonCaption,
String dialogCaption,
String text,
ViewUtils.OnTextSubmit listener)
Creates new text dialog with a text enter capability. |
static AlertDialog |
showYesNoDialog(Context context,
int questionResId,
DialogInterface.OnClickListener yesButtonListener)
Shows a simple yes/no question dialog. |
void |
translateCoordinates(Point point,
View view,
View targetView)
Translates given point into target view's coordinate system and stores the result into the translated point. |
void |
translateCoordinatesToRoot(Point point,
View view)
Translates given point into root view's coordinate system. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
final int[] translatedPoint
public final Point translated
public final Point measuredText
measureTextCache(Paint, String) is stored here.
public static final DialogInterface.OnClickListener CANCEL
| Constructor Detail |
|---|
public ViewUtils()
| Method Detail |
|---|
public static final Point clone(Point point)
point - the point to clone
public static void recycleBitmaps(Collection<Bitmap> bitmaps)
Recycles given collection of bitmap. The
collection is emptied afterwards.
bitmaps - bitmaps to recycle.
public void translateCoordinates(Point point,
View view,
View targetView)
translated point.
point - the point to translate. Will not get modified. If
null then the translated point data
will be taken instead.view - the point belongs to the coordinate system of this view. If
null then the point is an absolute screen
position.targetView - translate the view to this view coordinate system. If
null then the point will be returned as an
absolute screen position.
public void translateCoordinatesToRoot(Point point,
View view)
null.
point - the point to translate. Will not get modified.view - the point belongs to the coordinate system of this view. If
null then the point is an absolute screen
position.
public static int getTextHeight(Paint paint,
String text)
paint - the paint to usetext - the text to measure
public static void measureText(Paint paint,
String text,
Point point)
paint - the painttext - text to measurepoint - overwrites this point.
public static Point measureText(Paint paint,
String text)
paint - the painttext - text to measure
public void measureTextCache(Paint paint,
String text)
cached point.
paint - the painttext - text to measure
public static Dialog showTextEditor(Context context,
String submitButtonCaption,
String cancelButtonCaption,
String dialogCaption,
String text,
ViewUtils.OnTextSubmit listener)
context - the contextsubmitButtonCaption - the submit button caption, if null then OK will
be shown.cancelButtonCaption - the cancel button caption, if null then Cancel
will be shown.dialogCaption - the dialog captiontext - the text to show in the dialog.listener - fire events on this listener
public static AlertDialog showYesNoDialog(Context context,
int questionResId,
DialogInterface.OnClickListener yesButtonListener)
context - the context.questionResId - the question body.yesButtonListener - invoked when user presses the 'Yes' button.
public static boolean isPenUp(MotionEvent event)
MotionEvent.ACTION_UP or
MotionEvent.ACTION_CANCEL event.
event - the event to check
true if pen is up or the motion is canceled,
false otherwise.public static boolean isCancel(MotionEvent event)
MotionEvent.ACTION_CANCEL event.
event - the event to check
true if the motion is canceled,
false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||