Skip to content

Commit

Permalink
fix some crashes and allow translation text to be highlightable again.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre committed Apr 3, 2013
1 parent 59b9363 commit f86df75
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,33 @@ public Cursor getVersesBoundsForPage(int page){
}

public Rect getPageBounds(int page) {
if (!validDatabase()) return null;
String[] colNames = new String[] {
"MIN("+MIN_X+")", "MIN("+MIN_Y+")",
"MAX("+MAX_X+")", "MAX("+MAX_Y+")"};
Cursor c = database.query(GLYPHS_TABLE, colNames, COL_PAGE + "=" + page,
null, null, null, null);
if (!c.moveToFirst()) return null;
Rect r = new Rect(c.getInt(0), c.getInt(1), c.getInt(2), c.getInt(3));
c.close();
return r;
}
if (!validDatabase()){ return null; }

Cursor c = null;
try {
String[] colNames = new String[] {
"MIN("+MIN_X+")", "MIN("+MIN_Y+")",
"MAX("+MAX_X+")", "MAX("+MAX_Y+")"};
c = database.query(GLYPHS_TABLE,
colNames, COL_PAGE + "=" + page, null, null, null, null);
if (!c.moveToFirst()){ return null; }
Rect r = new Rect(c.getInt(0), c.getInt(1), c.getInt(2), c.getInt(3));
return r;
}
catch (Exception e){
return null;
}
finally {
if (c != null){
try { c.close(); } catch (Exception e){ }
}
}
}

public void closeDatabase() {
if (database != null)
database.close();
if (database != null){
try { database.close(); }
catch (Exception e){}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
Expand Down Expand Up @@ -213,6 +214,11 @@ private void addTextForAyah(QuranAyah ayah){
params.setMargins(mLeftRightMargin, mTopBottomMargin,
mLeftRightMargin, mTopBottomMargin);
translationView.setText(translationText);

if (Build.VERSION.SDK_INT >= 11){
translationView.setTextIsSelectable(true);
}

mLinearLayout.addView(translationView, params);
}

Expand Down

0 comments on commit f86df75

Please sign in to comment.