Launch a file list for a plugin path
This commit is contained in:
parent
48689f645d
commit
6516fe3cd8
|
@ -52,6 +52,7 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Presents a list of files of different types (Video/Music)
|
* Presents a list of files of different types (Video/Music)
|
||||||
|
@ -63,6 +64,7 @@ public class MediaFileListFragment extends AbstractListFragment {
|
||||||
public static final String PATH_CONTENTS = "pathContents";
|
public static final String PATH_CONTENTS = "pathContents";
|
||||||
public static final String ROOT_PATH_CONTENTS = "rootPathContents";
|
public static final String ROOT_PATH_CONTENTS = "rootPathContents";
|
||||||
public static final String ROOT_VISITED = "rootVisited";
|
public static final String ROOT_VISITED = "rootVisited";
|
||||||
|
public static final String ROOT_PATH = "rootPath";
|
||||||
private static final String ADDON_SOURCE = "addons:";
|
private static final String ADDON_SOURCE = "addons:";
|
||||||
|
|
||||||
private HostManager hostManager;
|
private HostManager hostManager;
|
||||||
|
@ -125,8 +127,10 @@ public class MediaFileListFragment extends AbstractListFragment {
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View root = super.onCreateView(inflater, container, savedInstanceState);
|
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
|
FileLocation rootPath = null;
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
mediaType = args.getString(MEDIA_TYPE, Files.Media.MUSIC);
|
rootPath = args.getParcelable(ROOT_PATH);
|
||||||
|
mediaType = args.getString(MEDIA_TYPE, Files.Media.FILES);
|
||||||
if (mediaType.equalsIgnoreCase(Files.Media.VIDEO)) {
|
if (mediaType.equalsIgnoreCase(Files.Media.VIDEO)) {
|
||||||
playlistId = PlaylistType.VIDEO_PLAYLISTID;
|
playlistId = PlaylistType.VIDEO_PLAYLISTID;
|
||||||
} else if (mediaType.equalsIgnoreCase(Files.Media.PICTURES)) {
|
} else if (mediaType.equalsIgnoreCase(Files.Media.PICTURES)) {
|
||||||
|
@ -156,6 +160,10 @@ public class MediaFileListFragment extends AbstractListFragment {
|
||||||
browseRootAlready = savedInstanceState.getBoolean(ROOT_VISITED);
|
browseRootAlready = savedInstanceState.getBoolean(ROOT_VISITED);
|
||||||
((MediaFileListAdapter) getAdapter()).setFilelistItems(list);
|
((MediaFileListAdapter) getAdapter()).setFilelistItems(list);
|
||||||
}
|
}
|
||||||
|
else if (rootPath != null) {
|
||||||
|
browseRootAlready = true;
|
||||||
|
browseDirectory(rootPath);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
browseSources();
|
browseSources();
|
||||||
}
|
}
|
||||||
|
@ -308,11 +316,12 @@ public class MediaFileListFragment extends AbstractListFragment {
|
||||||
|
|
||||||
ArrayList<FileLocation> flList = new ArrayList<FileLocation>();
|
ArrayList<FileLocation> flList = new ArrayList<FileLocation>();
|
||||||
|
|
||||||
// insert the parent directory as the first item in the list
|
if (dir.hasParent) {
|
||||||
FileLocation fl = new FileLocation("..", parentDirectory, true);
|
// insert the parent directory as the first item in the list
|
||||||
fl.setRootDir(dir.isRootDir());
|
FileLocation fl = new FileLocation("..", parentDirectory, true);
|
||||||
flList.add(0, fl);
|
fl.setRootDir(dir.isRootDir());
|
||||||
|
flList.add(0, fl);
|
||||||
|
}
|
||||||
for (ListType.ItemFile i : result) {
|
for (ListType.ItemFile i : result) {
|
||||||
flList.add(FileLocation.newInstanceFromItemFile(getActivity(), i));
|
flList.add(FileLocation.newInstanceFromItemFile(getActivity(), i));
|
||||||
}
|
}
|
||||||
|
@ -630,6 +639,7 @@ public class MediaFileListFragment extends AbstractListFragment {
|
||||||
|
|
||||||
public final String file;
|
public final String file;
|
||||||
public final boolean isDirectory;
|
public final boolean isDirectory;
|
||||||
|
public final boolean hasParent;
|
||||||
private boolean isRoot;
|
private boolean isRoot;
|
||||||
|
|
||||||
|
|
||||||
|
@ -640,10 +650,13 @@ public class MediaFileListFragment extends AbstractListFragment {
|
||||||
this(title, path, isDir, null, null, null);
|
this(title, path, isDir, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final Pattern noParent = Pattern.compile("plugin://[^/]*/?");
|
||||||
public FileLocation(String title, String path, boolean isDir, String details, String sizeDuration, String artUrl) {
|
public FileLocation(String title, String path, boolean isDir, String details, String sizeDuration, String artUrl) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.file = path;
|
this.file = path;
|
||||||
this.isDirectory = isDir;
|
this.isDirectory = isDir;
|
||||||
|
this.hasParent = !noParent.matcher(path).matches();
|
||||||
|
|
||||||
this.isRoot = false;
|
this.isRoot = false;
|
||||||
|
|
||||||
this.details = details;
|
this.details = details;
|
||||||
|
@ -698,6 +711,7 @@ public class MediaFileListFragment extends AbstractListFragment {
|
||||||
this.title = in.readString();
|
this.title = in.readString();
|
||||||
this.file = in.readString();
|
this.file = in.readString();
|
||||||
this.isDirectory = (in.readInt() != 0);
|
this.isDirectory = (in.readInt() != 0);
|
||||||
|
this.hasParent = (in.readInt() != 0);
|
||||||
this.isRoot = (in.readInt() != 0);
|
this.isRoot = (in.readInt() != 0);
|
||||||
|
|
||||||
this.details = in.readString();
|
this.details = in.readString();
|
||||||
|
@ -713,6 +727,7 @@ public class MediaFileListFragment extends AbstractListFragment {
|
||||||
out.writeString(title);
|
out.writeString(title);
|
||||||
out.writeString(file);
|
out.writeString(file);
|
||||||
out.writeInt(isDirectory ? 1 : 0);
|
out.writeInt(isDirectory ? 1 : 0);
|
||||||
|
out.writeInt(hasParent ? 1 : 0);
|
||||||
out.writeInt(isRoot ? 1 : 0);
|
out.writeInt(isRoot ? 1 : 0);
|
||||||
|
|
||||||
out.writeString(details);
|
out.writeString(details);
|
||||||
|
|
Loading…
Reference in New Issue