Add blacklist option and minor code improvements
This commit is contained in:
parent
0a71b37f00
commit
8a75b8b68f
13 changed files with 574 additions and 28 deletions
|
|
@ -68,12 +68,7 @@ public final class FileUtil {
|
|||
if (files != null) {
|
||||
String[] paths = new String[files.size()];
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
try {
|
||||
paths[i] = files.get(i).getCanonicalPath(); // canonical path is important here because we want to compare the path with the media store entry later
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
paths[i] = files.get(i).getPath();
|
||||
}
|
||||
paths[i] = safeGetCanonicalPath(files.get(i));
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
|
@ -190,4 +185,13 @@ public final class FileUtil {
|
|||
fin.close();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String safeGetCanonicalPath(File file) {
|
||||
try {
|
||||
return file.getCanonicalPath();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ public final class PreferenceUtil {
|
|||
|
||||
public static final String SYNCHRONIZED_LYRICS_SHOW = "synchronized_lyrics_show";
|
||||
|
||||
public static final String INITIALIZED_BLACKLIST = "initialized_blacklist";
|
||||
|
||||
private static PreferenceUtil sInstance;
|
||||
|
||||
private final SharedPreferences mPreferences;
|
||||
|
|
@ -405,11 +407,21 @@ public final class PreferenceUtil {
|
|||
|
||||
public void setStartDirectory(File file) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putString(START_DIRECTORY, file.getPath());
|
||||
editor.putString(START_DIRECTORY, FileUtil.safeGetCanonicalPath(file));
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean synchronizedLyricsShow() {
|
||||
return mPreferences.getBoolean(SYNCHRONIZED_LYRICS_SHOW, true);
|
||||
}
|
||||
|
||||
public void setInitializedBlacklist() {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(INITIALIZED_BLACKLIST, true);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean initializedBlacklist() {
|
||||
return mPreferences.getBoolean(INITIALIZED_BLACKLIST, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue