@Override
  public void spotsLoaded(boolean fromCache, List<SpotData> _spots) {
    // this is called when the spots are loaded.
    // it is called twice,first with values from the local cache and later with new updated values
    // from internet
    if (fromCache && _spots == null) {
      // since this is from cache, show a loading screen. Later this function is called again but
      // with non-cached values
      showLoading();
      return;
    }
    if (!fromCache && _spots == null) {
      // ok, there are really no spots
      showNoData();
      return;
    }

    if (SpotStorage.sameSpots(_spots, mSpots)) {
      return; // no change
    }
    mSpots = _spots;
    if (mTabPageIndicator != null && mFragmentAdapter != null) {
      mFragmentAdapter.setSpots(_spots);
      mTabPageIndicator.notifyDataSetChanged();
    }
    showSpots();
  }
 @Override
 public void setViewPager(ViewPager view) {
   if (mViewPager == view) {
     return;
   }
   if (mViewPager != null) {
     mViewPager.setOnPageChangeListener(null);
   }
   final PagerAdapter adapter = view.getAdapter();
   if (adapter == null) {
     throw new IllegalStateException("ViewPager does not have adapter instance.");
   }
   mViewPager = view;
   view.setOnPageChangeListener(this);
   notifyDataSetChanged();
 }