|
||||||||||
| 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 android.content.DialogInterface.OnClickListener |
CANCEL
Cancels the dialog on invocation. |
android.graphics.Point |
measuredText
The result of measureTextCache(Paint, String) is stored here. |
android.graphics.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 void |
addImage(android.content.Context c,
android.text.SpannableStringBuilder s,
int resId)
Appends an ImageSpan to given builder. |
static android.graphics.Point |
clone(android.graphics.Point point)
Clones given point |
static int |
getTextHeight(android.graphics.Paint paint,
java.lang.String text)
Returns the text height. |
static int |
intMeasureText(android.graphics.Paint paint,
java.lang.String text)
Measures text with given paint. |
static boolean |
isCancel(android.view.MotionEvent event)
Checks if given event is a MotionEvent.ACTION_CANCEL event. |
static boolean |
isPenUp(android.view.MotionEvent event)
Checks if given event is a MotionEvent.ACTION_UP or
MotionEvent.ACTION_CANCEL event. |
static android.graphics.Point |
measureText(android.graphics.Paint paint,
java.lang.String text)
Measures given text width/height and returns the result as a point. |
static void |
measureText(android.graphics.Paint paint,
java.lang.String text,
android.graphics.Point point)
Measures given text width/height and sets them to the given point. |
void |
measureTextCache(android.graphics.Paint paint,
java.lang.String text)
Measures given text width/height and sets them to the cached point. |
static void |
recycleBitmaps(java.util.Collection<android.graphics.Bitmap> bitmaps)
Recycles given collection of bitmap. |
static android.app.AlertDialog |
showOkDialog(android.content.Context context,
java.lang.CharSequence caption,
java.lang.CharSequence text,
int icon)
Shows a simple OK dialog. |
static android.app.Dialog |
showTextEditor(android.content.Context context,
java.lang.String submitButtonCaption,
java.lang.String cancelButtonCaption,
java.lang.String dialogCaption,
java.lang.String text,
ViewUtils.OnTextSubmit listener)
Creates new text dialog with a text enter capability. |
static android.app.AlertDialog |
showYesNoDialog(android.content.Context context,
java.lang.String question,
android.content.DialogInterface.OnClickListener yesButtonListener)
Shows a simple yes/no question dialog. |
void |
translateCoordinates(android.graphics.Point point,
android.view.View view,
android.view.View targetView)
Translates given point into target view's coordinate system and stores the result into the translated point. |
void |
translateCoordinatesToRoot(android.graphics.Point point,
android.view.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 android.graphics.Point translated
public final android.graphics.Point measuredText
measureTextCache(Paint, String) is stored here.
public static final android.content.DialogInterface.OnClickListener CANCEL
| Constructor Detail |
|---|
public ViewUtils()
| Method Detail |
|---|
public static final android.graphics.Point clone(android.graphics.Point point)
point - the point to clone
public static void recycleBitmaps(java.util.Collection<android.graphics.Bitmap> bitmaps)
Recycles given collection of bitmap. The
collection is emptied afterwards.
bitmaps - bitmaps to recycle.
public void translateCoordinates(android.graphics.Point point,
android.view.View view,
android.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(android.graphics.Point point,
android.view.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(android.graphics.Paint paint,
java.lang.String text)
paint - the paint to usetext - the text to measure
public static void measureText(android.graphics.Paint paint,
java.lang.String text,
android.graphics.Point point)
paint - the painttext - text to measurepoint - overwrites this point.
public static int intMeasureText(android.graphics.Paint paint,
java.lang.String text)
paint - the painttext - the text to measure
public static android.graphics.Point measureText(android.graphics.Paint paint,
java.lang.String text)
paint - the painttext - text to measure
public void measureTextCache(android.graphics.Paint paint,
java.lang.String text)
cached point.
paint - the painttext - text to measure
public static android.app.Dialog showTextEditor(android.content.Context context,
java.lang.String submitButtonCaption,
java.lang.String cancelButtonCaption,
java.lang.String dialogCaption,
java.lang.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 android.app.AlertDialog showYesNoDialog(android.content.Context context,
java.lang.String question,
android.content.DialogInterface.OnClickListener yesButtonListener)
context - the context.question - the question body.yesButtonListener - invoked when user presses the 'Yes' button.
public static android.app.AlertDialog showOkDialog(android.content.Context context,
java.lang.CharSequence caption,
java.lang.CharSequence text,
int icon)
context - the context.caption - the dialog captiontext - the text body.icon - optional dialog icon, may be -1 if it should not be shown.
public static boolean isPenUp(android.view.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(android.view.MotionEvent event)
MotionEvent.ACTION_CANCEL event.
event - the event to check
true if the motion is canceled, false
otherwise.
public static void addImage(android.content.Context c,
android.text.SpannableStringBuilder s,
int resId)
ImageSpan to given builder.
c - the contexts - the builderresId - image id.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||