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

    /* Stop the thumbnailer */
    if (mThumbnailer != null) mThumbnailer.stop();
  }
Ejemplo n.º 3
0
  @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);
  }
Ejemplo n.º 4
0
  public void updateList() {
    if (!mSwipeRefreshLayout.isRefreshing()) mSwipeRefreshLayout.setRefreshing(true);
    final List<MediaWrapper> itemList = mMediaLibrary.getVideoItems();

    if (mThumbnailer != null) mThumbnailer.clearJobs();
    else Log.w(TAG, "Can't generate thumbnails, the thumbnailer is missing");

    mVideoAdapter.setNotifyOnChange(true);
    mVideoAdapter.clear();

    if (itemList.size() > 0) {
      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  if (mGroup != null || itemList.size() <= 10) {
                    for (MediaWrapper item : itemList) {
                      if (mGroup == null || item.getTitle().startsWith(mGroup)) {
                        mVideoAdapter.setNotifyOnChange(false);
                        mVideoAdapter.add(item);
                        if (mThumbnailer != null) mThumbnailer.addJob(item);
                      }
                    }
                  } else {
                    List<MediaGroup> groups = MediaGroup.group(itemList);
                    for (MediaGroup item : groups) {
                      mVideoAdapter.setNotifyOnChange(false);
                      mVideoAdapter.add(item.getMedia());
                      if (mThumbnailer != null) mThumbnailer.addJob(item);
                    }
                  }
                  if (mReadyToDisplay) display();
                }
              })
          .start();
    } else focusHelper(true);
    stopRefresh();
  }