@Override public void onBackPressed() { OPDSBrowserFragment frag = (OPDSBrowserFragment) tab_opds.getFragment(); if (frag == null || !frag.isVisible() || !frag.loadPreviousPage()) { super.onBackPressed(); } }
@Override public void onConnectClick(ConnectionInfo ci) { OPDSBrowserFragment frag = ((OPDSBrowserFragment) tab_opds.getFragment()); if (mCalibreService != null) { mCalibreService.connectToServer(ci); } if (frag != null) { frag.loadURL(ci.getContentServerURL(), false); } }
@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()); }
public void onDiscoveryStateChanged(CalibreService.DiscoveryState discoveryState) { ConnectionFragment frag = (ConnectionFragment) tab_connection.getFragment(); if (frag != null) { frag.setDiscoveryState(discoveryState); switch (discoveryState) { case NO_SERVER: if (frag.isResumed() && mFragmentManager.findFragmentByTag("dlg-connect") == null) { NoServerDialogFragment instNSDF = new NoServerDialogFragment(); instNSDF.show(mFragmentManager, "dlg-no-server"); } break; } } }
public void onBookListChanged() { mBarTabManager.switchTab(tab_collection); CollectionFragment frag = (CollectionFragment) tab_collection.getFragment(); if (frag != null) frag.refreshBookList(); }
@Override public void onErrorReported(CalibreService.ErrorType e) { ConnectionFragment frag = (ConnectionFragment) tab_connection.getFragment(); if (frag != null) frag.setErrorMessage(e); }
public void onConnectionStateChanged(CalibreService.ConnectionState connectionState) { ConnectionFragment frag = (ConnectionFragment) tab_connection.getFragment(); if (frag != null) frag.setConnectionState(connectionState); }
@Override public void confirmDelete(int id) { CollectionFragment frag = (CollectionFragment) tab_collection.getFragment(); if (frag != null) frag.deleteBook(id); }