if (!handled
&& (event.getAction() == KeyEvent.ACTION_DOWN)
&& (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP)
+ && (mCurrentView != null)
&& (mCurrentView.isRootNamespace())
&& (mCurrentView.hasFocus())
&& (mCurrentView.findFocus().focusSearch(View.FOCUS_UP) == null)) {
@Override
public void dispatchWindowFocusChanged(boolean hasFocus) {
- mCurrentView.dispatchWindowFocusChanged(hasFocus);
+ if (mCurrentView != null){
+ mCurrentView.dispatchWindowFocusChanged(hasFocus);
+ }
}
public void setCurrentTab(int index) {
@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();
}
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) {
}
public void onFocusChange(View v, boolean hasFocus) {
- if (v == this && hasFocus) {
+ if (v == this && hasFocus && getTabCount() > 0) {
getChildTabViewAt(mSelectedTab).requestFocus();
return;
}