@Override
 public void onDestroyView() {
   super.onDestroyView();
   if (mAdapter != null) {
     mAdapter.forceStopLoadingIfNecessary();
   }
   GuiUtils.removeGlobalOnLayoutListener(photosGrid, photosGridListener);
 }
 @Override
 public void pageDeactivated() {
   super.pageDeactivated();
   if (mTags != null || mAlbum != null) {
     mTags = null;
     mAlbum = null;
     // we need to schedule refresh when the page will be activated in
     // viewpager to clear filters
     refreshOnPageActivated = true;
   }
 };
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   super.onCreateView(inflater, container, savedInstanceState);
   View v = inflater.inflate(R.layout.fragment_gallery, container, false);
   if (savedInstanceState != null) {
     mTags = savedInstanceState.getString(EXTRA_TAG);
     mAlbum = savedInstanceState.getString(EXTRA_ALBUM);
   } else {
     mTags = null;
     mAlbum = null;
   }
   return v;
 }
 @Override
 public void pageActivated() {
   super.pageActivated();
   if (!isVisible()) {
     return;
   }
   // if filtering is requested
   if (!refreshOnPageActivated) {
     Intent intent = getActivity().getIntent();
     if (intent != null) {
       if (intent.hasExtra(EXTRA_ALBUM) || intent.hasExtra(EXTRA_TAG)) {
         refresh();
       }
     }
   }
 }
 @Override
 public void onAttach(Activity activity) {
   super.onAttach(activity);
   loadingControl = ((LoadingControl) activity);
   startNowHandler = ((StartNowHandler) activity);
 }
 @Override
 public void onViewCreated(View view, Bundle savedInstanceState) {
   super.onViewCreated(view, savedInstanceState);
   refresh();
 }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putString(EXTRA_TAG, mTags);
   outState.putString(EXTRA_ALBUM, mAlbum);
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    pageSize = Utils.isTablet(getActivity()) ? 45 : PhotosEndlessAdapter.DEFAULT_PAGE_SIZE;
  }