Skip to content

Commit

Permalink
Fix an index out of bounds in search
Browse files Browse the repository at this point in the history
To account for the arabic database, i starts at -1 if it's present.
Consequently, there shouldn't be an additional 1 added to the total
count, because that results in a clear out of bounds case.
  • Loading branch information
ahmedre committed May 26, 2017
1 parent 2fa673a commit eff9f20
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.quran.labs.androidquran.database.DatabaseUtils;
import com.quran.labs.androidquran.database.TranslationsDBAdapter;
import com.quran.labs.androidquran.util.QuranFileUtils;
import com.quran.labs.androidquran.util.QuranSettings;
import com.quran.labs.androidquran.util.QuranUtils;

import java.util.List;
Expand All @@ -45,7 +44,6 @@ public class QuranDataProvider extends ContentProvider {
private static final UriMatcher uriMatcher = buildUriMatcher();

private boolean didInject;
@Inject QuranSettings quranSettings;
@Inject TranslationsDBAdapter translationsDBAdapter;

private static UriMatcher buildUriMatcher() {
Expand Down Expand Up @@ -123,7 +121,7 @@ private Cursor getSuggestions(String query) {
return null;
}

int total = translations.size() + (haveArabic ? 1 : 0);
int total = translations.size();
int start = haveArabic ? -1 : 0;

String[] cols = new String[] { BaseColumns._ID,
Expand Down Expand Up @@ -197,7 +195,7 @@ private Cursor search(String query, List<LocalTranslation> translations) {
}

int start = haveArabic ? -1 : 0;
int total = translations.size() + (haveArabic ? 1 : 0);
int total = translations.size();

for (int i = start; i < total; i++) {
String databaseName;
Expand Down

0 comments on commit eff9f20

Please sign in to comment.