Commit 6711a3e4 authored by Duncan McNAMARA's avatar Duncan McNAMARA
Browse files

Medialibrary: add ML to ServiceLocator name

parent 18f2fe8c
......@@ -26,12 +26,12 @@ import org.videolan.medialibrary.stubs.StubMediaWrapper;
import org.videolan.medialibrary.stubs.StubMedialibrary;
import org.videolan.medialibrary.stubs.StubPlaylist;
public class ServiceLocator {
public class MLServiceLocator {
private static LocatorMode mMode = LocatorMode.VLC_ANDROID;
public static void setLocatorMode(LocatorMode mode) {
ServiceLocator.mMode = mode;
MLServiceLocator.mMode = mode;
}
public static String EXTRA_TEST_STUBS = "extra_test_stubs";
......
......@@ -15,7 +15,7 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.SingleEvent;
import org.videolan.medialibrary.Tools;
import org.videolan.medialibrary.interfaces.media.AAlbum;
......@@ -85,7 +85,7 @@ abstract public class AMedialibrary {
protected static Context sContext;
public static LiveData<AMediaWrapper> lastThumb = new SingleEvent<>();
protected static final AMedialibrary instance = ServiceLocator.getAMedialibrary();
protected static final AMedialibrary instance = MLServiceLocator.getAMedialibrary();
public static Context getContext() {
return sContext;
......
......@@ -6,7 +6,7 @@ import android.text.TextUtils;
import org.videolan.libvlc.util.VLCUtil;
import org.videolan.medialibrary.R;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.interfaces.AMedialibrary;
import org.videolan.medialibrary.media.MediaLibraryItem;
......@@ -97,7 +97,7 @@ public abstract class AAlbum extends MediaLibraryItem {
= new Parcelable.Creator<AAlbum>() {
@Override
public AAlbum createFromParcel(Parcel in) {
return ServiceLocator.getAAlbum(in);
return MLServiceLocator.getAAlbum(in);
}
@Override
......
......@@ -5,7 +5,7 @@ import android.os.Parcelable;
import org.videolan.libvlc.util.VLCUtil;
import org.videolan.medialibrary.R;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.interfaces.AMedialibrary;
import org.videolan.medialibrary.media.MediaLibraryItem;
......@@ -90,7 +90,7 @@ abstract public class AArtist extends MediaLibraryItem {
= new Parcelable.Creator<AArtist>() {
@Override
public AArtist createFromParcel(Parcel in) {
return ServiceLocator.getAArtist(in);
return MLServiceLocator.getAArtist(in);
}
@Override
......
......@@ -3,7 +3,7 @@ package org.videolan.medialibrary.interfaces.media;
import android.os.Parcel;
import android.os.Parcelable;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.media.MediaLibraryItem;
public abstract class AFolder extends MediaLibraryItem {
......@@ -51,7 +51,7 @@ public abstract class AFolder extends MediaLibraryItem {
public static Parcelable.Creator<AFolder> CREATOR = new Parcelable.Creator<AFolder>() {
@Override
public AFolder createFromParcel(Parcel in) {
return ServiceLocator.getAFolder(in);
return MLServiceLocator.getAFolder(in);
}
@Override
......
......@@ -3,7 +3,7 @@ package org.videolan.medialibrary.interfaces.media;
import android.os.Parcel;
import android.os.Parcelable;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.interfaces.AMedialibrary;
import org.videolan.medialibrary.media.MediaLibraryItem;
......@@ -42,7 +42,7 @@ public abstract class AGenre extends MediaLibraryItem {
= new Parcelable.Creator<AGenre>() {
@Override
public AGenre createFromParcel(Parcel in) {
return ServiceLocator.getAGenre(in);
return MLServiceLocator.getAGenre(in);
}
@Override
......
......@@ -12,7 +12,7 @@ import org.videolan.libvlc.Media;
import org.videolan.libvlc.MediaPlayer;
import org.videolan.libvlc.util.Extensions;
import org.videolan.libvlc.util.VLCUtil;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.Tools;
import org.videolan.medialibrary.media.MediaLibraryItem;
......@@ -696,7 +696,7 @@ public abstract class AMediaWrapper extends MediaLibraryItem implements Parcelab
public static final Parcelable.Creator<AMediaWrapper> CREATOR = new Parcelable.Creator<AMediaWrapper>() {
@Override
public AMediaWrapper createFromParcel(Parcel in) {
return ServiceLocator.getAMediaWrapper(in);
return MLServiceLocator.getAMediaWrapper(in);
}
@Override
......
......@@ -3,7 +3,7 @@ package org.videolan.medialibrary.interfaces.media;
import android.os.Parcel;
import android.os.Parcelable;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.media.MediaLibraryItem;
import java.util.List;
......@@ -45,7 +45,7 @@ public abstract class APlaylist extends MediaLibraryItem {
= new Parcelable.Creator<APlaylist>() {
@Override
public APlaylist createFromParcel(Parcel in) {
return ServiceLocator.getAPlaylist(in);
return MLServiceLocator.getAPlaylist(in);
}
@Override
......
package org.videolan.medialibrary.media;
import android.app.Service;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
import java.util.Date;
......@@ -24,7 +23,7 @@ public class HistoryItem extends MediaLibraryItem {
}
public AMediaWrapper getMedia() {
AMediaWrapper mw = ServiceLocator.getAMediaWrapper(Uri.parse(mrl));
AMediaWrapper mw = MLServiceLocator.getAMediaWrapper(Uri.parse(mrl));
mw.setTitle(title);
mw.setType(AMediaWrapper.TYPE_STREAM);
return mw;
......
package org.videolan.medialibrary.stubs;
import android.os.Handler;
import android.text.TextUtils;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.interfaces.media.AAlbum;
import org.videolan.medialibrary.interfaces.media.AArtist;
import org.videolan.medialibrary.interfaces.media.AFolder;
......@@ -61,21 +60,21 @@ public class StubDataSource {
// Video
String fileName = "058_foar_everywun_frum_boxxy.flv";
media = ServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 18820L, 0,
media = MLServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 18820L, 0,
fileName, fileName, "", "",
"", "", 416, 304, "", 0, -2,
0, 0, 1509466228L, 0L, true);
addVideo(media);
fileName = "FMA - MultiChapter.mkv";
media = ServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 1467383L, 0,
media = MLServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 1467383L, 0,
"Encoded with MiniCoder", fileName, "", "",
"", "", 1280, 720, "", 0,
-2, 0, 0, 1512396147L, 0L, true);
addVideo(media);
fileName = "114_My_Heart_Will_Go_On.avi";
media = ServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 20000L, 0,
media = MLServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 20000L, 0,
"My Heart Will Go On - Celine Dion", fileName, "", "",
"", "", 352, 220, "", 0,
-2, 0, 0, 1509465852L, 0L, true);
......@@ -85,7 +84,7 @@ public class StubDataSource {
fileName = "01-Show Me The Way.mp3";
baseMrl = "/storage/emulated/0/Music/Peter Frampton/Shine On - CD2/";
media = ServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 280244L, 1,
media = MLServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 280244L, 1,
"01-Show Me The Way", fileName, "Peter Frampton", "Rock",
"Shine On CD2", "Peter Frampton",
0, 0, "/storage/emulated/0/Music/Peter Frampton/Shine On - CD2/Folder.jpg",
......@@ -95,7 +94,7 @@ public class StubDataSource {
fileName = "01-Wind Of Change.mp3";
baseMrl = "/storage/emulated/0/Music/Peter Frampton/Shine On - CD1/";
media = ServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 184271L, 1,
media = MLServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 184271L, 1,
"01-Wind Of Change", fileName, "Peter Frampton", "Rock",
"Shine On CD1", "Peter Frampton",
0, 0, "/storage/emulated/0/Music/Peter Frampton/Shine On - CD1/Folder.jpg",
......@@ -105,7 +104,7 @@ public class StubDataSource {
fileName = "03 Bloody Well Right.wma";
baseMrl = "/storage/emulated/0/Music/Supertramp/Best of/";
media = ServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 257199L, 1,
media = MLServiceLocator.getAMediaWrapper(getUUID(), baseMrl + fileName, 0L, 257199L, 1,
"Bloody Well Right", fileName, "Supertramp", "Rock",
"The Autobiography of Supertramp", "Supertramp",
0, 0, "/storage/emulated/0/Music/Supertramp/Best of/Folder.jpg", 0,
......@@ -300,26 +299,26 @@ public class StubDataSource {
private void addAudio(AMediaWrapper media, String shortBio, int releaseYear, int albumDuration) {
addFolders(media);
mAudioMediaWrappers.add(media);
AArtist artist = ServiceLocator.getAArtist(getUUID(), media.getArtist(), shortBio, media.getArtworkMrl(), "");
AArtist artist = MLServiceLocator.getAArtist(getUUID(), media.getArtist(), shortBio, media.getArtworkMrl(), "");
mArtists.add(artist);
AArtist albumArtist = null;
if (!media.getArtist().equals(media.getAlbumArtist())) {
albumArtist = ServiceLocator.getAArtist(getUUID(), media.getAlbumArtist(), "", media.getArtworkMrl(), "");
albumArtist = MLServiceLocator.getAArtist(getUUID(), media.getAlbumArtist(), "", media.getArtworkMrl(), "");
mArtists.add(albumArtist);
}
AAlbum album;
if (albumArtist == null)
album = ServiceLocator.getAAlbum(getUUID(), media.getAlbum(), releaseYear,
album = MLServiceLocator.getAAlbum(getUUID(), media.getAlbum(), releaseYear,
media.getArtworkMrl(), artist.getTitle(),
artist.getId(), media.getTracks().length, albumDuration);
else
album = ServiceLocator.getAAlbum(getUUID(), media.getAlbum(), releaseYear,
album = MLServiceLocator.getAAlbum(getUUID(), media.getAlbum(), releaseYear,
media.getArtworkMrl(), albumArtist.getTitle(),
albumArtist.getId(), media.getTracks().length, albumDuration);
mAlbums.add(album);
ArrayList genreStrings = new ArrayList<>();
// if (!getGenresString())
mGenres.add(ServiceLocator.getAGenre(getUUID(), media.getGenre()));
mGenres.add(MLServiceLocator.getAGenre(getUUID(), media.getGenre()));
}
private void addVideo(AMediaWrapper media) {
......@@ -350,7 +349,7 @@ public class StubDataSource {
ArrayList<String> mlFolders = new ArrayList<>(Arrays.asList(getFoldersString()));
if (!mlFolders.contains(mrl)) {
final String name = folderArray[folderArray.length - 1];
mFolders.add(ServiceLocator.getAFolder(getUUID(), name, mrl));
mFolders.add(MLServiceLocator.getAFolder(getUUID(), name, mrl));
}
}
}
......
......@@ -6,7 +6,7 @@ import android.util.Log;
import androidx.annotation.NonNull;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.interfaces.AMedialibrary;
import org.videolan.medialibrary.interfaces.media.AAlbum;
import org.videolan.medialibrary.interfaces.media.AArtist;
......@@ -268,7 +268,7 @@ public class StubMedialibrary extends AMedialibrary {
}
public APlaylist createPlaylist(String name) {
APlaylist playlist = ServiceLocator.getAPlaylist(dt.getUUID(), name, 0);
APlaylist playlist = MLServiceLocator.getAPlaylist(dt.getUUID(), name, 0);
dt.mPlaylists.add(playlist);
onPlaylistsAdded();
return playlist;
......
......@@ -34,7 +34,7 @@ import androidx.fragment.app.FragmentActivity
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.libvlc.util.AndroidUtil
import org.videolan.medialibrary.ServiceLocator
import org.videolan.medialibrary.MLServiceLocator
import org.videolan.vlc.gui.MainActivity
import org.videolan.vlc.gui.SearchActivity
import org.videolan.vlc.gui.helpers.UiTools
......@@ -97,9 +97,9 @@ class StartActivity : FragmentActivity() {
}
// Setting test mode with stubbed media library if required
if (intent.hasExtra(ServiceLocator.EXTRA_TEST_STUBS)
&& intent.getBooleanExtra(ServiceLocator.EXTRA_TEST_STUBS, false)) {
ServiceLocator.setLocatorMode(ServiceLocator.LocatorMode.TESTS)
if (intent.hasExtra(MLServiceLocator.EXTRA_TEST_STUBS)
&& intent.getBooleanExtra(MLServiceLocator.EXTRA_TEST_STUBS, false)) {
MLServiceLocator.setLocatorMode(MLServiceLocator.LocatorMode.TESTS)
Log.i(TAG, "onCreate: Setting test mode`")
}
......
......@@ -37,7 +37,7 @@ import androidx.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
import org.videolan.vlc.extensions.api.IExtensionHost;
import org.videolan.vlc.extensions.api.IExtensionService;
......@@ -202,7 +202,7 @@ public class ExtensionManagerService extends Service {
@Override
public void playUri(Uri uri, String title) throws RemoteException {
final AMediaWrapper media = ServiceLocator.getAMediaWrapper(uri);
final AMediaWrapper media = MLServiceLocator.getAMediaWrapper(uri);
if (!TextUtils.isEmpty(title));
media.setDisplayTitle(title);
mHandler.post(new Runnable() {
......
......@@ -2,14 +2,14 @@ package org.videolan.vlc.extensions;
import android.net.Uri;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
import org.videolan.vlc.extensions.api.VLCExtensionItem;
public class Utils {
public static AMediaWrapper mediawrapperFromExtension(VLCExtensionItem vlcItem) {
AMediaWrapper media = ServiceLocator.getAMediaWrapper(Uri.parse(vlcItem.link));
AMediaWrapper media = MLServiceLocator.getAMediaWrapper(Uri.parse(vlcItem.link));
media.setDisplayTitle(vlcItem.title);
if (vlcItem.type != VLCExtensionItem.TYPE_OTHER_FILE)
media.setType(vlcItem.type);
......
......@@ -9,7 +9,7 @@ import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.medialibrary.ServiceLocator
import org.videolan.medialibrary.MLServiceLocator
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import org.videolan.vlc.R
import org.videolan.vlc.databinding.ExtensionItemViewBinding
......@@ -36,7 +36,7 @@ class ExtensionAdapter(internal var fragment: ExtensionBrowser?) : RecyclerView.
if (item.type == VLCExtensionItem.TYPE_DIRECTORY) {
fragment!!.browseItem(item)
} else if (item.type == VLCExtensionItem.TYPE_AUDIO || item.type == VLCExtensionItem.TYPE_VIDEO) {
val mw = ServiceLocator.getAMediaWrapper(Uri.parse(item.link))
val mw = MLServiceLocator.getAMediaWrapper(Uri.parse(item.link))
mw.setDisplayTitle(item.getTitle())
mw.description = item.getSubTitle()
mw.type = getTypeAccordingToItem(item.type)
......
......@@ -35,7 +35,7 @@ import androidx.lifecycle.ViewModelProviders
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.launch
import org.videolan.medialibrary.ServiceLocator
import org.videolan.medialibrary.MLServiceLocator
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.vlc.ExternalMonitor
......@@ -164,7 +164,7 @@ open class FileBrowserFragment : BaseBrowserFragment() {
private fun browseOtgDevice(uri: Uri, title: String) {
val mw = ServiceLocator.getAMediaWrapper(uri)
val mw = MLServiceLocator.getAMediaWrapper(uri)
mw.type = AMediaWrapper.TYPE_DIR
mw.title = title
handler.post { browse(mw, true) }
......
......@@ -33,7 +33,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProviders
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.videolan.medialibrary.ServiceLocator
import org.videolan.medialibrary.MLServiceLocator
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.vlc.R
......@@ -104,7 +104,7 @@ class FilePickerFragment : FileBrowserFragment() {
viewModel.refresh()
}
mrl != null -> {
val mw = ServiceLocator.getAMediaWrapper(Uri.parse(FileUtils.getParent(mrl)))
val mw = MLServiceLocator.getAMediaWrapper(Uri.parse(FileUtils.getParent(mrl)))
browse(mw, false)
}
}
......
......@@ -43,7 +43,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.launch
import org.videolan.libvlc.util.AndroidUtil
import org.videolan.medialibrary.ServiceLocator
import org.videolan.medialibrary.MLServiceLocator
import org.videolan.medialibrary.interfaces.EntryPointsEventsCb
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import org.videolan.medialibrary.media.MediaLibraryItem
......@@ -166,7 +166,7 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb {
}
override fun onClick(v: View, position: Int, item: MediaLibraryItem) {
val mw = (item as? Storage)?.let { ServiceLocator.getAMediaWrapper(it.uri) } ?: return
val mw = (item as? Storage)?.let { MLServiceLocator.getAMediaWrapper(it.uri) } ?: return
mw.type = AMediaWrapper.TYPE_DIR
browse(mw, position, (DataBindingUtil.findBinding<BrowserItemBinding>(v))?.browserCheckbox?.state == ThreeStatesCheckbox.STATE_CHECKED)
}
......
......@@ -64,7 +64,7 @@ import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.launch
import org.videolan.libvlc.util.AndroidUtil
import org.videolan.medialibrary.interfaces.AMedialibrary
import org.videolan.medialibrary.ServiceLocator
import org.videolan.medialibrary.MLServiceLocator
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.tools.isStarted
......@@ -422,7 +422,7 @@ object UiTools {
MediaUtils.openUri(activity, item.uri)
else if (item.text != null) {
val uri = Uri.parse(item.text.toString())
val media = ServiceLocator.getAMediaWrapper(uri)
val media = MLServiceLocator.getAMediaWrapper(uri)
if ("file" != uri.scheme)
media.type = AMediaWrapper.TYPE_STREAM
MediaUtils.openMedia(activity, media)
......
......@@ -32,7 +32,7 @@ import androidx.annotation.WorkerThread
import androidx.documentfile.provider.DocumentFile
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.LiveData
import org.videolan.medialibrary.ServiceLocator
import org.videolan.medialibrary.MLServiceLocator
import org.videolan.medialibrary.interfaces.media.AMediaWrapper
import videolan.org.commontools.LiveEvent
......@@ -94,7 +94,7 @@ fun getDocumentFiles(context: Context, path: String) : List<AMediaWrapper>? {
for (file in documentFile.listFiles()) {
if (file.exists() && file.canRead()) {
if (file.name?.startsWith(".") == true) continue
val mw = ServiceLocator.getAMediaWrapper(file.uri).apply {
val mw = MLServiceLocator.getAMediaWrapper(file.uri).apply {
type = when {
file.isDirectory -> AMediaWrapper.TYPE_DIR
file.type?.startsWith("video") == true -> AMediaWrapper.TYPE_VIDEO
......
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