aboutsummaryrefslogtreecommitdiff
path: root/src/org/happysanta/gd/Menu/Views/MenuTextView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/happysanta/gd/Menu/Views/MenuTextView.java')
-rw-r--r--src/org/happysanta/gd/Menu/Views/MenuTextView.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/org/happysanta/gd/Menu/Views/MenuTextView.java b/src/org/happysanta/gd/Menu/Views/MenuTextView.java
new file mode 100644
index 0000000..4b48f5f
--- /dev/null
+++ b/src/org/happysanta/gd/Menu/Views/MenuTextView.java
@@ -0,0 +1,73 @@
+package org.happysanta.gd.Menu.Views;
+
+import android.content.Context;
+import android.graphics.Typeface;
+import android.widget.TextView;
+
+import static org.happysanta.gd.Helpers.runOnUiThread;
+
+public class MenuTextView extends TextView {
+
+ protected boolean isAttached = false;
+
+ public MenuTextView(Context context) {
+ super(context);
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ isAttached = true;
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ isAttached = false;
+ }
+
+ @Override
+ public boolean isAttachedToWindow() {
+ return isAttached;
+ }
+
+ public void setTextOnUiThread(final CharSequence sequence) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ MenuTextView.super.setText(sequence);
+ }
+ });
+ }
+
+ @Override
+ public void setTextSize(final float size) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ MenuTextView.super.setTextSize(size);
+ }
+ });
+ }
+
+ @Override
+ public void setTypeface(final Typeface typeface) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ MenuTextView.super.setTypeface(typeface);
+ }
+ });
+ }
+
+ @Override
+ public void setVisibility(final int visibility) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ MenuTextView.super.setVisibility(visibility);
+ }
+ });
+ }
+
+}