1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 18:29:23 +02:00

custom catalog activity (in progress); duplicate custom catalogs are allowed

This commit is contained in:
Nikolay Pultsin 2011-02-28 05:51:21 +03:00
parent 4a306a0427
commit 1adfbf95bd
10 changed files with 132 additions and 299 deletions

3
TODO.CustomCatalog Normal file
View file

@ -0,0 +1,3 @@
* hide keyboard after link loading
* custom link editing
* start FBReader in new task

View file

@ -41,7 +41,7 @@ import org.geometerplus.android.util.UIUtil;
public class AddCustomCatalogActivity extends Activity { public class AddCustomCatalogActivity extends Activity {
private ZLResource myResource; private ZLResource myResource;
private String myURL; private ICustomNetworkLink myLink;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@ -63,28 +63,7 @@ public class AddCustomCatalogActivity extends Activity {
setupButton( setupButton(
R.id.add_custom_catalog_ok_button, "ok", new View.OnClickListener() { R.id.add_custom_catalog_ok_button, "ok", new View.OnClickListener() {
public void onClick(View view) { public void onClick(View view) {
if (isEmptyString(myURL)) { onOkButton();
final String url = getTextById(R.id.add_custom_catalog_url);
if (isEmptyString(url)) {
setErrorByKey("urlIsEmpty");
} else {
try {
Uri uri = Uri.parse(url);
if (isEmptyString(uri.getScheme())) {
uri = Uri.parse("http://" + url);
}
if (isEmptyString(uri.getHost())) {
setErrorByKey("invalidUrl");
} else {
loadInfoByUri(uri);
}
} catch (Throwable t) {
setErrorByKey("invalidUrl");
}
}
} else {
gotoNetworkLibrary();
}
} }
} }
); );
@ -101,11 +80,54 @@ public class AddCustomCatalogActivity extends Activity {
loadInfoByUri(uri); loadInfoByUri(uri);
setExtraFieldsVisibility(true); setExtraFieldsVisibility(true);
} else { } else {
myURL = null; myLink = null;
setExtraFieldsVisibility(false); setExtraFieldsVisibility(false);
} }
} }
private void onOkButton() {
final String textUrl = getTextById(R.id.add_custom_catalog_url);
if (isEmptyString(textUrl)) {
setErrorByKey("urlIsEmpty");
return;
}
final String title = getTextById(R.id.add_custom_catalog_title);
final String summary = getTextById(R.id.add_custom_catalog_summary);
Uri uri = null;
try {
uri = Uri.parse(textUrl);
if (isEmptyString(uri.getScheme())) {
uri = Uri.parse("http://" + textUrl);
}
if (isEmptyString(uri.getHost())) {
setErrorByKey("invalidUrl");
return;
}
} catch (Throwable t) {
setErrorByKey("invalidUrl");
return;
}
if (myLink == null) {
loadInfoByUri(uri);
} else if (isEmptyString(title)) {
setErrorByKey("titleIsEmpty");
} else {
startActivity(
new Intent(
NetworkLibraryActivity.ADD_CATALOG,
uri,
AddCustomCatalogActivity.this,
NetworkLibraryActivity.class
)
.putExtra(NetworkLibraryActivity.ADD_CATALOG_TITLE_KEY, title)
.putExtra(NetworkLibraryActivity.ADD_CATALOG_SUMMARY_KEY, summary)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP)
);
finish();
}
}
private boolean isEmptyString(String s) { private boolean isEmptyString(String s) {
return s == null || s.length() == 0; return s == null || s.length() == 0;
} }
@ -120,14 +142,6 @@ public class AddCustomCatalogActivity extends Activity {
}); });
} }
private void gotoNetworkLibrary() {
startActivity(
new Intent(AddCustomCatalogActivity.this, NetworkLibraryActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP)
);
finish();
}
private void setTextById(int id, String text) { private void setTextById(int id, String text) {
((TextView)findViewById(id)).setText(text); ((TextView)findViewById(id)).setText(text);
} }
@ -197,15 +211,15 @@ public class AddCustomCatalogActivity extends Activity {
} }
private void loadInfoByUri(Uri uri) { private void loadInfoByUri(Uri uri) {
myURL = uri.toString(); String textUrl = uri.toString();
if (isEmptyString(uri.getScheme())) { if (isEmptyString(uri.getScheme())) {
myURL = "http://" + myURL; textUrl = "http://" + textUrl;
uri = Uri.parse(myURL); uri = Uri.parse(textUrl);
} else if ("opds".equals(uri.getScheme())) { } else if ("opds".equals(uri.getScheme())) {
myURL = "http" + uri.toString().substring(4); textUrl = "http" + uri.toString().substring(4);
} }
setTextById(R.id.add_custom_catalog_url, myURL); setTextById(R.id.add_custom_catalog_url, textUrl);
String siteName = uri.getHost(); String siteName = uri.getHost();
if (isEmptyString(siteName)) { if (isEmptyString(siteName)) {
setErrorByKey("invalidUrl"); setErrorByKey("invalidUrl");
@ -215,8 +229,7 @@ public class AddCustomCatalogActivity extends Activity {
if (siteName.startsWith("www.")) { if (siteName.startsWith("www.")) {
siteName = siteName.substring(4); siteName = siteName.substring(4);
} }
final ICustomNetworkLink link = myLink = OPDSLinkReader.createCustomLink(siteName, null, null, textUrl);
OPDSLinkReader.createCustomLinkWithoutInfo(siteName, myURL);
final Runnable loadInfoRunnable = new Runnable() { final Runnable loadInfoRunnable = new Runnable() {
private String myError; private String myError;
@ -224,15 +237,15 @@ public class AddCustomCatalogActivity extends Activity {
public void run() { public void run() {
try { try {
myError = null; myError = null;
link.reloadInfo(); myLink.reloadInfo();
} catch (ZLNetworkException e) { } catch (ZLNetworkException e) {
myError = e.getMessage(); myError = e.getMessage();
} }
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
if (myError == null) { if (myError == null) {
setTextById(R.id.add_custom_catalog_title, link.getTitle()); setTextById(R.id.add_custom_catalog_title, myLink.getTitle());
setTextById(R.id.add_custom_catalog_summary, link.getSummary()); setTextById(R.id.add_custom_catalog_summary, myLink.getSummary());
setExtraFieldsVisibility(true); setExtraFieldsVisibility(true);
} else { } else {
runErrorDialog(myError); runErrorDialog(myError);

View file

@ -1,238 +0,0 @@
/*
* Copyright (C) 2010-2011 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
package org.geometerplus.android.fbreader.network;
import android.app.Dialog;
import android.app.AlertDialog;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextView;
import android.content.DialogInterface;
import org.geometerplus.zlibrary.core.resources.ZLResource;
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
import org.geometerplus.zlibrary.ui.android.R;
import org.geometerplus.android.util.UIUtil;
import org.geometerplus.fbreader.network.*;
import org.geometerplus.fbreader.network.opds.OPDSLinkReader;
class CustomCatalogDialog extends NetworkDialog {
private String myTitle;
private String myUrl;
private String mySummary;
private boolean myLinkWithoutInfo;
public CustomCatalogDialog() {
super("CustomCatalogDialog");
}
@Override
protected void clearData() {
myTitle = myUrl = mySummary = null;
myLinkWithoutInfo = false;
}
@Override
protected View createLayout() {
final View layout = myActivity.getLayoutInflater().inflate(R.layout.network_custom_catalog_dialog, null);
((TextView) layout.findViewById(R.id.network_catalog_title_text)).setText(myResource.getResource("catalogTitle").getValue());
((TextView) layout.findViewById(R.id.network_catalog_url_text)).setText(myResource.getResource("catalogUrl").getValue());
((TextView) layout.findViewById(R.id.network_catalog_summary_text)).setText(myResource.getResource("catalogSummary").getValue());
((TextView) layout.findViewById(R.id.network_catalog_title_example)).setText(myResource.getResource("catalogTitleExample").getValue());
((TextView) layout.findViewById(R.id.network_catalog_url_example)).setText(myResource.getResource("catalogUrlExample").getValue());
((TextView) layout.findViewById(R.id.network_catalog_summary_example)).setText(myResource.getResource("catalogSummaryExample").getValue());
return layout;
}
@Override
protected void onPositive(DialogInterface dialog) {
AlertDialog alert = (AlertDialog) dialog;
myTitle = ((TextView) alert.findViewById(R.id.network_catalog_title)).getText().toString().trim();
myUrl = ((TextView) alert.findViewById(R.id.network_catalog_url)).getText().toString().trim();
mySummary = ((TextView) alert.findViewById(R.id.network_catalog_summary)).getText().toString().trim();
if (myTitle.length() == 0) {
myTitle = null;
if (myLink != null) {
final String err = myResource.getResource("titleIsEmpty").getValue();
sendError(true, false, err);
return;
}
}
if (myUrl.length() == 0) {
myUrl = null;
final String err = myResource.getResource("urlIsEmpty").getValue();
sendError(true, false, err);
return;
}
if (mySummary.length() == 0) {
mySummary = null;
}
Uri uri = Uri.parse(myUrl);
if (uri.getScheme() == null) {
myUrl = "http://" + myUrl;
uri = Uri.parse(myUrl);
}
String siteName = uri.getHost();
if (siteName == null) {
final String err = myResource.getResource("invalidUrl").getValue();
sendError(true, false, err);
return;
}
if (siteName.startsWith("www.")) {
siteName = siteName.substring(4);
}
final NetworkLibrary library = NetworkLibrary.Instance();
if (myLink != null && library.hasCustomLinkTitle(myTitle, myLink)) {
final String err = myResource.getResource("titleAlreadyExists").getValue();
sendError(true, false, err);
return;
}
if (library.hasCustomLinkSite(siteName, myLink)) {
final String err = myResource.getResource("siteAlreadyExists").getValue();
sendError(true, false, err);
return;
}
if (myLink != null) {
final ICustomNetworkLink link = (ICustomNetworkLink) myLink;
link.setSiteName(siteName);
link.setTitle(myTitle);
link.setSummary(mySummary);
link.setLink(INetworkLink.URL_MAIN, myUrl);
if (myLinkWithoutInfo) {
NetworkLibrary.Instance().addCustomLink(link);
myLinkWithoutInfo = false;
} else {
link.saveLink();
}
sendSuccess(true);
return;
}
myLinkWithoutInfo = true;
myLink = OPDSLinkReader.createCustomLinkWithoutInfo(siteName, myUrl);
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
final String err = (String) msg.obj;
if (err != null) {
final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_NEGATIVE) {
sendSuccess(true);
} else {
if (which == DialogInterface.BUTTON_NEUTRAL) {
myLinkWithoutInfo = false;
myLink = null;
}
sendError(true, false, null);
}
}
};
final ZLResource dialogResource = ZLResource.resource("dialog");
final ZLResource boxResource = dialogResource.getResource("networkError");
final ZLResource buttonResource = dialogResource.getResource("button");
new AlertDialog.Builder(myActivity)
.setTitle(boxResource.getResource("title").getValue())
.setMessage(err)
.setIcon(0)
.setPositiveButton(buttonResource.getResource("continue").getValue(), listener)
.setNeutralButton(buttonResource.getResource("editUrl").getValue(), listener)
.setNegativeButton(buttonResource.getResource("cancel").getValue(), listener)
.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
listener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);
}
})
.create().show();
} else {
sendError(true, false, null);
}
}
};
final Runnable loadInfoRunnable = new Runnable() {
public void run() {
String error = null;
try {
((ICustomNetworkLink)myLink).reloadInfo();
} catch (ZLNetworkException e) {
error = e.getMessage();
}
handler.sendMessage(handler.obtainMessage(0, error));
}
};
UIUtil.wait("loadingCatalogInfo", loadInfoRunnable, myActivity);
}
@Override
protected void onNegative(DialogInterface dialog) {
sendCancel(false);
}
@Override
public void prepareDialogInternal(Dialog dialog) {
if (myLink != null) {
if (myTitle == null) myTitle = myLink.getTitle();
if (myUrl == null) myUrl = myLink.getLink(INetworkLink.URL_MAIN);
if (mySummary == null) mySummary = myLink.getSummary();
}
((TextView) dialog.findViewById(R.id.network_catalog_title)).setText(myTitle);
((TextView) dialog.findViewById(R.id.network_catalog_url)).setText(myUrl);
((TextView) dialog.findViewById(R.id.network_catalog_summary)).setText(mySummary);
final int examplesVisibility = (myLink == null || myLinkWithoutInfo) ? View.VISIBLE : View.GONE;
dialog.findViewById(R.id.network_catalog_title_example).setVisibility(examplesVisibility);
dialog.findViewById(R.id.network_catalog_url_example).setVisibility(examplesVisibility);
dialog.findViewById(R.id.network_catalog_summary_example).setVisibility(examplesVisibility);
final int groupsVisibility = (myLink != null) ? View.VISIBLE : View.GONE;
dialog.findViewById(R.id.network_catalog_title_group).setVisibility(groupsVisibility);
dialog.findViewById(R.id.network_catalog_summary_group).setVisibility(groupsVisibility);
final TextView error = (TextView) dialog.findViewById(R.id.network_catalog_error);
if (myErrorMessage == null) {
error.setVisibility(View.GONE);
error.setText("");
} else {
error.setVisibility(View.VISIBLE);
error.setText(myErrorMessage);
}
View dlgView = dialog.findViewById(R.id.network_custom_catalog_dialog);
dlgView.invalidate();
dlgView.requestLayout();
}
}

View file

@ -246,7 +246,7 @@ class NetworkCatalogActions extends NetworkTreeActions {
new RefillAccountActions().runStandalone(activity, ((RefillAccountTree)activity.getDefaultTree()).Link); new RefillAccountActions().runStandalone(activity, ((RefillAccountTree)activity.getDefaultTree()).Link);
return true; return true;
case CUSTOM_CATALOG_EDIT: case CUSTOM_CATALOG_EDIT:
NetworkDialog.show(activity, NetworkDialog.DIALOG_CUSTOM_CATALOG, ((NetworkCatalogTree)tree).Item.Link, null); //NetworkDialog.show(activity, NetworkDialog.DIALOG_CUSTOM_CATALOG, ((NetworkCatalogTree)tree).Item.Link, null);
return true; return true;
case CUSTOM_CATALOG_REMOVE: case CUSTOM_CATALOG_REMOVE:
removeCustomLink((ICustomNetworkLink)((NetworkCatalogTree)tree).Item.Link); removeCustomLink((ICustomNetworkLink)((NetworkCatalogTree)tree).Item.Link);

View file

@ -39,7 +39,6 @@ abstract class NetworkDialog {
// dialog identifiers // dialog identifiers
public static final int DIALOG_AUTHENTICATION = 0; public static final int DIALOG_AUTHENTICATION = 0;
public static final int DIALOG_CUSTOM_CATALOG = 1;
private static final TreeMap<Integer, NetworkDialog> ourInstances = new TreeMap<Integer, NetworkDialog>(); private static final TreeMap<Integer, NetworkDialog> ourInstances = new TreeMap<Integer, NetworkDialog>();
@ -50,9 +49,6 @@ abstract class NetworkDialog {
case DIALOG_AUTHENTICATION: case DIALOG_AUTHENTICATION:
dlg = new AuthenticationDialog(); dlg = new AuthenticationDialog();
break; break;
case DIALOG_CUSTOM_CATALOG:
dlg = new CustomCatalogDialog();
break;
} }
if (dlg != null) { if (dlg != null) {
dlg.myId = id; dlg.myId = id;

View file

@ -24,6 +24,7 @@ import java.util.*;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
@ -40,9 +41,17 @@ import org.geometerplus.android.util.UIUtil;
import org.geometerplus.fbreader.network.NetworkTree; import org.geometerplus.fbreader.network.NetworkTree;
import org.geometerplus.fbreader.network.NetworkLibrary; import org.geometerplus.fbreader.network.NetworkLibrary;
import org.geometerplus.fbreader.network.ICustomNetworkLink;
import org.geometerplus.fbreader.network.opds.OPDSLinkReader;
public class NetworkLibraryActivity extends NetworkBaseActivity { public class NetworkLibraryActivity extends NetworkBaseActivity {
final static String ADD_CATALOG = "android.fbreader.action.ADD_CATALOG";
final static String ADD_CATALOG_TITLE_KEY = "title";
final static String ADD_CATALOG_SUMMARY_KEY = "summary";
private NetworkTree myTree; private NetworkTree myTree;
private volatile Intent myIntent;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@ -50,6 +59,40 @@ public class NetworkLibraryActivity extends NetworkBaseActivity {
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
myIntent = getIntent();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
processIntent(intent);
}
private void processIntent(Intent intent) {
if (ADD_CATALOG.equals(intent.getAction())) {
final Uri uri = intent.getData();
final String title = intent.getStringExtra(ADD_CATALOG_TITLE_KEY);
final String summary = intent.getStringExtra(ADD_CATALOG_SUMMARY_KEY);
if (uri != null && title != null) {
final ICustomNetworkLink link = OPDSLinkReader.createCustomLink(
uri.getHost(), title, summary, uri.toString()
);
if (link != null) {
runOnUiThread(new Runnable() {
public void run() {
final NetworkLibrary library = NetworkLibrary.Instance();
library.addCustomLink(link);
library.updateChildren();
library.synchronize();
NetworkView.Instance().fireModelChangedAsync();
getListView().invalidateViews();
}
});
}
}
}
} }
private void prepareView() { private void prepareView() {
@ -74,6 +117,10 @@ public class NetworkLibraryActivity extends NetworkBaseActivity {
} }
} else { } else {
prepareView(); prepareView();
if (myIntent != null) {
processIntent(myIntent);
myIntent = null;
}
} }
} }
@ -114,6 +161,10 @@ public class NetworkLibraryActivity extends NetworkBaseActivity {
String error = null; String error = null;
try { try {
NetworkView.Instance().initialize(); NetworkView.Instance().initialize();
if (myActivity.myIntent != null) {
myActivity.processIntent(myActivity.myIntent);
myActivity.myIntent = null;
}
} catch (ZLNetworkException e) { } catch (ZLNetworkException e) {
error = e.getMessage(); error = e.getMessage();
} }

View file

@ -41,7 +41,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
private void migrate() { private void migrate() {
final int version = myDatabase.getVersion(); final int version = myDatabase.getVersion();
final int currentCodeVersion = 1; final int currentCodeVersion = 2;
if (version >= currentCodeVersion) { if (version >= currentCodeVersion) {
return; return;
} }
@ -49,12 +49,14 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
switch (version) { switch (version) {
case 0: case 0:
createTables(); createTables();
case 1:
updateTables1();
} }
myDatabase.setTransactionSuccessful(); myDatabase.setTransactionSuccessful();
myDatabase.endTransaction(); myDatabase.endTransaction();
myDatabase.execSQL("VACUUM"); myDatabase.execSQL("VACUUM");
myDatabase.setVersion(currentCodeVersion); //myDatabase.setVersion(currentCodeVersion);
} }
protected void executeAsATransaction(Runnable actions) { protected void executeAsATransaction(Runnable actions) {
@ -155,7 +157,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
if (dbValue == null) { if (dbValue == null) {
if (myInsertCustomLinkUrlStatement == null) { if (myInsertCustomLinkUrlStatement == null) {
myInsertCustomLinkUrlStatement = myDatabase.compileStatement( myInsertCustomLinkUrlStatement = myDatabase.compileStatement(
"INSERT INTO CustomLinkUrls(url,link_id,key) VALUES (?,?,?)"); "INSERT OR REPLACE INTO CustomLinkUrls(url,link_id,key) VALUES (?,?,?)");
} }
urlStatement = myInsertCustomLinkUrlStatement; urlStatement = myInsertCustomLinkUrlStatement;
} else if (!value.equals(dbValue)) { } else if (!value.equals(dbValue)) {
@ -230,4 +232,17 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
"url TEXT NOT NULL," + "url TEXT NOT NULL," +
"CONSTRAINT CustomLinkUrls_PK PRIMARY KEY (key, link_id))"); "CONSTRAINT CustomLinkUrls_PK PRIMARY KEY (key, link_id))");
} }
private void updateTables1() {
myDatabase.execSQL("ALTER TABLE CustomLinks RENAME TO CustomLinks_Obsolete");
myDatabase.execSQL(
"CREATE TABLE CustomLinks(" +
"link_id INTEGER PRIMARY KEY," +
"title TEXT NOT NULL," +
"site_name TEXT NOT NULL," +
"summary TEXT," +
"icon TEXT)");
myDatabase.execSQL("INSERT INTO CustomLinks (link_id,title,site_name,summary,icon) SELECT link_id,title,site_name,summary,icon FROM CustomLinks_Obsolete");
myDatabase.execSQL("DROP TABLE CustomLinks_Obsolete");
}
} }

View file

@ -303,11 +303,6 @@ public class NetworkLibrary {
myUpdateVisibility = true; myUpdateVisibility = true;
} }
private static boolean linksEqual(INetworkLink l1, INetworkLink l2) {
return l1 == l2 || l1.getSiteName().equals(l2.getSiteName());
}
private static boolean linkIsInvalid(INetworkLink link, INetworkLink nodeLink) { private static boolean linkIsInvalid(INetworkLink link, INetworkLink nodeLink) {
if (link instanceof ICustomNetworkLink) { if (link instanceof ICustomNetworkLink) {
if (link != nodeLink) { if (link != nodeLink) {
@ -347,7 +342,7 @@ public class NetworkLibrary {
continue; continue;
} }
final INetworkLink nodeLink = ((NetworkCatalogTree) currentNode).Item.Link; final INetworkLink nodeLink = ((NetworkCatalogTree) currentNode).Item.Link;
if (linksEqual(link, nodeLink)) { if (link == nodeLink) {
if (linkIsInvalid(link, nodeLink)) { if (linkIsInvalid(link, nodeLink)) {
toRemove.add(currentNode); toRemove.add(currentNode);
} else { } else {
@ -360,7 +355,7 @@ public class NetworkLibrary {
INetworkLink newNodeLink = null; INetworkLink newNodeLink = null;
for (int j = i; j < links.size(); ++j) { for (int j = i; j < links.size(); ++j) {
final INetworkLink jlnk = links.get(j); final INetworkLink jlnk = links.get(j);
if (linksEqual(nodeLink, jlnk)) { if (nodeLink == jlnk) {
newNodeLink = jlnk; newNodeLink = jlnk;
break; break;
} }

View file

@ -33,9 +33,7 @@ import org.geometerplus.fbreader.network.ICustomNetworkLink;
import org.geometerplus.fbreader.network.INetworkLink; import org.geometerplus.fbreader.network.INetworkLink;
import org.geometerplus.fbreader.network.NetworkException; import org.geometerplus.fbreader.network.NetworkException;
class OPDSCustomLink extends OPDSNetworkLink implements ICustomNetworkLink { class OPDSCustomLink extends OPDSNetworkLink implements ICustomNetworkLink {
private int myId; private int myId;
private SaveLinkListener myListener; private SaveLinkListener myListener;

View file

@ -46,10 +46,10 @@ public class OPDSLinkReader {
return new OPDSCustomLink(id, siteName, title, summary, icon, links); return new OPDSCustomLink(id, siteName, title, summary, icon, links);
} }
public static ICustomNetworkLink createCustomLinkWithoutInfo(String siteName, String url) { public static ICustomNetworkLink createCustomLink(String siteName, String title, String summary, String url) {
final HashMap<String, String> links = new HashMap<String, String>(); final HashMap<String, String> links = new HashMap<String, String>();
links.put(INetworkLink.URL_MAIN, url); links.put(INetworkLink.URL_MAIN, url);
return new OPDSCustomLink(ICustomNetworkLink.INVALID_ID, siteName, null, null, null, links); return new OPDSCustomLink(ICustomNetworkLink.INVALID_ID, siteName, title, summary, null, links);
} }
public static final int CACHE_LOAD = 0; public static final int CACHE_LOAD = 0;