@Override public void onBackPressed() { OPDSBrowserFragment frag = (OPDSBrowserFragment) tab_opds.getFragment(); if (frag == null || !frag.isVisible() || !frag.loadPreviousPage()) { super.onBackPressed(); } }
@Override public void onStop() { super.onStop(); if (isBoundToService && mCalibreService != null) { mCalibreService.setListener(null); mActivity.getApplicationContext().unbindService(mServiceConnection); isBoundToService = false; } }
@Override public void onStart() { super.onStart(); mActivity .getApplicationContext() .bindService(calibreServiceIntent, mServiceConnection, Context.BIND_AUTO_CREATE); isBoundToService = true; if (getIntent().hasExtra(EXTRA_TAB)) { mBarTabManager.switchTabByTag(getIntent().getStringExtra(EXTRA_TAB)); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Instantiate Main UI Components setContentView(R.layout.tabs_main); mBarTabManager = getBarTabManager(); // Diaglog Fragment Manager and their dialogs mFragmentManager = getSupportFragmentManager(); mSettings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); tab_connection = mBarTabManager.newTab(ConnectionFragment.TAB_TAG); tab_connection .setText(R.string.tab_connection) .setIcon(R.drawable.ic_tab_connection) .setFragmentClass(ConnectionFragment.class); mBarTabManager.addTab(tab_connection); tab_collection = mBarTabManager.newTab(CollectionFragment.TAB_TAG); tab_collection .setText(R.string.tab_collection) .setIcon(R.drawable.ic_tab_collection) .setFragmentClass(CollectionFragment.class); mBarTabManager.addTab(tab_collection); tab_opds = mBarTabManager.newTab(OPDSBrowserFragment.TAB_TAG); tab_opds .setText(R.string.tab_library) .setIcon(R.drawable.ic_tab_csync) .setFragmentClass(OPDSBrowserFragment.class); mBarTabManager.addTab(tab_opds); // Kickstart Calibre Service calibreServiceIntent = new Intent(this, CalibreService.class); startService(calibreServiceIntent); mDB = new MetadataDatabaseHelper(getApplicationContext()); }
@Override public void onDestroy() { super.onDestroy(); mDB.close(); }