@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); UIHelper.SetTheme(this, R.layout.activity_display_light_novel_content); UIHelper.SetActionBarDisplayHomeAsUp(this, true); try { PageModel tempPage = new PageModel(); tempPage.setPage(getIntent().getStringExtra(Constants.EXTRA_PAGE)); pageModel = dao.getPageModel(tempPage, null); } catch (Exception e) { Log.e( TAG, "Failed to get the PageModel for content: " + getIntent().getStringExtra(Constants.EXTRA_PAGE), e); } // compatibility search box final EditText searchText = (EditText) findViewById(R.id.searchText); searchText.setOnEditorActionListener( new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { search(searchText.getText().toString()); return false; } }); webView = (WebView) findViewById(R.id.webView1); Log.d(TAG, "OnCreate Completed: " + pageModel.getPage()); restored = false; }
public PageModel getPageModel() throws Exception { if (this.pageModel == null) { NovelsDao dao = NovelsDao.getInstance(); PageModel tempPage = new PageModel(); tempPage.setPage(this.page); this.pageModel = dao.getPageModel(tempPage, null); } return pageModel; }
public PageModel getParentPageModel() throws Exception { if (this.parentPageModel == null) { NovelsDao dao = NovelsDao.getInstance(); PageModel tempPage = new PageModel(); if (this.type.contentEquals(TYPE_CONTENT)) { String tempParent = parent.substring(0, parent.indexOf(Constants.NOVEL_BOOK_DIVIDER)); tempPage.setPage(tempParent); } else { tempPage.setPage(this.parent); } this.parentPageModel = dao.getPageModel(tempPage, null); } return parentPageModel; }
public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); try { // replace the current pageModel with the saved instance PageModel tempPage = new PageModel(); tempPage.setPage(savedInstanceState.getString(Constants.EXTRA_PAGE)); // if(pageModel == null) { pageModel = dao.getPageModel(tempPage, null); executeTask(pageModel); // } } catch (Exception e) { Log.e(TAG, "Error when restoring instance", e); } Log.d(TAG, "onRestoreInstanceState Completed"); restored = true; }