use of org.geometerplus.fbreader.network.tree.NetworkBookTree in project FBReaderJ by geometer.
the class BuyBooksActivity method run.
public static void run(Activity activity, List<NetworkBookTree> trees) {
if (trees.isEmpty()) {
return;
}
final Intent intent = new Intent(activity, BuyBooksActivity.class);
final ArrayList<NetworkTree.Key> keys = new ArrayList<NetworkTree.Key>(trees.size());
for (NetworkBookTree t : trees) {
keys.add(t.getUniqueKey());
}
intent.putExtra(NetworkLibraryActivity.TREE_KEY_KEY, keys);
activity.startActivity(intent);
}
use of org.geometerplus.fbreader.network.tree.NetworkBookTree in project FBReaderJ by geometer.
the class BuyBooksActivity method onCreate.
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
myBookCollection.bindToService(this, null);
myLibrary = Util.networkLibrary(this);
final List<NetworkTree.Key> keys = (List<NetworkTree.Key>) getIntent().getSerializableExtra(NetworkLibraryActivity.TREE_KEY_KEY);
if (keys == null || keys.isEmpty()) {
finish();
return;
}
myBooks = new ArrayList<NetworkBookItem>(keys.size());
for (NetworkTree.Key k : keys) {
final NetworkTree tree = myLibrary.getTreeByKey(k);
if (tree instanceof NetworkBookTree) {
myBooks.add(((NetworkBookTree) tree).Book);
} else {
finish();
return;
}
}
myLink = myBooks.get(0).Link;
final NetworkAuthenticationManager mgr = myLink.authenticationManager();
if (mgr == null) {
finish();
return;
}
try {
if (!mgr.isAuthorised(true)) {
buttonsView().setVisibility(View.GONE);
AuthorisationMenuActivity.runMenu(this, myLink, 1);
}
} catch (ZLNetworkException e) {
}
myCost = calculateCost();
if (myCost == null) {
// TODO: error message
finish();
return;
}
myAccount = mgr.currentAccount();
setupUI(AuthorisationState.Authorised);
myLibrary.addChangeListener(this);
}
Aggregations