Search in sources :

Example 1 with OPDSCustomNetworkLink

use of org.geometerplus.fbreader.network.opds.OPDSCustomNetworkLink in project FBReaderJ by geometer.

the class AddCustomCatalogActivity method loadInfoByUri.

private void loadInfoByUri(Uri uri) {
    String textUrl = uri.toString();
    if (isEmptyString(uri.getScheme())) {
        textUrl = "http://" + textUrl;
        uri = Uri.parse(textUrl);
    }
    setTextById(R.id.add_custom_catalog_url, textUrl);
    if (isEmptyString(uri.getHost())) {
        setErrorByKey("invalidUrl");
        return;
    }
    final UrlInfoCollection<UrlInfoWithDate> infos = new UrlInfoCollection<UrlInfoWithDate>();
    infos.addInfo(new UrlInfoWithDate(UrlInfo.Type.Catalog, textUrl, MimeType.APP_ATOM_XML));
    myLink = new OPDSCustomNetworkLink(Util.networkLibrary(this), ICustomNetworkLink.INVALID_ID, myType, null, null, null, infos);
    final Runnable loadInfoRunnable = new Runnable() {

        private String myError;

        public void run() {
            try {
                myError = null;
                myLink.reloadInfo(myNetworkContext, false, false);
            } catch (ZLNetworkException e) {
                myError = e.getMessage();
            }
            runOnUiThread(new Runnable() {

                public void run() {
                    if (myError == null) {
                        setTextById(R.id.add_custom_catalog_title, myLink.getTitle());
                        setTextById(R.id.add_custom_catalog_summary, myLink.getSummary());
                        setExtraFieldsVisibility(true);
                    } else {
                        myLink = null;
                    }
                }
            });
            setErrorText(myError);
        }
    };
    UIUtil.wait("loadingCatalogInfo", loadInfoRunnable, this);
}
Also used : ZLNetworkException(org.geometerplus.zlibrary.core.network.ZLNetworkException) OPDSCustomNetworkLink(org.geometerplus.fbreader.network.opds.OPDSCustomNetworkLink)

Aggregations

OPDSCustomNetworkLink (org.geometerplus.fbreader.network.opds.OPDSCustomNetworkLink)1 ZLNetworkException (org.geometerplus.zlibrary.core.network.ZLNetworkException)1