aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/domain/MusicDirectory.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/github/daneren2005/dsub/domain/MusicDirectory.java b/src/github/daneren2005/dsub/domain/MusicDirectory.java
index 7189e31f..faedb25e 100644
--- a/src/github/daneren2005/dsub/domain/MusicDirectory.java
+++ b/src/github/daneren2005/dsub/domain/MusicDirectory.java
@@ -168,16 +168,24 @@ public class MusicDirectory implements Serializable {
}
}
public void rebaseTitleOffPath() {
- String filename = getPath();
- if(filename.indexOf('/') != -1) {
- filename = filename.substring(filename.lastIndexOf('/') + 1);
- if(getTrack() != null) {
- filename = filename.replace(String.format("%02d ", getTrack()), "");
+ try {
+ String filename = getPath();
+ int index = filename.lastIndexOf('/');
+ if (index != -1) {
+ filename = filename.substring(index + 1);
+ if (getTrack() != null) {
+ filename = filename.replace(String.format("%02d ", getTrack()), "");
+ }
+
+ index = filename.lastIndexOf('.');
+ if(index != -1) {
+ filename = filename.substring(0, index);
+ }
+
+ setTitle(filename);
}
-
- filename = filename.substring(0, filename.lastIndexOf('.'));
-
- setTitle(filename);
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to update title based off of path", e);
}
}