@Override
 public void onDestroy() {
   super.onDestroy();
   if (mThumbnailer != null) mThumbnailer.clearJobs();
   mBarrier.reset();
   mVideoAdapter.clear();
 }
  @Override
  public void onPause() {
    super.onPause();
    mGVFirstVisiblePos = mGridView.getFirstVisiblePosition();
    mMediaLibrary.setBrowser(null);
    mMediaLibrary.removeUpdateHandler(mHandler);

    /* Stop the thumbnailer */
    if (mThumbnailer != null) mThumbnailer.stop();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mVideoAdapter = new VideoListAdapter(this);
    mMediaLibrary = MediaLibrary.getInstance();

    if (savedInstanceState != null) setGroup(savedInstanceState.getString(KEY_GROUP));
    /* Load the thumbnailer */
    FragmentActivity activity = getActivity();
    if (activity != null)
      mThumbnailer = new Thumbnailer(activity, activity.getWindowManager().getDefaultDisplay());
  }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    registerForContextMenu(mGridView);

    // init the information for the scan (2/2)
    IntentFilter filter = new IntentFilter();
    filter.addAction(Util.ACTION_SCAN_START);
    filter.addAction(Util.ACTION_SCAN_STOP);
    getActivity().registerReceiver(messageReceiverVideoListFragment, filter);
    if (mMediaLibrary.isWorking()) {
      Util.actionScanStart();
    }

    mAnimator = new VideoGridAnimator(mGridView);
  }
  @Override
  public void onResume() {
    super.onResume();
    if ((getActivity() instanceof MainActivity)) mMainActivity = (MainActivity) getActivity();
    mMediaLibrary.setBrowser(this);
    mMediaLibrary.addUpdateHandler(mHandler);
    final boolean refresh = mVideoAdapter.isEmpty();
    if (refresh) updateList();
    else {
      mViewNomedia.setVisibility(View.GONE);
      focusHelper(false);
    }
    // Get & set times
    HashMap<String, Long> times = MediaDatabase.getInstance().getVideoTimes();
    mVideoAdapter.setTimes(times);
    mGridView.setSelection(mGVFirstVisiblePos);
    updateViewMode();
    if (mGroup == null && refresh) mAnimator.animate();

    /* Start the thumbnailer */
    if (mThumbnailer != null) mThumbnailer.start(this);
  }
 @Override
 public void onDestroyView() {
   getActivity().unregisterReceiver(messageReceiverVideoListFragment);
   super.onDestroyView();
 }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putString(KEY_GROUP, mGroup);
 }