Skip to content

Commit

Permalink
Fix a crash on tablets due to null context
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre committed Sep 19, 2016
1 parent f30eb1d commit b92e508
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.quran.labs.androidquran.data;

import android.content.Context;
import android.text.TextUtils;

import com.quran.labs.androidquran.R;
import com.quran.labs.androidquran.common.QuranAyah;
import com.quran.labs.androidquran.util.QuranUtils;

import android.content.Context;
import android.text.TextUtils;

import java.util.LinkedHashSet;
import java.util.Set;

Expand Down Expand Up @@ -52,11 +52,11 @@ public static String getSuraName(Context context, int sura,
}

StringBuilder builder = new StringBuilder();
String[] suraNames = context.getResources().getStringArray(R.array.sura_names);
if (wantPrefix) {
builder.append(context.getString(R.string.quran_sura_title,
context.getResources().getStringArray(R.array.sura_names)[sura - 1]));
builder.append(context.getString(R.string.quran_sura_title, suraNames[sura - 1]));
} else {
builder.append(context.getResources().getStringArray(R.array.sura_names)[sura - 1]);
builder.append(suraNames[sura - 1]);
}
if (wantTranslation) {
String translation = context.getResources().getStringArray(R.array.sura_names_translation)[sura - 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ protected void onPostExecute(RectF[] rect) {
if (mRightImageView != null && mLeftImageView != null) {
mRightImageView.setPageBounds(rect[0]);
mLeftImageView.setPageBounds(rect[1]);
if (mOverlayText) {
Context context = getContext();
Context context = getContext();
if (mOverlayText && context != null) {
String suraText = QuranInfo.getSuraNameFromPage(context, mPageNumber - 1, true);
String juzText = QuranInfo.getJuzString(context, mPageNumber - 1);
String pageText = QuranUtils.getLocalizedNumber(context, mPageNumber - 1);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ escolher um leitor-qari diferente. Clique play para baixar e reproduzir a págin
<string name="quran_page">Página</string>
<string name="quran_sura">Sura</string>
<string name="quran_ayah">Ayah %1$d</string>
<string name="quran_sura_title">Surat</string>
<string name="quran_sura_title">Surat %1$s</string>
<string name="sura_ayah_notification_str">Sura %1$s, Ayah %2$d</string>

<string name="bookmarks_current_page">Página Atual</string>
Expand Down

0 comments on commit b92e508

Please sign in to comment.