Fix TabHost NPE when there are no tabs

Fixes http://b/issue?id=2318588

Change-Id: If90ee7e2b777e4c77fdd0ae768d1ececa792ee1b
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java
index 2ba6268..c12d098 100644
--- a/core/java/android/widget/TabWidget.java
+++ b/core/java/android/widget/TabWidget.java
@@ -183,7 +183,7 @@
 
     @Override
     public void childDrawableStateChanged(View child) {
-        if (child == getChildTabViewAt(mSelectedTab)) {
+        if (getTabCount() > 0 && child == getChildTabViewAt(mSelectedTab)) {
             // To make sure that the bottom strip is redrawn
             invalidate();
         }
@@ -194,6 +194,9 @@
     public void dispatchDraw(Canvas canvas) {
         super.dispatchDraw(canvas);
 
+        // Do nothing if there are no tabs.
+        if (getTabCount() == 0) return;
+
         // If the user specified a custom view for the tab indicators, then
         // do not draw the bottom strips.
         if (!mDrawBottomStrips) {
@@ -347,7 +350,7 @@
     }
 
     public void onFocusChange(View v, boolean hasFocus) {
-        if (v == this && hasFocus) {
+        if (v == this && hasFocus && getTabCount() > 0) {
             getChildTabViewAt(mSelectedTab).requestFocus();
             return;
         }