Move ContentSettingsFragment.isValidPath to helpers and add unit test for it.
This commit is contained in:
parent
01f05e2f46
commit
15873d53c4
3 changed files with 57 additions and 10 deletions
22
app/src/main/java/org/schabi/newpipe/util/FilePathUtils.java
Normal file
22
app/src/main/java/org/schabi/newpipe/util/FilePathUtils.java
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package org.schabi.newpipe.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public final class FilePathUtils {
|
||||
private FilePathUtils() { }
|
||||
|
||||
|
||||
/**
|
||||
* Check that the path is a valid directory path and it exists.
|
||||
*
|
||||
* @param path full path of directory,
|
||||
* @return is path valid or not
|
||||
*/
|
||||
public static boolean isValidDirectoryPath(final String path) {
|
||||
if (path == null || path.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
final File file = new File(path);
|
||||
return file.exists() && file.isDirectory();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue