Minor bug fixes and improvements, added caching to inventory

This commit is contained in:
2016-01-19 07:43:48 +01:00
parent 6ec25cfae7
commit 6f6a2e4e6c
9 changed files with 186 additions and 101 deletions

View File

@ -56,7 +56,7 @@ public class BitmessageService extends Service {
private static Messenger messenger;
public static boolean isRunning() {
return running;
return running && bmc.isRunning();
}
@Override
@ -102,8 +102,6 @@ public class BitmessageService extends Service {
switch (msg.what) {
case MSG_CREATE_IDENTITY: {
BitmessageAddress identity = bmc.createIdentity(false);
identity.setAlias(service.get().getString(R.string.alias_default_identity));
bmc.addresses().save(identity);
if (msg.replyTo != null) {
try {
Message message = Message.obtain(this, MSG_CREATE_IDENTITY);

View File

@ -4,6 +4,7 @@ import android.content.Context;
import java.util.List;
import ch.dissem.apps.abit.R;
import ch.dissem.apps.abit.adapter.AndroidCryptography;
import ch.dissem.apps.abit.adapter.SwitchingProofOfWorkEngine;
import ch.dissem.apps.abit.listener.MessageListener;
@ -92,10 +93,15 @@ public class Singleton {
if (identity == null) {
synchronized (Singleton.class) {
if (identity == null) {
List<BitmessageAddress> identities = getBitmessageContext(ctx).addresses()
BitmessageContext bmc = getBitmessageContext(ctx);
List<BitmessageAddress> identities = bmc.addresses()
.getIdentities();
if (identities.size() > 0) {
identity = identities.get(0);
} else {
identity = bmc.createIdentity(false);
identity.setAlias(ctx.getString(R.string.alias_default_identity));
bmc.addresses().save(identity);
}
}
}