public int getVerseNumber() { // Set the verseNumber to what is currently being viewed int verseNumber = bibleTextView.yToVerse( bibleScrollView.getScrollY(), getActivity().findViewById(R.id.prev_chapter_button).getHeight()); return verseNumber; }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); bibleScrollView = (BibleTextScrollView) getActivity().findViewById(R.id.bibleScrollView); // Handler created on UI thread to handle updates to title updateTitleHandler = new Handler() { @Override public void handleMessage(Message msg) { final String verseText = msg.getData().getString("Verse_Text"); ((MainActivity) getActivity()) .updateHeaderText( bibleTextView.getBibleText().getDisplayReferenceBookChapter() + verseText); } }; bibleScrollView.setTitleHandler(updateTitleHandler); bibleTextView = (BibleTextView) getActivity().findViewById(R.id.bible_text); bibleTextView.setBibleSrcollView(bibleScrollView); loadSettings(); // Previous chapter button ((Button) getActivity().findViewById(R.id.prev_chapter_button)) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // Start thread to get verse getActivity().showDialog(LOADING_DIALOG); new SwordVerseTask().execute(bibleTextView.getBibleText().getPrevChapterRef()); } }); // Next chapter button ((Button) getActivity().findViewById(R.id.next_chapter_button)) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // Start thread to get verse getActivity().showDialog(LOADING_DIALOG); new SwordVerseTask().execute(bibleTextView.getBibleText().getNextChapterRef()); } }); // Go to windows view ((ImageButton) getActivity().findViewById(R.id.menu_button_windows)) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), WindowsActivity.class); // Set the verseNumber to what is currently being viewed int verseNumber = bibleTextView.yToVerse( bibleScrollView.getScrollY(), (getActivity().findViewById(R.id.prev_chapter_button)).getHeight()); Log.i("Main", "Set BibleTextView verse number " + verseNumber); bibleTextView.getBibleText().setVerse(verseNumber); Log.i( "Main", "BibleTextView sent " + bibleTextView.getBibleText().getReferenceBookChapterVerse()); // TODO: add string preview from existing rendered text probably just do a // substring of boundaries intent.putExtra("BibleText", bibleTextView.getBibleText()); intent.putExtra("WindowId", ((MainActivity) getActivity()).windowId); startActivityForResult(intent, MainActivity.WINDOW_SELECT_CODE); // overridePendingTransition(R.anim.zoom_enter, 0); } }); // Go to tabs view ((ImageButton) getActivity().findViewById(R.id.menu_button_tabs)) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), TabsActivity.class); // Set the verseNumber to what is currently being viewed int verseNumber = bibleTextView.yToVerse( bibleScrollView.getScrollY(), (getActivity().findViewById(R.id.prev_chapter_button)).getHeight()); Log.i("Main", "Set BibleTextView verse number " + verseNumber); bibleTextView.getBibleText().setVerse(verseNumber); Log.i( "Main", "BibleTextView sent " + bibleTextView.getBibleText().getReferenceBookChapterVerse()); // TODO: add string preview from existing rendered text probably just do a // substring of boundaries intent.putExtra("BibleText", bibleTextView.getBibleText()); intent.putExtra("WindowId", ((MainActivity) getActivity()).windowId); startActivityForResult(intent, MainActivity.WINDOW_SELECT_CODE); // overridePendingTransition(R.anim.zoom_enter, 0); } }); if (bibleTextView.getBibleText() == null) { // Load last opened verse String currentBook = getActivity() .getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE) .getString(SharedPreferencesHelper.CURRENT_BOOK, "Philipiians"); String currentChapter = getActivity() .getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE) .getString(SharedPreferencesHelper.CURRENT_CHAPTER, "1"); String currentVerse = getActivity() .getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE) .getString(SharedPreferencesHelper.CURRENT_VERSE, "1"); String currentTranslation = getActivity() .getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE) .getString(SharedPreferencesHelper.CURRENT_TRANSLATION, "ESV"); new SwordInitTask().execute(currentBook, currentChapter, currentVerse, currentTranslation); } // // Give some text to display if there is no data. In a real // // application this would come from a resource. // setEmptyText("No applications"); // // // We have a menu item to show in action bar. // setHasOptionsMenu(true); // // // Only have one choice // getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); // // // Create an empty adapter we will use to display the loaded data. // mAdapter = new AppListAdapter(getActivity()); // setListAdapter(mAdapter); // // // Start out with a progress indicator. // setListShown(false); // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); }