From 1b57cd8968520b7872d026e07af06f3727d8c397 Mon Sep 17 00:00:00 2001 From: Robot Date: Sat, 19 Sep 2015 11:48:18 +0800 Subject: [PATCH] Update PagerSlidingTabStrip.java fix NullPointException when there's no data in Adapter --- library/src/com/astuetz/PagerSlidingTabStrip.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/src/com/astuetz/PagerSlidingTabStrip.java b/library/src/com/astuetz/PagerSlidingTabStrip.java index 87b671c..14fe19e 100644 --- a/library/src/com/astuetz/PagerSlidingTabStrip.java +++ b/library/src/com/astuetz/PagerSlidingTabStrip.java @@ -357,8 +357,9 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse currentPosition = position; currentPositionOffset = positionOffset; - - scrollToChild(position, (int) (positionOffset * tabsContainer.getChildAt(position).getWidth())); + if (tabsContainer.getChildAt(position) != null) { + scrollToChild(position, (int) (positionOffset * tabsContainer.getChildAt(position).getWidth())); + } invalidate();