From b0c5cd0069f79b07060a3fd1895d6809f005a9f1 Mon Sep 17 00:00:00 2001 From: serso Date: Thu, 6 Jul 2017 09:15:42 +0200 Subject: [PATCH] Fix NPE on Android 4 in DirectionDragButton --- .../android/views/dragbutton/DirectionDragButton.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dragbutton/src/main/java/org/solovyev/android/views/dragbutton/DirectionDragButton.java b/dragbutton/src/main/java/org/solovyev/android/views/dragbutton/DirectionDragButton.java index a51b2bbe..6f67334b 100644 --- a/dragbutton/src/main/java/org/solovyev/android/views/dragbutton/DirectionDragButton.java +++ b/dragbutton/src/main/java/org/solovyev/android/views/dragbutton/DirectionDragButton.java @@ -55,13 +55,19 @@ public class DirectionDragButton extends DragButton implements DirectionDragView @Override public void setTypeface(Typeface tf, int style) { super.setTypeface(tf, style); - textView.setTypeface(getPaint().getTypeface()); + // might be called from constructor + if (textView != null) { + textView.setTypeface(getPaint().getTypeface()); + } } @Override public void setTextSize(int unit, float size) { super.setTextSize(unit, size); - textView.setTextSize(getPaint().getTextSize()); + // might be called from constructor + if (textView != null) { + textView.setTextSize(getPaint().getTextSize()); + } } @Override