use of org.geometerplus.android.fbreader.network.auth.ActivityNetworkContext in project FBReaderJ by geometer.
the class ProcessHyperlinkAction method openInBrowser.
private void openInBrowser(final String url) {
final Intent intent = new Intent(Intent.ACTION_VIEW);
final boolean externalUrl;
if (BookDownloader.acceptsUri(Uri.parse(url), null)) {
intent.setClass(BaseActivity, BookDownloader.class);
intent.putExtra(BookDownloaderService.Key.SHOW_NOTIFICATIONS, BookDownloaderService.Notifications.ALL);
externalUrl = false;
} else {
externalUrl = true;
}
final NetworkLibrary nLibrary = NetworkLibrary.Instance(Paths.systemInfo(BaseActivity));
new Thread(new Runnable() {
public void run() {
if (!url.startsWith("fbreader-action:")) {
try {
nLibrary.initialize(new ActivityNetworkContext(BaseActivity));
} catch (ZLNetworkException e) {
e.printStackTrace();
UIMessageUtil.showMessageText(BaseActivity, e.getMessage());
return;
}
}
intent.setData(Util.rewriteUri(Uri.parse(nLibrary.rewriteUrl(url, externalUrl))));
BaseActivity.runOnUiThread(new Runnable() {
public void run() {
try {
OrientationUtil.startActivity(BaseActivity, intent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
});
}
}).start();
}
Aggregations