mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
url rewriting for external references has been fixed
This commit is contained in:
parent
bcbcf2db42
commit
b243b2e704
2 changed files with 28 additions and 12 deletions
|
@ -227,7 +227,11 @@ public class NetworkLibrary {
|
||||||
myLinks = new CompositeList(linksList, new LinksComparator());
|
myLinks = new CompositeList(linksList, new LinksComparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize() throws ZLNetworkException {
|
private boolean myIsAlreadyInitialized;
|
||||||
|
public synchronized void initialize() throws ZLNetworkException {
|
||||||
|
if (myIsAlreadyInitialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final LinksComparator comparator = new LinksComparator();
|
final LinksComparator comparator = new LinksComparator();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -243,18 +247,21 @@ public class NetworkLibrary {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkDatabase.Instance().loadCustomLinks(
|
final NetworkDatabase db = NetworkDatabase.Instance();
|
||||||
new NetworkDatabase.ICustomLinksHandler() {
|
if (db != null) {
|
||||||
public void handleCustomLinkData(int id, String siteName,
|
db.loadCustomLinks(
|
||||||
String title, String summary, String icon, Map<String, String> links) {
|
new NetworkDatabase.ICustomLinksHandler() {
|
||||||
final ICustomNetworkLink link = OPDSLinkReader.createCustomLink(id, siteName, title, summary, icon, links);
|
public void handleCustomLinkData(int id, String siteName,
|
||||||
if (link != null) {
|
String title, String summary, String icon, Map<String, String> links) {
|
||||||
addLinkInternal(myCustomLinks, link, comparator);
|
final ICustomNetworkLink link = OPDSLinkReader.createCustomLink(id, siteName, title, summary, icon, links);
|
||||||
link.setSaveLinkListener(myChangesListener);
|
if (link != null) {
|
||||||
|
addLinkInternal(myCustomLinks, link, comparator);
|
||||||
|
link.setSaveLinkListener(myChangesListener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
}
|
||||||
|
|
||||||
/*testDate(new ATOMUpdated(2010, 1, 1, 1, 0, 0, 0, 2, 0),
|
/*testDate(new ATOMUpdated(2010, 1, 1, 1, 0, 0, 0, 2, 0),
|
||||||
new ATOMUpdated(2009, 12, 31, 23, 0, 0, 0, 0, 0));
|
new ATOMUpdated(2009, 12, 31, 23, 0, 0, 0, 0, 0));
|
||||||
|
@ -274,6 +281,7 @@ public class NetworkLibrary {
|
||||||
new ATOMUpdated(2012, 2, 15, 23, 40, 1, 0, 3, 30));
|
new ATOMUpdated(2012, 2, 15, 23, 40, 1, 0, 3, 30));
|
||||||
testDate(new ATOMUpdated(2012, 2, 15, 23, 40, 0, 0.001f, 3, 30),
|
testDate(new ATOMUpdated(2012, 2, 15, 23, 40, 0, 0.001f, 3, 30),
|
||||||
new ATOMUpdated(2012, 2, 15, 23, 40, 0, 0, 3, 30));*/
|
new ATOMUpdated(2012, 2, 15, 23, 40, 0, 0, 3, 30));*/
|
||||||
|
myIsAlreadyInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private void testDate(ATOMDateConstruct date1, ATOMDateConstruct date2) {
|
/*private void testDate(ATOMDateConstruct date1, ATOMDateConstruct date2) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.net.Uri;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.library.ZLibrary;
|
import org.geometerplus.zlibrary.core.library.ZLibrary;
|
||||||
import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile;
|
import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile;
|
||||||
|
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.ui.android.R;
|
import org.geometerplus.zlibrary.ui.android.R;
|
||||||
import org.geometerplus.zlibrary.ui.android.view.ZLAndroidPaintContext;
|
import org.geometerplus.zlibrary.ui.android.view.ZLAndroidPaintContext;
|
||||||
|
@ -38,6 +39,8 @@ import org.geometerplus.zlibrary.ui.android.dialogs.ZLAndroidDialogManager;
|
||||||
import org.geometerplus.android.fbreader.network.BookDownloader;
|
import org.geometerplus.android.fbreader.network.BookDownloader;
|
||||||
import org.geometerplus.android.fbreader.network.BookDownloaderService;
|
import org.geometerplus.android.fbreader.network.BookDownloaderService;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.network.NetworkLibrary;
|
||||||
|
|
||||||
public final class ZLAndroidLibrary extends ZLibrary {
|
public final class ZLAndroidLibrary extends ZLibrary {
|
||||||
private ZLAndroidActivity myActivity;
|
private ZLAndroidActivity myActivity;
|
||||||
private final Application myApplication;
|
private final Application myApplication;
|
||||||
|
@ -81,7 +84,12 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
||||||
externalUrl = false;
|
externalUrl = false;
|
||||||
}
|
}
|
||||||
// FIXME: initialize network library and use rewriteUrl!!!
|
// FIXME: initialize network library and use rewriteUrl!!!
|
||||||
//reference = NetworkLibrary.Instance().rewriteUrl(reference, externalUrl);
|
final NetworkLibrary nLibrary = NetworkLibrary.Instance();
|
||||||
|
try {
|
||||||
|
nLibrary.initialize();
|
||||||
|
} catch (ZLNetworkException e) {
|
||||||
|
}
|
||||||
|
reference = NetworkLibrary.Instance().rewriteUrl(reference, externalUrl);
|
||||||
intent.setData(Uri.parse(reference));
|
intent.setData(Uri.parse(reference));
|
||||||
myActivity.startActivity(intent);
|
myActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue