mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
book purchasing (in progress)
This commit is contained in:
parent
0b19b5fc6f
commit
55d238b687
5 changed files with 190 additions and 130 deletions
|
@ -1,6 +1,4 @@
|
||||||
buy book after topup
|
|
||||||
buy book after registration
|
buy book after registration
|
||||||
buy several books
|
|
||||||
buy book after auto-sign-in
|
buy book after auto-sign-in
|
||||||
auto-sign-in
|
auto-sign-in
|
||||||
do we cache cover images?
|
do we cache cover images?
|
||||||
|
|
|
@ -129,6 +129,15 @@
|
||||||
<node name="buyAllBooks" value="Buy all books"/>
|
<node name="buyAllBooks" value="Buy all books"/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="buyBook">
|
||||||
|
<node name="title" value="Purchase book" />
|
||||||
|
<node name="titleSeveralBooks" value="Purchase books" />
|
||||||
|
<node name="confirm" value="Are you sure you want to buy “%s”?" />
|
||||||
|
<node name="confirmSeveralBooks" value="Are you sure you want to buy %s books?" />
|
||||||
|
<node name="alreadyBought" value="Book is already bought" />
|
||||||
|
<node name="noAccountInformation" value="Cannot load account state" />
|
||||||
|
<node name="unsufficientFunds" value="This purchase costs %0 and you have only %1" />
|
||||||
|
</node>
|
||||||
<node name="networkBookView">
|
<node name="networkBookView">
|
||||||
<node name="bookInfo" value="Book Info" />
|
<node name="bookInfo" value="Book Info" />
|
||||||
<node name="description" value="Description" />
|
<node name="description" value="Description" />
|
||||||
|
@ -243,6 +252,8 @@
|
||||||
<node name="editInfo" value="Edit" />
|
<node name="editInfo" value="Edit" />
|
||||||
<node name="reloadInfo" value="Reload" />
|
<node name="reloadInfo" value="Reload" />
|
||||||
<node name="topup" value="Top up"/>
|
<node name="topup" value="Top up"/>
|
||||||
|
<node name="pay" value="Pay"/>
|
||||||
|
<node name="refresh" value="Refresh"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="plugin">
|
<node name="plugin">
|
||||||
<node name="installTitle" value="Install plugin"/>
|
<node name="installTitle" value="Install plugin"/>
|
||||||
|
@ -626,6 +637,7 @@
|
||||||
<node name="loadingCatalogInfo" value="Loading catalog information. Please, wait…" />
|
<node name="loadingCatalogInfo" value="Loading catalog information. Please, wait…" />
|
||||||
<node name="loadingNetworkBookInfo" value="Loading book information. Please, wait…" />
|
<node name="loadingNetworkBookInfo" value="Loading book information. Please, wait…" />
|
||||||
<node name="updatingCatalogsList" value="Updating catalogs list. Please, wait…"/>
|
<node name="updatingCatalogsList" value="Updating catalogs list. Please, wait…"/>
|
||||||
|
<node name="updatingAccountInformation" value="Updating account information. Please, wait…"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="networkError">
|
<node name="networkError">
|
||||||
<node name="internalError" value="Internal server error" />
|
<node name="internalError" value="Internal server error" />
|
||||||
|
@ -665,16 +677,6 @@
|
||||||
<node name="languageFilterDialog">
|
<node name="languageFilterDialog">
|
||||||
<node name="title" value="Language filter" />
|
<node name="title" value="Language filter" />
|
||||||
</node>
|
</node>
|
||||||
<node name="purchaseConfirmBox">
|
|
||||||
<node name="title" value="Purchase book" />
|
|
||||||
<node name="message" value="Are you sure you want to buy “%s”?" />
|
|
||||||
<node name="titleSeveralBooks" value="Purchase books" />
|
|
||||||
<node name="messageSeveralBooks" value="Are you sure you want to buy %s books?" />
|
|
||||||
</node>
|
|
||||||
<node name="alreadyPurchasedBox">
|
|
||||||
<node name="title" value="Purchase book" />
|
|
||||||
<node name="message" value="Book is already bought" />
|
|
||||||
</node>
|
|
||||||
</node>
|
</node>
|
||||||
<node name="errorMessage">
|
<node name="errorMessage">
|
||||||
<node name="cannotRunAndroidMarket" value="Cannot access Android Market. Please, install %s manually"/>
|
<node name="cannotRunAndroidMarket" value="Cannot access Android Market. Please, install %s manually"/>
|
||||||
|
|
|
@ -60,13 +60,19 @@ public class BuyBooksActivity extends Activity {
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private NetworkLibrary myLibrary;
|
||||||
|
private INetworkLink myLink;
|
||||||
|
private List<NetworkBookItem> myBooks;
|
||||||
|
private Money myCost;
|
||||||
|
private Money myAccount;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle bundle) {
|
protected void onCreate(Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
|
Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
|
||||||
setContentView(R.layout.buy_book);
|
setContentView(R.layout.buy_book);
|
||||||
|
|
||||||
final NetworkLibrary library = NetworkLibrary.Instance();
|
myLibrary = NetworkLibrary.Instance();
|
||||||
|
|
||||||
final List<NetworkTree.Key> keys =
|
final List<NetworkTree.Key> keys =
|
||||||
(List<NetworkTree.Key>)getIntent().getSerializableExtra(
|
(List<NetworkTree.Key>)getIntent().getSerializableExtra(
|
||||||
|
@ -76,25 +82,43 @@ public class BuyBooksActivity extends Activity {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final List<NetworkBookItem> books = new ArrayList<NetworkBookItem>(keys.size());
|
myBooks = new ArrayList<NetworkBookItem>(keys.size());
|
||||||
for (NetworkTree.Key k : keys) {
|
for (NetworkTree.Key k : keys) {
|
||||||
final NetworkTree tree = library.getTreeByKey(k);
|
final NetworkTree tree = myLibrary.getTreeByKey(k);
|
||||||
if (tree instanceof NetworkBookTree) {
|
if (tree instanceof NetworkBookTree) {
|
||||||
books.add(((NetworkBookTree)tree).Book);
|
myBooks.add(((NetworkBookTree)tree).Book);
|
||||||
} else {
|
} else {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
myCost = Money.ZERO;
|
||||||
|
for (NetworkBookItem b : myBooks) {
|
||||||
|
if (b.getStatus() != NetworkBookItem.Status.CanBePurchased) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final BookBuyUrlInfo info = b.buyInfo();
|
||||||
|
if (info == null || info.Price == null) {
|
||||||
|
// TODO: error message
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
myCost = myCost.add(info.Price);
|
||||||
|
}
|
||||||
|
|
||||||
// we assume all the books are from the same catalog
|
// we assume all the books are from the same catalog
|
||||||
final INetworkLink link = books.get(0).Link;
|
myLink = myBooks.get(0).Link;
|
||||||
final NetworkAuthenticationManager mgr = link.authenticationManager();
|
final NetworkAuthenticationManager mgr = myLink.authenticationManager();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
myAccount = mgr.currentAccount();
|
||||||
|
|
||||||
|
setupUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupUI() {
|
||||||
final ZLResource dialogResource = ZLResource.resource("dialog");
|
final ZLResource dialogResource = ZLResource.resource("dialog");
|
||||||
final ZLResource buttonResource = dialogResource.getResource("button");
|
final ZLResource buttonResource = dialogResource.getResource("button");
|
||||||
|
|
||||||
|
@ -104,39 +128,117 @@ public class BuyBooksActivity extends Activity {
|
||||||
final Button cancelButton =
|
final Button cancelButton =
|
||||||
(Button)findViewById(R.id.buy_book_buttons).findViewById(R.id.cancel_button);
|
(Button)findViewById(R.id.buy_book_buttons).findViewById(R.id.cancel_button);
|
||||||
|
|
||||||
final Runnable buyRunnable = new Runnable() {
|
final ZLResource resource = ZLResource.resource("buyBook");
|
||||||
public void run() {
|
if (myBooks.size() > 1) {
|
||||||
Money cost = Money.ZERO;
|
setTitle(resource.getResource("titleSeveralBooks").getValue());
|
||||||
System.err.println("cost = " + cost);
|
} else {
|
||||||
try {
|
setTitle(resource.getResource("title").getValue());
|
||||||
final Money account = mgr.currentAccount();
|
}
|
||||||
System.err.println("account = " + account);
|
|
||||||
if (account != null) {
|
if (myAccount == null) {
|
||||||
for (NetworkBookItem b : books) {
|
textArea.setText(resource.getResource("noAccountInformation").getValue());
|
||||||
final BookBuyUrlInfo info = b.buyInfo();
|
okButton.setText(buttonResource.getResource("refresh").getValue());
|
||||||
if (b.getStatus() != NetworkBookItem.Status.CanBePurchased) {
|
cancelButton.setText(buttonResource.getResource("cancel").getValue());
|
||||||
continue;
|
okButton.setOnClickListener(new View.OnClickListener() {
|
||||||
}
|
public void onClick(View v) {
|
||||||
if (info == null || info.Price == null) {
|
refreshAccountInformation();
|
||||||
cost = null;
|
}
|
||||||
break;
|
});
|
||||||
}
|
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
cost = cost.add(info.Price);
|
public void onClick(View v) {
|
||||||
System.err.println("cost = " + cost);
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (myCost.compareTo(myAccount) > 0) {
|
||||||
|
textArea.setText(
|
||||||
|
resource.getResource("unsufficientFunds").getValue()
|
||||||
|
.replace("%0", myCost.toString())
|
||||||
|
.replace("%1", myAccount.toString())
|
||||||
|
);
|
||||||
|
okButton.setText(buttonResource.getResource("pay").getValue());
|
||||||
|
cancelButton.setText(buttonResource.getResource("refresh").getValue());
|
||||||
|
okButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
TopupMenuActivity.runMenu(BuyBooksActivity.this, myLink, myCost.subtract(myAccount));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
refreshAccountInformation();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
okButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
UIUtil.wait("purchaseBook", buyRunnable(), BuyBooksActivity.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (myBooks.size() > 1) {
|
||||||
|
textArea.setText(
|
||||||
|
resource.getResource("confirmSeveralBooks").getValue()
|
||||||
|
.replace("%s", String.valueOf(myBooks.size()))
|
||||||
|
);
|
||||||
|
okButton.setText(buttonResource.getResource("buy").getValue());
|
||||||
|
cancelButton.setText(buttonResource.getResource("cancel").getValue());
|
||||||
|
} else if (myBooks.get(0).getStatus() == NetworkBookItem.Status.CanBePurchased) {
|
||||||
|
textArea.setText(
|
||||||
|
resource.getResource("confirm").getValue().replace("%s", myBooks.get(0).Title)
|
||||||
|
);
|
||||||
|
okButton.setText(buttonResource.getResource("buy").getValue());
|
||||||
|
cancelButton.setText(buttonResource.getResource("cancel").getValue());
|
||||||
|
} else {
|
||||||
|
textArea.setText(resource.getResource("alreadyBought").getValue());
|
||||||
|
cancelButton.setText(buttonResource.getResource("ok").getValue());
|
||||||
|
okButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
refreshAccountInformation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshAccountInformation() {
|
||||||
|
UIUtil.wait(
|
||||||
|
"updatingAccountInformation",
|
||||||
|
new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
final NetworkAuthenticationManager mgr = myLink.authenticationManager();
|
||||||
|
try {
|
||||||
|
mgr.refreshAccountInformation();
|
||||||
|
final Money oldAccount = myAccount;
|
||||||
|
myAccount = mgr.currentAccount();
|
||||||
|
if (myAccount != null && !myAccount.equals(oldAccount)) {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
setupUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
cost = cost.subtract(account);
|
myLibrary.invalidateVisibility();
|
||||||
System.err.println("cost = " + cost);
|
myLibrary.synchronize();
|
||||||
} else {
|
} catch (ZLNetworkException e) {
|
||||||
cost = null;
|
// ignore
|
||||||
}
|
}
|
||||||
System.err.println("cost = " + cost);
|
}
|
||||||
if (cost != null && cost.compareTo(Money.ZERO) > 0 && books.size() > 1) {
|
},
|
||||||
// we only throw this exception if there are more than 1 book in list
|
this
|
||||||
// for 1 book we prefer to send request to server and got an error
|
);
|
||||||
throw new ZLNetworkException(NetworkException.ERROR_PURCHASE_NOT_ENOUGH_MONEY);
|
}
|
||||||
}
|
|
||||||
|
private Runnable buyRunnable() {
|
||||||
for (final NetworkBookItem b : books) {
|
return new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
final NetworkAuthenticationManager mgr = myLink.authenticationManager();
|
||||||
|
for (final NetworkBookItem b : myBooks) {
|
||||||
if (b.getStatus() != NetworkBookItem.Status.CanBePurchased) {
|
if (b.getStatus() != NetworkBookItem.Status.CanBePurchased) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -149,62 +251,24 @@ public class BuyBooksActivity extends Activity {
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
} catch (final ZLNetworkException e) {
|
} catch (final ZLNetworkException e) {
|
||||||
if (NetworkException.ERROR_PURCHASE_NOT_ENOUGH_MONEY.equals(e.getCode())) {
|
final ZLResource dialogResource = ZLResource.resource("dialog");
|
||||||
TopupMenuActivity.runMenu(BuyBooksActivity.this, link, cost);
|
final ZLResource buttonResource = dialogResource.getResource("button");
|
||||||
finish();
|
final ZLResource boxResource = dialogResource.getResource("networkError");
|
||||||
} else {
|
runOnUiThread(new Runnable() {
|
||||||
final ZLResource boxResource = dialogResource.getResource("networkError");
|
public void run() {
|
||||||
runOnUiThread(new Runnable() {
|
new AlertDialog.Builder(BuyBooksActivity.this)
|
||||||
public void run() {
|
.setTitle(boxResource.getResource("title").getValue())
|
||||||
new AlertDialog.Builder(BuyBooksActivity.this)
|
.setMessage(e.getMessage())
|
||||||
.setTitle(boxResource.getResource("title").getValue())
|
.setIcon(0)
|
||||||
.setMessage(e.getMessage())
|
.setPositiveButton(buttonResource.getResource("ok").getValue(), null)
|
||||||
.setIcon(0)
|
.create().show();
|
||||||
.setPositiveButton(buttonResource.getResource("ok").getValue(), null)
|
}
|
||||||
.create().show();
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
library.invalidateVisibility();
|
myLibrary.invalidateVisibility();
|
||||||
library.synchronize();
|
myLibrary.synchronize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
okButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
UIUtil.wait("purchaseBook", buyRunnable, BuyBooksActivity.this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (books.size() > 1 || books.get(0).getStatus() == NetworkBookItem.Status.CanBePurchased) {
|
|
||||||
final ZLResource boxResource = dialogResource.getResource("purchaseConfirmBox");
|
|
||||||
if (books.size() == 1) {
|
|
||||||
setTitle(boxResource.getResource("title").getValue());
|
|
||||||
textArea.setText(
|
|
||||||
boxResource.getResource("message").getValue().replace("%s", books.get(0).Title)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
setTitle(boxResource.getResource("titleSeveralBooks").getValue());
|
|
||||||
textArea.setText(
|
|
||||||
boxResource.getResource("messageSeveralBooks").getValue()
|
|
||||||
.replace("%s", String.valueOf(books.size()))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
okButton.setText(buttonResource.getResource("buy").getValue());
|
|
||||||
cancelButton.setText(buttonResource.getResource("cancel").getValue());
|
|
||||||
} else {
|
|
||||||
final ZLResource boxResource = dialogResource.getResource("alreadyPurchasedBox");
|
|
||||||
setTitle(boxResource.getResource("title").getValue());
|
|
||||||
textArea.setText(boxResource.getResource("message").getValue());
|
|
||||||
cancelButton.setText(buttonResource.getResource("ok").getValue());
|
|
||||||
okButton.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ public abstract class NetworkAuthenticationManager {
|
||||||
public abstract void authorise(String password) throws ZLNetworkException;
|
public abstract void authorise(String password) throws ZLNetworkException;
|
||||||
public abstract void logOut();
|
public abstract void logOut();
|
||||||
public abstract BookUrlInfo downloadReference(NetworkBookItem book);
|
public abstract BookUrlInfo downloadReference(NetworkBookItem book);
|
||||||
|
public abstract void refreshAccountInformation() throws ZLNetworkException;
|
||||||
|
|
||||||
public final boolean mayBeAuthorised(boolean useNetwork) {
|
public final boolean mayBeAuthorised(boolean useNetwork) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -267,7 +267,7 @@ public class LitResAuthenticationManager extends NetworkAuthenticationManager {
|
||||||
logOut(false);
|
logOut(false);
|
||||||
throw new ZLNetworkException(NetworkException.ERROR_AUTHENTICATION_FAILED);
|
throw new ZLNetworkException(NetworkException.ERROR_AUTHENTICATION_FAILED);
|
||||||
}
|
}
|
||||||
networkRequest = loadPurchasedBooks();
|
networkRequest = loadPurchasedBooksRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
ZLNetworkException exception = null;
|
ZLNetworkException exception = null;
|
||||||
|
@ -279,7 +279,6 @@ public class LitResAuthenticationManager extends NetworkAuthenticationManager {
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (exception != null) {
|
if (exception != null) {
|
||||||
//loadPurchasedBooksOnError();
|
|
||||||
if (NetworkException.ERROR_AUTHENTICATION_FAILED.equals(exception.getCode())) {
|
if (NetworkException.ERROR_AUTHENTICATION_FAILED.equals(exception.getCode())) {
|
||||||
logOut(false);
|
logOut(false);
|
||||||
}
|
}
|
||||||
|
@ -317,35 +316,41 @@ public class LitResAuthenticationManager extends NetworkAuthenticationManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
purchasedBooksRequest = loadPurchasedBooks();
|
purchasedBooksRequest = loadPurchasedBooksRequest();
|
||||||
accountRequest = loadAccount();
|
accountRequest = loadAccountRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
final LinkedList<ZLNetworkRequest> requests = new LinkedList<ZLNetworkRequest>();
|
final LinkedList<ZLNetworkRequest> requests = new LinkedList<ZLNetworkRequest>();
|
||||||
requests.add(purchasedBooksRequest);
|
requests.add(purchasedBooksRequest);
|
||||||
requests.add(accountRequest);
|
requests.add(accountRequest);
|
||||||
|
|
||||||
ZLNetworkException exception = null;
|
|
||||||
try {
|
try {
|
||||||
ZLNetworkManager.Instance().perform(requests);
|
ZLNetworkManager.Instance().perform(requests);
|
||||||
|
synchronized (this) {
|
||||||
|
myInitializedDataSid = sid;
|
||||||
|
loadPurchasedBooksOnSuccess(purchasedBooksRequest);
|
||||||
|
myAccount = new Money(((LitResPurchaseXMLReader)accountRequest.Reader).Account, "RUB");
|
||||||
|
}
|
||||||
} catch (ZLNetworkException e) {
|
} catch (ZLNetworkException e) {
|
||||||
exception = e;
|
synchronized (this) {
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
if (exception != null) {
|
|
||||||
myInitializedDataSid = null;
|
myInitializedDataSid = null;
|
||||||
loadPurchasedBooksOnError();
|
loadPurchasedBooksOnError();
|
||||||
loadAccountOnError();
|
myAccount = null;
|
||||||
throw exception;
|
|
||||||
}
|
}
|
||||||
myInitializedDataSid = sid;
|
throw e;
|
||||||
loadPurchasedBooksOnSuccess(purchasedBooksRequest);
|
|
||||||
loadAccountOnSuccess(accountRequest);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LitResNetworkRequest loadPurchasedBooks() {
|
@Override
|
||||||
|
public void refreshAccountInformation() throws ZLNetworkException {
|
||||||
|
final LitResNetworkRequest accountRequest = loadAccountRequest();
|
||||||
|
ZLNetworkManager.Instance().perform(accountRequest);
|
||||||
|
synchronized (this) {
|
||||||
|
myAccount = new Money(((LitResPurchaseXMLReader)accountRequest.Reader).Account, "RUB");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LitResNetworkRequest loadPurchasedBooksRequest() {
|
||||||
final String sid = mySidOption.getValue();
|
final String sid = mySidOption.getValue();
|
||||||
final String query = "pages/catalit_browser/";
|
final String query = "pages/catalit_browser/";
|
||||||
|
|
||||||
|
@ -376,28 +381,18 @@ public class LitResAuthenticationManager extends NetworkAuthenticationManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LitResNetworkRequest loadAccount() {
|
private LitResNetworkRequest loadAccountRequest() {
|
||||||
final String sid = mySidOption.getValue();
|
|
||||||
final String query = "pages/purchase_book/";
|
final String query = "pages/purchase_book/";
|
||||||
|
|
||||||
final LitResNetworkRequest request = new LitResNetworkRequest(
|
final LitResNetworkRequest request = new LitResNetworkRequest(
|
||||||
LitResUtil.url(Link, query),
|
LitResUtil.url(Link, query),
|
||||||
new LitResPurchaseXMLReader(Link.getSiteName())
|
new LitResPurchaseXMLReader(Link.getSiteName())
|
||||||
);
|
);
|
||||||
request.addPostParameter("sid", sid);
|
request.addPostParameter("sid", mySidOption.getValue());
|
||||||
request.addPostParameter("art", "0");
|
request.addPostParameter("art", "0");
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadAccountOnError() {
|
|
||||||
myAccount = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAccountOnSuccess(LitResNetworkRequest accountRequest) {
|
|
||||||
LitResPurchaseXMLReader reader = (LitResPurchaseXMLReader)accountRequest.Reader;
|
|
||||||
myAccount = new Money(reader.Account, "RUB");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean passwordRecoverySupported() {
|
public boolean passwordRecoverySupported() {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue