Commit 3a6b017b authored by Geoffrey Métais's avatar Geoffrey Métais

Medialibrary: Call reload in service actor

parent ab19887b
...@@ -126,8 +126,8 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope { ...@@ -126,8 +126,8 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
val parse = intent.getBooleanExtra(EXTRA_PARSE, true) val parse = intent.getBooleanExtra(EXTRA_PARSE, true)
setupMedialibrary(upgrade, parse) setupMedialibrary(upgrade, parse)
} }
ACTION_RELOAD -> reload(intent.getStringExtra(EXTRA_PATH)) ACTION_RELOAD -> actions.offer(Reload(intent.getStringExtra(EXTRA_PATH)))
ACTION_FORCE_RELOAD -> medialibrary.forceRescan() ACTION_FORCE_RELOAD -> actions.offer(ForceReload)
ACTION_DISCOVER -> discover(intent.getStringExtra(EXTRA_PATH)) ACTION_DISCOVER -> discover(intent.getStringExtra(EXTRA_PATH))
ACTION_DISCOVER_DEVICE -> discoverStorage(intent.getStringExtra(EXTRA_PATH)) ACTION_DISCOVER_DEVICE -> discoverStorage(intent.getStringExtra(EXTRA_PATH))
ACTION_CHECK_STORAGES -> if (scanActivated) actions.offer(UpdateStorages) else exitCommand() ACTION_CHECK_STORAGES -> if (scanActivated) actions.offer(UpdateStorages) else exitCommand()
...@@ -388,6 +388,8 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope { ...@@ -388,6 +388,8 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
startScan(false, action.upgrade) startScan(false, action.upgrade)
} }
UpdateStorages -> updateStorages() UpdateStorages -> updateStorages()
is Reload -> reload(action.path)
ForceReload -> medialibrary.forceRescan()
} }
} }
...@@ -432,7 +434,7 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope { ...@@ -432,7 +434,7 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
data class ScanProgress(val parsing: Int, val discovery: String) data class ScanProgress(val parsing: Int, val discovery: String)
fun Context.reload() { fun Context.reloadLibrary() {
ContextCompat.startForegroundService(this, Intent(ACTION_RELOAD, null, this, MediaParsingService::class.java)) ContextCompat.startForegroundService(this, Intent(ACTION_RELOAD, null, this, MediaParsingService::class.java))
} }
...@@ -464,6 +466,8 @@ private class DiscoverFolder(val path: String) : MLAction() ...@@ -464,6 +466,8 @@ private class DiscoverFolder(val path: String) : MLAction()
private class Init(val upgrade: Boolean, val parse: Boolean) : MLAction() private class Init(val upgrade: Boolean, val parse: Boolean) : MLAction()
private class StartScan(val upgrade: Boolean) : MLAction() private class StartScan(val upgrade: Boolean) : MLAction()
private object UpdateStorages : MLAction() private object UpdateStorages : MLAction()
private class Reload(val path: String?) : MLAction()
private object ForceReload : MLAction()
private sealed class Notification private sealed class Notification
private object Show : Notification() private object Show : Notification()
......
...@@ -150,7 +150,7 @@ public class MainActivity extends ContentActivity implements ExtensionManagerSer ...@@ -150,7 +150,7 @@ public class MainActivity extends ContentActivity implements ExtensionManagerSer
super.onStart(); super.onStart();
if (mMediaLibrary.isInitiated()) { if (mMediaLibrary.isInitiated()) {
/* Load media items from database and storage */ /* Load media items from database and storage */
if (mScanNeeded && Permissions.canReadStorage(this)) MediaParsingServiceKt.reload(this); if (mScanNeeded && Permissions.canReadStorage(this)) MediaParsingServiceKt.reloadLibrary(this);
} }
if (BuildConfig.DEBUG) createExtensionServiceConnection(); if (BuildConfig.DEBUG) createExtensionServiceConnection();
} }
...@@ -341,7 +341,7 @@ public class MainActivity extends ContentActivity implements ExtensionManagerSer ...@@ -341,7 +341,7 @@ public class MainActivity extends ContentActivity implements ExtensionManagerSer
if (requestCode == Constants.ACTIVITY_RESULT_PREFERENCES) { if (requestCode == Constants.ACTIVITY_RESULT_PREFERENCES) {
switch (resultCode) { switch (resultCode) {
case PreferencesActivity.RESULT_RESCAN: case PreferencesActivity.RESULT_RESCAN:
MediaParsingServiceKt.reload(this); MediaParsingServiceKt.reloadLibrary(this);
break; break;
case PreferencesActivity.RESULT_RESTART: case PreferencesActivity.RESULT_RESTART:
case PreferencesActivity.RESULT_RESTART_APP: case PreferencesActivity.RESULT_RESTART_APP:
......
...@@ -46,7 +46,7 @@ import org.videolan.vlc.gui.audio.AudioBrowserFragment ...@@ -46,7 +46,7 @@ import org.videolan.vlc.gui.audio.AudioBrowserFragment
import org.videolan.vlc.gui.audio.BaseAudioBrowser import org.videolan.vlc.gui.audio.BaseAudioBrowser
import org.videolan.vlc.gui.view.FastScroller import org.videolan.vlc.gui.view.FastScroller
import org.videolan.vlc.gui.view.RecyclerSectionItemDecoration import org.videolan.vlc.gui.view.RecyclerSectionItemDecoration
import org.videolan.vlc.reload import org.videolan.vlc.reloadLibrary
import org.videolan.vlc.util.AppScope import org.videolan.vlc.util.AppScope
import org.videolan.vlc.viewmodels.paged.PagedPlaylistsModel import org.videolan.vlc.viewmodels.paged.PagedPlaylistsModel
...@@ -112,7 +112,7 @@ class PlaylistFragment : BaseAudioBrowser(), Observer<PagedList<MediaLibraryItem ...@@ -112,7 +112,7 @@ class PlaylistFragment : BaseAudioBrowser(), Observer<PagedList<MediaLibraryItem
} }
override fun onRefresh() { override fun onRefresh() {
activity?.reload() activity?.reloadLibrary()
} }
override fun getTitle() = getString(R.string.playlists) override fun getTitle() = getString(R.string.playlists)
......
...@@ -110,7 +110,7 @@ public class SecondaryActivity extends ContentActivity { ...@@ -110,7 +110,7 @@ public class SecondaryActivity extends ContentActivity {
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == ACTIVITY_RESULT_SECONDARY) { if (requestCode == ACTIVITY_RESULT_SECONDARY) {
if (resultCode == PreferencesActivity.RESULT_RESCAN) MediaParsingServiceKt.reload(this); if (resultCode == PreferencesActivity.RESULT_RESCAN) MediaParsingServiceKt.reloadLibrary(this);
} }
} }
......
...@@ -254,7 +254,7 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre ...@@ -254,7 +254,7 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
@Override @Override
public void onRefresh() { public void onRefresh() {
mActivity.closeSearchView(); mActivity.closeSearchView();
MediaParsingServiceKt.reload(requireContext()); MediaParsingServiceKt.reloadLibrary(requireContext());
} }
@Override @Override
......
...@@ -21,7 +21,7 @@ import org.videolan.vlc.gui.helpers.UiTools ...@@ -21,7 +21,7 @@ import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.media.MediaUtils import org.videolan.vlc.media.MediaUtils
import org.videolan.vlc.media.PlaylistManager import org.videolan.vlc.media.PlaylistManager
import org.videolan.vlc.media.getAll import org.videolan.vlc.media.getAll
import org.videolan.vlc.reload import org.videolan.vlc.reloadLibrary
import org.videolan.vlc.util.* import org.videolan.vlc.util.*
import org.videolan.vlc.viewmodels.paged.PagedFoldersModel import org.videolan.vlc.viewmodels.paged.PagedFoldersModel
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
...@@ -80,7 +80,7 @@ class FoldersFragment : MediaBrowserFragment<PagedFoldersModel>(), CoroutineScop ...@@ -80,7 +80,7 @@ class FoldersFragment : MediaBrowserFragment<PagedFoldersModel>(), CoroutineScop
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
folders_list.layoutManager = LinearLayoutManager(view.context, RecyclerView.VERTICAL, false) folders_list.layoutManager = LinearLayoutManager(view.context, RecyclerView.VERTICAL, false)
folders_list.adapter = adapter folders_list.adapter = adapter
mSwipeRefreshLayout.setOnRefreshListener { activity?.reload() } mSwipeRefreshLayout.setOnRefreshListener { activity?.reloadLibrary() }
} }
override fun onStart() { override fun onStart() {
......
...@@ -80,7 +80,7 @@ public class MainTvActivity extends BaseTvActivity { ...@@ -80,7 +80,7 @@ public class MainTvActivity extends BaseTvActivity {
if (requestCode == ACTIVITY_RESULT_PREFERENCES) { if (requestCode == ACTIVITY_RESULT_PREFERENCES) {
switch (resultCode) { switch (resultCode) {
case PreferencesActivity.RESULT_RESCAN: case PreferencesActivity.RESULT_RESCAN:
MediaParsingServiceKt.reload(this); MediaParsingServiceKt.reloadLibrary(this);
break; break;
case PreferencesActivity.RESULT_RESTART: case PreferencesActivity.RESULT_RESTART:
case PreferencesActivity.RESULT_RESTART_APP: case PreferencesActivity.RESULT_RESTART_APP:
...@@ -139,6 +139,6 @@ public class MainTvActivity extends BaseTvActivity { ...@@ -139,6 +139,6 @@ public class MainTvActivity extends BaseTvActivity {
@Override @Override
protected void refresh() { protected void refresh() {
mMediaLibrary.reload(); MediaParsingServiceKt.reloadLibrary(this);
} }
} }
...@@ -263,7 +263,7 @@ public class VideoGridFragment extends MediaBrowserFragment<VideosModel> impleme ...@@ -263,7 +263,7 @@ public class VideoGridFragment extends MediaBrowserFragment<VideosModel> impleme
@Override @Override
public void onRefresh() { public void onRefresh() {
final Activity activity = getActivity(); final Activity activity = getActivity();
if (activity != null) MediaParsingServiceKt.reload(activity); if (activity != null) MediaParsingServiceKt.reloadLibrary(activity);
} }
@Override @Override
......
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