mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
fixed adding catalog from external plugin
This commit is contained in:
parent
53ec85193b
commit
b826f322bd
4 changed files with 106 additions and 74 deletions
|
@ -22,17 +22,17 @@ package org.geometerplus.android.fbreader.network;
|
|||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.*;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.geometerplus.zlibrary.core.network.*;
|
||||
import org.geometerplus.zlibrary.core.network.ZLNetworkContext;
|
||||
import org.geometerplus.zlibrary.core.options.Config;
|
||||
import org.geometerplus.zlibrary.core.util.MimeType;
|
||||
|
||||
import org.geometerplus.fbreader.network.*;
|
||||
import org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager;
|
||||
import org.geometerplus.fbreader.network.opds.OPDSCustomNetworkLink;
|
||||
import org.geometerplus.fbreader.network.urlInfo.*;
|
||||
import org.geometerplus.fbreader.network.urlInfo.BookUrlInfo;
|
||||
import org.geometerplus.fbreader.network.urlInfo.UrlInfo;
|
||||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
import org.geometerplus.android.util.PackageUtil;
|
||||
|
@ -136,53 +136,4 @@ public abstract class Util implements UserRegistrationConstants {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static final BroadcastReceiver catalogInfoReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final List<String> urls =
|
||||
getResultExtras(true).getStringArrayList("fbreader.catalog.ids");
|
||||
if (urls == null || urls.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final NetworkLibrary library = NetworkLibrary.Instance();
|
||||
for (String u : urls) {
|
||||
if (library.getLinkByUrl(u) != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final ICustomNetworkLink link = new OPDSCustomNetworkLink(
|
||||
INetworkLink.INVALID_ID,
|
||||
INetworkLink.Type.Custom,
|
||||
null, null, null,
|
||||
new UrlInfoCollection<UrlInfoWithDate>(new UrlInfoWithDate(
|
||||
UrlInfo.Type.Catalog, u, MimeType.APP_ATOM_XML
|
||||
))
|
||||
);
|
||||
final Runnable loader = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
link.reloadInfo(new QuietNetworkContext(), false, false);
|
||||
library.addCustomLink(link);
|
||||
} catch (ZLNetworkException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
new Thread(loader).start();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void requestCatalogPlugins(Activity activity) {
|
||||
activity.sendOrderedBroadcast(
|
||||
new Intent(EXTRA_CATALOG_ACTION),
|
||||
null,
|
||||
catalogInfoReceiver,
|
||||
null,
|
||||
Activity.RESULT_OK,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue