/** * check index exists and go to search screen if index exists if no more jobs in progress and no * index then error */ @Override protected void jobFinished(Progress jobJustFinished) { // give the document up to 12 secs to reload - the Progress declares itself finished before the // index status has been changed int attempts = 0; while (!IndexStatus.DONE.equals(documentBeingIndexed.getIndexStatus()) && attempts++ < 6) { CommonUtils.pause(2); } // if index is fine then goto search if (IndexStatus.DONE.equals(documentBeingIndexed.getIndexStatus())) { Log.i(TAG, "Index created"); Intent intent = null; if (StringUtils.isNotEmpty(getIntent().getStringExtra(SearchControl.SEARCH_TEXT))) { // the search string was passed in so execute it directly intent = new Intent(this, SearchResults.class); intent.putExtras(getIntent().getExtras()); } else { // just go to the normal Search screen intent = new Intent(this, Search.class); } startActivity(intent); finish(); } else { // if jobs still running then just wait else error if (isAllJobsFinished()) { Log.e(TAG, "Index finished but document's index is invalid"); showErrorMsg(R.string.error_occurred); } } }
@Override protected void jobFinished(Progress prog) { Log.d(TAG, "Finished download, going to main screen"); if (SwordDocumentFacade.getInstance().getBibles().size() > 0) { gotoMainScreen(); } else { Log.w(TAG, "Could not immediately find downloaded bible"); // can't find downloaded bible, wait a sec and try again CommonUtils.pause(2); if (SwordDocumentFacade.getInstance().getBibles().size() > 0) { Log.d(TAG, "Downloaded bible found now"); gotoMainScreen(); } else { Log.e(TAG, "Downloaded bible not found"); if (JobManager.getJobs().size() == 0) { // something went wrong with the download Dialogs.getInstance().showErrorMsg(R.string.download_complete_no_bibles); } } } }