mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
cleanup
This commit is contained in:
parent
454c3c9cb6
commit
73b71c36eb
8 changed files with 29 additions and 42 deletions
|
@ -28,20 +28,18 @@ import org.geometerplus.fbreader.network.NetworkTree;
|
|||
import org.geometerplus.fbreader.network.tree.AddCustomCatalogItemTree;
|
||||
|
||||
class AddCustomCatalogItemActions extends NetworkTreeActions {
|
||||
public static final int RUN_ITEM_ID = 0;
|
||||
|
||||
@Override
|
||||
public boolean canHandleTree(NetworkTree tree) {
|
||||
return tree instanceof AddCustomCatalogItemTree;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildContextMenu(Activity activity, ContextMenu menu, NetworkTree tree) {
|
||||
public void buildContextMenu(NetworkLibraryActivity activity, ContextMenu menu, NetworkTree tree) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultActionCode(NetworkLibraryActivity activity, NetworkTree tree) {
|
||||
return RUN_ITEM_ID;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,15 +54,11 @@ class AddCustomCatalogItemActions extends NetworkTreeActions {
|
|||
|
||||
@Override
|
||||
public boolean runAction(NetworkLibraryActivity activity, NetworkTree tree, int actionCode) {
|
||||
switch (actionCode) {
|
||||
case RUN_ITEM_ID:
|
||||
addCustomCatalog(activity);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
addCustomCatalog(activity);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void addCustomCatalog(Activity activity) {
|
||||
static void addCustomCatalog(Activity activity) {
|
||||
activity.startActivity(new Intent(activity, AddCustomCatalogActivity.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class NetworkBookActions extends NetworkTreeActions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildContextMenu(Activity activity, ContextMenu menu, NetworkTree tree) {
|
||||
public void buildContextMenu(NetworkLibraryActivity activity, ContextMenu menu, NetworkTree tree) {
|
||||
menu.setHeaderTitle(tree.getName());
|
||||
if (tree instanceof NetworkAuthorTree || tree instanceof NetworkSeriesTree) {
|
||||
addMenuItem(menu, SHOW_BOOKS_ITEM_ID, "showBooks");
|
||||
|
@ -402,7 +402,7 @@ class NetworkBookActions extends NetworkTreeActions {
|
|||
buttonKey = "topup";
|
||||
action = new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
TopupActions.runStandalone(activity, book.Link);
|
||||
TopupMenuActivity.runMenu(activity, book.Link);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
|
|
@ -66,7 +66,7 @@ class NetworkCatalogActions extends NetworkTreeActions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildContextMenu(Activity activity, ContextMenu menu, NetworkTree tree) {
|
||||
public void buildContextMenu(NetworkLibraryActivity activity, ContextMenu menu, NetworkTree tree) {
|
||||
final NetworkCatalogItem item = ((NetworkCatalogTree)tree).Item;
|
||||
final NetworkURLCatalogItem urlItem =
|
||||
item instanceof NetworkURLCatalogItem ? (NetworkURLCatalogItem)item : null;
|
||||
|
@ -88,7 +88,7 @@ class NetworkCatalogActions extends NetworkTreeActions {
|
|||
if (mgr != null) {
|
||||
if (mgr.mayBeAuthorised(false)) {
|
||||
addMenuItem(menu, SIGNOUT_ITEM_ID, "signOut", mgr.currentUserName());
|
||||
if (Util.isTopupSupported(item.Link)) {
|
||||
if (TopupMenuActivity.isTopupSupported(item.Link)) {
|
||||
final String account = mgr.currentAccount();
|
||||
if (account != null) {
|
||||
addMenuItem(menu, TOPUP_ITEM_ID, "topup", account);
|
||||
|
@ -177,7 +177,7 @@ class NetworkCatalogActions extends NetworkTreeActions {
|
|||
userName = mgr.currentUserName();
|
||||
signOut = true;
|
||||
account = mgr.currentAccount();
|
||||
if (account != null && Util.isTopupSupported(item.Link)) {
|
||||
if (account != null && TopupMenuActivity.isTopupSupported(item.Link)) {
|
||||
topup = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -261,7 +261,7 @@ class NetworkCatalogActions extends NetworkTreeActions {
|
|||
doSignOut(activity, catalogTree);
|
||||
return true;
|
||||
case TOPUP_ITEM_ID:
|
||||
TopupActions.runStandalone(activity, item.Link);
|
||||
TopupMenuActivity.runMenu(activity, item.Link);
|
||||
return true;
|
||||
case CUSTOM_CATALOG_EDIT:
|
||||
{
|
||||
|
|
|
@ -87,7 +87,7 @@ abstract class NetworkTreeActions {
|
|||
|
||||
public abstract boolean canHandleTree(NetworkTree tree);
|
||||
|
||||
public abstract void buildContextMenu(Activity activity, ContextMenu menu, NetworkTree tree);
|
||||
public abstract void buildContextMenu(NetworkLibraryActivity activity, ContextMenu menu, NetworkTree tree);
|
||||
|
||||
public abstract int getDefaultActionCode(NetworkLibraryActivity activity, NetworkTree tree);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class SearchItemActions extends NetworkTreeActions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildContextMenu(Activity activity, ContextMenu menu, NetworkTree tree) {
|
||||
public void buildContextMenu(NetworkLibraryActivity activity, ContextMenu menu, NetworkTree tree) {
|
||||
menu.setHeaderTitle(tree.getName());
|
||||
|
||||
final boolean isLoading = ItemsLoadingService.getRunnable(tree) != null;
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
|
||||
package org.geometerplus.android.fbreader.network;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.view.View;
|
||||
import android.view.Menu;
|
||||
import android.view.ContextMenu;
|
||||
|
||||
|
@ -40,7 +36,7 @@ class TopupActions extends NetworkTreeActions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildContextMenu(Activity activity, ContextMenu menu, NetworkTree tree) {
|
||||
public void buildContextMenu(NetworkLibraryActivity activity, ContextMenu menu, NetworkTree tree) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,14 +56,7 @@ class TopupActions extends NetworkTreeActions {
|
|||
|
||||
@Override
|
||||
public boolean runAction(NetworkLibraryActivity activity, NetworkTree tree, int actionCode) {
|
||||
runStandalone(activity, ((TopUpTree)tree).Item.Link);
|
||||
TopupMenuActivity.runMenu(activity, ((TopUpTree)tree).Item.Link);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void runStandalone(Activity activity, INetworkLink link) {
|
||||
activity.startActivity(
|
||||
new Intent(activity, TopupMenuActivity.class)
|
||||
.setData(Uri.parse(link.getUrlInfo(UrlInfo.Type.Catalog).Url))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.*;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.*;
|
||||
|
@ -45,6 +44,19 @@ public class TopupMenuActivity extends ListActivity implements AdapterView.OnIte
|
|||
static final String TOPUP_ACTION =
|
||||
"android.fbreader.action.network.TOPUP";
|
||||
|
||||
static boolean isTopupSupported(INetworkLink link) {
|
||||
final List<PluginApi.TopupActionInfo> infos =
|
||||
NetworkView.Instance().TopupActionInfos.get(link.getUrlInfo(UrlInfo.Type.Catalog).Url);
|
||||
return infos != null && infos.size() > 0;
|
||||
}
|
||||
|
||||
static void runMenu(Context context, INetworkLink link) {
|
||||
context.startActivity(
|
||||
new Intent(context, TopupMenuActivity.class)
|
||||
.setData(Uri.parse(link.getUrlInfo(UrlInfo.Type.Catalog).Url))
|
||||
);
|
||||
}
|
||||
|
||||
private INetworkLink myLink;
|
||||
private List<PluginApi.TopupActionInfo> myInfos;
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ import org.geometerplus.fbreader.network.urlInfo.UrlInfo;
|
|||
import org.geometerplus.android.util.UIUtil;
|
||||
import org.geometerplus.android.util.PackageUtil;
|
||||
|
||||
import org.geometerplus.android.fbreader.api.PluginApi;
|
||||
|
||||
abstract class Util implements UserRegistrationConstants {
|
||||
private static final String REGISTRATION_ACTION =
|
||||
"android.fbreader.action.NETWORK_LIBRARY_REGISTER";
|
||||
|
@ -189,12 +187,6 @@ abstract class Util implements UserRegistrationConstants {
|
|||
}
|
||||
}
|
||||
|
||||
static boolean isTopupSupported(INetworkLink link) {
|
||||
final List<PluginApi.TopupActionInfo> infos =
|
||||
NetworkView.Instance().TopupActionInfos.get(link.getUrlInfo(UrlInfo.Type.Catalog).Url);
|
||||
return infos != null && infos.size() > 0;
|
||||
}
|
||||
|
||||
static void openInBrowser(Context context, String url) {
|
||||
if (url != null) {
|
||||
url = NetworkLibrary.Instance().rewriteUrl(url, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue