Skip to content

Commit

Permalink
fixed error stringOutOfBoundsException...
Browse files Browse the repository at this point in the history
  • Loading branch information
hareeshnagaraj committed Aug 6, 2014
1 parent bab19a1 commit 148124b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
Binary file modified app/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "thproject.test.com.myapplication"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
versionCode 3
versionName "1.0.2"

}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void getUserSongs(final Context mContext){
do {
long thisId = musicCursor.getLong(idColumn);
String thisTitle = musicCursor.getString(titleColumn);
String thisArtist = capitalizeEachWord(musicCursor.getString(artistColumn));
String thisArtist = musicCursor.getString(artistColumn);
newtab = new Tab();

if(thisTitle == null || thisTitle == "<unknown>"){
Expand All @@ -75,12 +75,10 @@ public void getUserSongs(final Context mContext){
db.addTab(newtab);
//Scraping the web for this song via handler, and adding that to our DB
}

numsongs++;
}
while (musicCursor.moveToNext());
// Log.d("num songs from songGrabber", Integer.toString(numsongs));

// Log.d("num songs from songGrabber", Integer.toString(numsongs));
}
}

Expand Down Expand Up @@ -224,6 +222,7 @@ public String capitalizeEachWord(String a){
}
}
String titleCaseValue = sb.toString();

return titleCaseValue;
}

Expand Down
22 changes: 14 additions & 8 deletions app/src/main/java/thproject/test/com/myapplication/Tab.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,22 @@ public String toString(){
* Used to capitalize each word when setting the artist, to avoid multiple instances of same artist
* */
public String capitalizeEachWord(String a){
String[] words = a.split(" ");
StringBuilder sb = new StringBuilder();
if (words[0].length() > 0) {
sb.append(Character.toUpperCase(words[0].charAt(0)) + words[0].subSequence(1, words[0].length()).toString().toLowerCase());
for (int i = 1; i < words.length; i++) {
sb.append(" ");
sb.append(Character.toUpperCase(words[i].charAt(0)) + words[i].subSequence(1, words[i].length()).toString().toLowerCase());
String titleCaseValue;
try{
String[] words = a.split(" ");
StringBuilder sb = new StringBuilder();
if (words[0].length() > 0) {
sb.append(Character.toUpperCase(words[0].charAt(0)) + words[0].subSequence(1, words[0].length()).toString().toLowerCase());
for (int i = 1; i < words.length; i++) {
sb.append(" ");
sb.append(Character.toUpperCase(words[i].charAt(0)) + words[i].subSequence(1, words[i].length()).toString().toLowerCase());
}
}
titleCaseValue = sb.toString();
}
catch(StringIndexOutOfBoundsException e){
titleCaseValue = a;
}
String titleCaseValue = sb.toString();
return titleCaseValue;
}
}

0 comments on commit 148124b

Please sign in to comment.