Commit 1c4d466e authored by Geoffrey Métais's avatar Geoffrey Métais

Better list refresh

Start media loading earlier, and properly subscribe to medialibrary.
Plus refresh video times on resume, to get updated progress when we leave a video.
parent 77dda481
......@@ -182,6 +182,10 @@ public class MainActivity extends ActionBarActivity {
return;
}
/* Load media items from database and storage */
if (mScanNeeded)
MediaLibrary.getInstance().loadMediaItems();
super.onCreate(savedInstanceState);
/*** Start initializing the UI ***/
......@@ -337,10 +341,6 @@ public class MainActivity extends ActionBarActivity {
/* FIXME: this is used to avoid having MainActivity twice in the backstack */
if (getIntent().hasExtra(AudioService.START_FROM_NOTIFICATION))
getIntent().removeExtra(AudioService.START_FROM_NOTIFICATION);
/* Load media items from database and storage */
if (mScanNeeded)
MediaLibrary.getInstance().loadMediaItems();
}
@Override
......
......@@ -174,15 +174,14 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
@Override
public void onResume() {
super.onResume();
mMediaLibrary.addUpdateHandler(mHandler);
final boolean refresh = mVideoAdapter.isEmpty();
if (refresh){
if (refresh)
updateList();
//Get & set times
HashMap<String, Long> times = MediaDatabase.getInstance().getVideoTimes(getActivity());
mVideoAdapter.setTimes(times);
mVideoAdapter.notifyDataSetChanged();
}
mMediaLibrary.addUpdateHandler(mHandler);
//Get & set times
HashMap<String, Long> times = MediaDatabase.getInstance().getVideoTimes(getActivity());
mVideoAdapter.setTimes(times);
mVideoAdapter.notifyDataSetChanged();
mGridView.setSelection(mGVFirstVisiblePos);
updateViewMode();
if (refresh)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment