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

single NetworkLibraryActivity instance is now used

This commit is contained in:
Nikolay Pultsin 2011-08-15 02:13:52 +01:00
parent 364e191be1
commit 469525664d
9 changed files with 50 additions and 36 deletions

View file

@ -133,7 +133,7 @@
</intent-filter> </intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity> </activity>
<activity android:name="org.geometerplus.android.fbreader.network.NetworkLibraryActivity" android:process=":networkLibrary" android:launchMode="singleTask" android:configChanges="orientation|keyboardHidden"> <activity android:name="org.geometerplus.android.fbreader.network.NetworkLibraryActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden">
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.network.NetworkSearchActivity" /> <meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.network.NetworkSearchActivity" />
</activity> </activity>
<activity android:name="org.geometerplus.android.fbreader.network.AuthenticationActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Dialog"/> <activity android:name="org.geometerplus.android.fbreader.network.AuthenticationActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Dialog"/>

View file

@ -133,7 +133,7 @@
</intent-filter> </intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity> </activity>
<activity android:name="org.geometerplus.android.fbreader.network.NetworkTopLevelActivity" android:process=":networkLibrary" android:launchMode="singleTask" android:configChanges="orientation|keyboardHidden"> <activity android:name="org.geometerplus.android.fbreader.network.NetworkLibraryActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden">
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.network.NetworkSearchActivity" /> <meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.network.NetworkSearchActivity" />
</activity> </activity>
<activity android:name="org.geometerplus.android.fbreader.network.AuthenticationActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Dialog"/> <activity android:name="org.geometerplus.android.fbreader.network.AuthenticationActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Dialog"/>

View file

@ -25,6 +25,7 @@ import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Intent; import android.content.Intent;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.ActivityNotFoundException;
import android.net.Uri; import android.net.Uri;
import android.view.Menu; import android.view.Menu;
import android.view.ContextMenu; import android.view.ContextMenu;
@ -376,15 +377,17 @@ class NetworkCatalogActions extends NetworkTreeActions {
NetworkView.Instance().tryResumeLoading(activity, tree, new Runnable() { NetworkView.Instance().tryResumeLoading(activity, tree, new Runnable() {
public void run() { public void run() {
if (tree instanceof NetworkCatalogRootTree) { if (tree instanceof NetworkCatalogRootTree) {
/* try {
activity.startActivityForResult( activity.startActivityForResult(
new Intent( new Intent(
Util.TOPUP_ACTION, Util.TOPUP_ACTION,
Uri.parse(tree.Item.Link.getUrl(UrlInfo.Type.Catalog)) Uri.parse(tree.Item.Link.getUrl(UrlInfo.Type.Catalog))
), ),
NetworkLibraryActivity.LIST_TOPUP_METHODS_CODE NetworkLibraryActivity.LIST_TOPUP_METHODS_CODE
); );
*/ } catch (ActivityNotFoundException e) {
// ignore
}
} }
boolean resumeNotLoad = false; boolean resumeNotLoad = false;

View file

@ -19,6 +19,7 @@
package org.geometerplus.android.fbreader.network; package org.geometerplus.android.fbreader.network;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;

View file

@ -72,8 +72,7 @@ public class NetworkLibraryActivity extends BaseActivity implements NetworkView.
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
System.err.println("NetworkLibraryActivity.onCreate");
OLD_STYLE_FLAG = true;
SQLiteCookieDatabase.init(this); SQLiteCookieDatabase.init(this);
@ -189,6 +188,11 @@ public class NetworkLibraryActivity extends BaseActivity implements NetworkView.
return false; return false;
} }
@Override
protected boolean isTreeInvisible(FBTree tree) {
return tree instanceof RootTree && ((RootTree)tree).IsFake;
}
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
@ -286,14 +290,14 @@ public class NetworkLibraryActivity extends BaseActivity implements NetworkView.
Util.processSignup(((NetworkCatalogTree)getCurrentTree()).Item.Link, resultCode, data); Util.processSignup(((NetworkCatalogTree)getCurrentTree()).Item.Link, resultCode, data);
break; break;
case LIST_TOPUP_METHODS_CODE: case LIST_TOPUP_METHODS_CODE:
{ if (data != null) {
final Bundle bundle = data.getExtras(); final Bundle bundle = data.getExtras();
final ArrayList<PluginApi.ActionInfo> infos = final ArrayList<PluginApi.ActionInfo> infos =
bundle != null bundle != null
? bundle.<PluginApi.ActionInfo>getParcelableArrayList(PluginApi.PluginInfo.KEY) ? bundle.<PluginApi.ActionInfo>getParcelableArrayList(PluginApi.PluginInfo.KEY)
: null; : null;
System.err.println("infos: " + infos); System.err.println("infos: " + infos);
} }
} }
} }

View file

@ -242,10 +242,14 @@ abstract class Util implements UserRegistrationConstants {
static void openTree(Context context, NetworkTree tree) { static void openTree(Context context, NetworkTree tree) {
final Class<?> clz = tree instanceof NetworkBookTree final Class<?> clz = tree instanceof NetworkBookTree
? NetworkBookInfoActivity.class : NetworkLibraryActivity.class; ? NetworkBookInfoActivity.class : NetworkLibraryActivity.class;
context.startActivity( if (context instanceof NetworkLibraryActivity && clz == NetworkLibraryActivity.class) {
new Intent(context.getApplicationContext(), clz) ((NetworkLibraryActivity)context).openTree(tree);
.putExtra(NetworkLibraryActivity.TREE_KEY_KEY, tree.getUniqueKey()) } else {
); context.startActivity(
new Intent(context.getApplicationContext(), clz)
.putExtra(NetworkLibraryActivity.TREE_KEY_KEY, tree.getUniqueKey())
);
}
} }
public static NetworkTree getTreeFromIntent(Intent intent) { public static NetworkTree getTreeFromIntent(Intent intent) {

View file

@ -71,14 +71,12 @@ public abstract class BaseActivity extends ListActivity {
protected abstract FBTree getTreeByKey(FBTree.Key key); protected abstract FBTree getTreeByKey(FBTree.Key key);
public abstract boolean isTreeSelected(FBTree tree); public abstract boolean isTreeSelected(FBTree tree);
protected boolean OLD_STYLE_FLAG = false; protected boolean isTreeInvisible(FBTree tree) {
return false;
}
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (OLD_STYLE_FLAG) {
return super.onKeyDown(keyCode, event);
}
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {
FBTree parent = null; FBTree parent = null;
while (parent == null && !myHistory.isEmpty()) { while (parent == null && !myHistory.isEmpty()) {
@ -87,7 +85,7 @@ public abstract class BaseActivity extends ListActivity {
if (parent == null) { if (parent == null) {
parent = myCurrentTree.Parent; parent = myCurrentTree.Parent;
} }
if (parent != null) { if (parent != null && !isTreeInvisible(parent)) {
openTree(parent, myCurrentTree, false); openTree(parent, myCurrentTree, false);
return true; return true;
} }
@ -96,7 +94,8 @@ public abstract class BaseActivity extends ListActivity {
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
} }
protected void openTree(final FBTree tree) { // TODO: change to protected
public void openTree(final FBTree tree) {
openTree(tree, null, true); openTree(tree, null, true);
} }
@ -157,7 +156,7 @@ public abstract class BaseActivity extends ListActivity {
if (storeInHistory && !myCurrentKey.equals(tree.getUniqueKey())) { if (storeInHistory && !myCurrentKey.equals(tree.getUniqueKey())) {
myHistory.add(myCurrentKey); myHistory.add(myCurrentKey);
} }
startActivity(new Intent(this, getClass()) onNewIntent(new Intent(this, getClass())
.setAction(OPEN_TREE_ACTION) .setAction(OPEN_TREE_ACTION)
.putExtra(TREE_KEY_KEY, tree.getUniqueKey()) .putExtra(TREE_KEY_KEY, tree.getUniqueKey())
.putExtra( .putExtra(

View file

@ -124,8 +124,8 @@ public class NetworkLibrary {
return filteredList; return filteredList;
} }
private final RootTree myRootTree = new RootTree("@Root"); private final RootTree myRootTree = new RootTree("@Root", false);
private final RootTree myFakeRootTree = new RootTree("@FakeRoot"); private final RootTree myFakeRootTree = new RootTree("@FakeRoot", true);
private SearchItemTree mySearchItemTree; private SearchItemTree mySearchItemTree;
private boolean myChildrenAreInvalid = true; private boolean myChildrenAreInvalid = true;

View file

@ -22,9 +22,12 @@ package org.geometerplus.fbreader.network.tree;
import org.geometerplus.fbreader.network.*; import org.geometerplus.fbreader.network.*;
public final class RootTree extends NetworkTree { public final class RootTree extends NetworkTree {
public final boolean IsFake;
private final String myId; private final String myId;
public RootTree(String id) { public RootTree(String id, boolean isFake) {
IsFake = isFake;
myId = id; myId = id;
} }