Buggy code:
public class QuranViewActivity extends PageViewQuranActivity implements AyahStateListener { protected static final String ACTION_PREVIOUS = "ACTION_PREVIOUS" ; protected static final String ACTION_NEXT = "ACTION_NEXT" ; protected static final String ACTION_PAUSE = "ACTION_PAUSE" ; protected static final String ACTION_PLAY = "ACTION_PLAY" ; protected static final String ACTION_STOP = "ACTION_STOP" ; protected static final String ACTION_CHANGE_READER = "ACTION_CHANGE_READER" ; protected static final String ACTION_JUMP_TO_AYAH = "ACTION_JUMP_TO_AYAH" ; protected static final String ACTION_REPEAT = "ACTION_REPEAT" ; private static final String TAG = "QuranViewActivity" ; private boolean bounded = false ; private AudioServiceBinder quranAudioPlayer = null ; private AyahItem lastAyah ; private int currentReaderId ; private boolean playing = false ; private LinkedHashMap < String , IntentAction > actionBarActions = new LinkedHashMap < String , IntentAction > ( ) ; private ServiceConnection conn = new ServiceConnection ( ) { @ Override public void onServiceDisconnected ( ComponentName name ) { } @ Override public void onServiceConnected ( ComponentName name , IBinder service ) { } } ; @ Override protected void onCreate ( Bundle savedInstanceState ) { } protected void addActions ( ) { } private IntentAction getIntentAction ( String intentAction , int drawable ) { } @ Override protected void onNewIntent ( Intent intent ) { } private void onActionPlay ( ) { } private void onActionStop ( ) { } private void showPlayDialog ( ) { } private void showDownloadDialog ( final AyahItem i ) { } private void showAudioRepeatsDialog ( ) { } private Map < Integer , RadioButton > initPlayRadioButtons ( View parent , int pageNum ) { } private void initDownloadRadioButtons ( View parent , AyahItem ayahItem ) { } private void showJumpToAyahDialog ( ) { final Integer [ ] pageBounds = QuranInfo . getPageBounds ( quranPageFeeder . getCurrentPagePosition ( ) ) ; AlertDialog . Builder dialogBuilder = new AlertDialog . Builder ( this ) ; LayoutInflater li = LayoutInflater . from ( this ) ; final View view = li . inflate ( dialog_jump_to_ayah , null ) ; final Spinner ayatSpinner = ( ( Spinner ) ( view . findViewById ( spinner_ayat ) ) ) ; final CheckBox checkbox = ( ( CheckBox ) ( view . findViewById ( checkbox_whole_quran ) ) ) ; int startAyah = pageBounds [ 1 ] ; int endAyah = ( ( pageBounds [ 0 ] ) == ( pageBounds [ 2 ] ) ) ? pageBounds [ 3 ] : QuranInfo . SURA_NUM_AYAHS [ ( ( pageBounds [ 0 ] ) - 1 ) ] ; initAyatSpinner ( ayatSpinner , startAyah , endAyah ) ; final Spinner surasSpinner = ( ( Spinner ) ( view . findViewById ( spinner_suras ) ) ) ; initSurasSpinner ( surasSpinner , 1 , 114 ) ; surasSpinner . setSelection ( ( ( pageBounds [ 0 ] ) - 1 ) ) ; surasSpinner . setOnItemSelectedListener ( new OnItemSelectedListener ( ) { @ SuppressWarnings ( "unchecked" ) @ Override public void onItemSelected ( AdapterView < ? > adapter , View view , int position , long id ) { HashMap < String , String > map = ( ( HashMap < String , String > ) ( adapter . getItemAtPosition ( position ) ) ) ; int suraIndex = Integer . parseInt ( map . get ( "suraId" ) ) ; int startAyah = ( ( suraIndex == ( pageBounds [ 0 ] ) ) && ( checkbox . isChecked ( ) ) ) ? pageBounds [ 1 ] : 1 ; <START_BUG> int endAyah = ( suraIndex == ( pageBounds [ 2 ] ) ) ? pageBounds [ 3 ] : QuranInfo . SURA_NUM_AYAHS [ ( suraIndex - 1 ) ] ; <END_BUG> initAyatSpinner ( ayatSpinner , startAyah , endAyah ) ; if ( suraIndex == ( pageBounds [ 0 ] ) ) { int selection = ( checkbox . isChecked ( ) ) ? 0 : ( pageBounds [ 1 ] ) - 1 ; ayatSpinner . setSelection ( selection ) ; } } @ Override public void onNothingSelected ( AdapterView < ? > arg0 ) { } } ) ; checkbox . setOnCheckedChangeListener ( new OnCheckedChangeListener ( ) { @ Override public void onCheckedChanged ( CompoundButton buttonView , boolean isChecked ) { if ( ! isChecked ) { initSurasSpinner ( surasSpinner , 1 , 114 ) ; surasSpinner . setSelection ( ( ( pageBounds [ 0 ] ) - 1 ) ) ; } else initSurasSpinner ( surasSpinner , pageBounds [ 0 ] , pageBounds [ 2 ] ) ; } } ) ; dialogBuilder . setView ( view ) ; dialogBuilder . setMessage ( "Jump<seq2seq4repair_space>to<seq2seq4repair_space>ayah" ) ; dialogBuilder . setPositiveButton ( "Jump" , new DialogInterface . OnClickListener ( ) { @ SuppressWarnings ( "unchecked" ) @ Override public void onClick ( DialogInterface dialog , int which ) { HashMap < String , String > suraData = ( ( HashMap < String , String > ) ( surasSpinner . getSelectedItem ( ) ) ) ; int sura = Integer . parseInt ( suraData . get ( "suraId" ) ) ; Log . d ( "Ayah" , ( "Spinner<seq2seq4repair_space>ayay<seq2seq4repair_space>values<seq2seq4repair_space>" + ( ayatSpinner . getSelectedItem ( ) . toString ( ) ) ) ) ; Integer ayah = ( ( Integer ) ( ayatSpinner . getSelectedItem ( ) ) ) ; lastAyah = QuranAudioLibrary . getAyahItem ( getApplicationContext ( ) , sura , ayah , getQuranReaderId ( ) ) ; if ( ( ( quranAudioPlayer ) != null ) && ( quranAudioPlayer . isPlaying ( ) ) ) { quranAudioPlayer . stop ( ) ; quranAudioPlayer . play ( lastAyah ) ; } jumpTo ( QuranInfo . getPageFromSuraAyah ( sura , ayah ) ) ; } } ) ; dialogBuilder . setNegativeButton ( "Cancel" , null ) ; dialogBuilder . show ( ) ; } private void initSurasSpinner ( final Spinner spinner , int startSura , int endSura ) { } private void initAyatSpinner ( final Spinner spinner , int startAyah , int endAyah ) { } private void showChangeReaderDialog ( ) { }

Fix:
int endAyah = ( ( suraIndex == ( pageBounds [ 2 ] ) ) && ( checkbox . isChecked ( ) ) ) ? pageBounds [ 3 ] : QuranInfo . SURA_NUM_AYAHS [ ( suraIndex - 1 ) ] ;