Browse files

optimize key value storage

  • Loading branch information...
1 parent 0a7b7d3 commit 92ae3ab0e1a19f7897a162508bd67de8bbdf7217 @jindw committed Apr 12, 2014
Showing with 12 additions and 8 deletions.
  1. +5 −5 gen/org/xidea/androidbase/R.java
  2. +1 −0 project.properties
  3. +6 −3 src/org/xidea/android/impl/io/KeyValueStorageImpl.java
View
10 gen/org/xidea/androidbase/R.java
@@ -11,13 +11,13 @@
public static final class attr {
}
public static final class drawable {
- public static final int ic_launcher=0x7f020000;
+ public static int ic_launcher=0x7f020000;
}
public static final class id {
- public static final int androidbaseReservedId=0x7f030000;
+ public static int androidbaseReservedId=0x7f030000;
}
public static final class string {
- public static final int app_name=0x7f040000;
+ public static int app_name=0x7f040000;
}
public static final class style {
/**
@@ -30,10 +30,10 @@
backward-compatibility can go here.
*/
- public static final int AppBaseTheme=0x7f050000;
+ public static int AppBaseTheme=0x7f050000;
/** Application theme.
All customizations that are NOT specific to a particular API-level can go here.
*/
- public static final int AppTheme=0x7f050001;
+ public static int AppTheme=0x7f050001;
}
}
View
1 project.properties
@@ -16,3 +16,4 @@ target=android-17
key.store=xidea.keystore
key.alias=xidea
#proguard.config=proguard.conf
+android.library=true
View
9 src/org/xidea/android/impl/io/KeyValueStorageImpl.java
@@ -4,6 +4,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
+import java.util.HashMap;
import java.util.IdentityHashMap;
import org.xidea.android.KeyValueStorage;
@@ -37,7 +38,7 @@
name, Activity.MODE_PRIVATE);
return (T) Proxy.newProxyInstance(type.getClassLoader(),
new Class[] { type }, new InvocationHandler() {
- IdentityHashMap<Method, Invocable> impls = new IdentityHashMap<Method, Invocable>();
+ HashMap<String, Invocable> impls = new HashMap<String, Invocable>();
private Editor[] editorHolder = new Editor[1];
@Override
@@ -47,14 +48,16 @@ public Object invoke(Object thiz, Method method,
if (args == null) {// alliyun bug
args = EMPTY_OBJECTS;
}
- Invocable inv = impls.get(method);
+ String name = method.getName();
+ Invocable inv = impls.get(name);
if (inv == null) {
inv = KeyValueStorageImpl.buildInvocable(type,
method, preferences, editorHolder);
+ //System.err.println("create:"+method+"@"+System.identityHashCode(method)+(null==inv));
if (inv == null) {
return null;
} else {
- impls.put(method, inv);
+ impls.put(name, inv);
}
}
Object value = inv.invoke(thiz, args);

0 comments on commit 92ae3ab

Please sign in to comment.