diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-05-26 16:14:47 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-05-26 16:14:47 -0700 |
commit | 6df8cbc555b399fb0559e4db3a338a0ea9218b12 (patch) | |
tree | 0f91377a59e33f26344387efce5d48e10b647020 /src | |
parent | 77aad54173617f08c778ce054869d359631bc41d (diff) | |
download | dsub-6df8cbc555b399fb0559e4db3a338a0ea9218b12.tar.gz dsub-6df8cbc555b399fb0559e4db3a338a0ea9218b12.tar.bz2 dsub-6df8cbc555b399fb0559e4db3a338a0ea9218b12.zip |
#351 Don't assume file has period, wrap in try/catch
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/domain/MusicDirectory.java | 26 |
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); } } |