Search in sources :

Example 1 with NetworkCatalogRootTree

use of org.geometerplus.fbreader.network.tree.NetworkCatalogRootTree in project FBReaderJ by geometer.

the class SignOutAction method isVisible.

@Override
public boolean isVisible(NetworkTree tree) {
    if (!(tree instanceof NetworkCatalogRootTree)) {
        return false;
    }
    final INetworkLink link = tree.getLink();
    if (link instanceof ISyncNetworkLink) {
        return ((ISyncNetworkLink) link).isLoggedIn(myNetworkContext);
    }
    final NetworkAuthenticationManager mgr = link.authenticationManager();
    return mgr != null && mgr.mayBeAuthorised(false);
}
Also used : NetworkAuthenticationManager(org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager) NetworkCatalogRootTree(org.geometerplus.fbreader.network.tree.NetworkCatalogRootTree)

Example 2 with NetworkCatalogRootTree

use of org.geometerplus.fbreader.network.tree.NetworkCatalogRootTree in project FBReaderJ by geometer.

the class SignOutAction method run.

@Override
public void run(NetworkTree tree) {
    final INetworkLink link = tree.getLink();
    if (link instanceof ISyncNetworkLink) {
        ((ISyncNetworkLink) link).logout(myNetworkContext);
        ((NetworkCatalogRootTree) tree).clearCatalog();
        return;
    }
    final NetworkAuthenticationManager mgr = link.authenticationManager();
    final Runnable runnable = new Runnable() {

        public void run() {
            if (mgr.mayBeAuthorised(false)) {
                mgr.logOut();
                myActivity.runOnUiThread(new Runnable() {

                    public void run() {
                        myLibrary.invalidateVisibility();
                        myLibrary.synchronize();
                    }
                });
            }
        }
    };
    UIUtil.wait("signOut", runnable, myActivity);
}
Also used : NetworkAuthenticationManager(org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager) NetworkCatalogRootTree(org.geometerplus.fbreader.network.tree.NetworkCatalogRootTree)

Aggregations

NetworkAuthenticationManager (org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager)2 NetworkCatalogRootTree (org.geometerplus.fbreader.network.tree.NetworkCatalogRootTree)2