From e466fc8d535b98382e8cade58faa3b8496af1041 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Wed, 4 Oct 2017 20:29:44 -0400 Subject: [PATCH] - Crystal Wallet Service Created! --- .../application/CrystalApplication.java | 5 +++++ .../service/CrystalWalletService.java | 18 +++++++++++------- .../viewmodels/AccountSeedViewModel.java | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java index 8e00a4d..2bea06c 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java @@ -1,10 +1,12 @@ package cy.agorise.crystalwallet.application; import android.app.Application; +import android.content.Intent; import com.idescout.sql.SqlScoutServer; import cy.agorise.crystalwallet.dao.CrystalDatabase; +import cy.agorise.crystalwallet.service.CrystalWalletService; /** * Created by Henry Varona on 6/9/2017. @@ -19,5 +21,8 @@ public class CrystalApplication extends Application { //initialize the database CrystalDatabase db = CrystalDatabase.getAppDatabase(this.getApplicationContext()); SqlScoutServer.create(this, getPackageName()); + + Intent intent = new Intent(getApplicationContext(), CrystalWalletService.class); + startService(intent); } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java b/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java index eefadd9..121b4bd 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java +++ b/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java @@ -1,19 +1,15 @@ package cy.agorise.crystalwallet.service; -import android.app.Notification; -import android.app.NotificationManager; import android.app.Service; -import android.content.Context; import android.content.Intent; -import android.graphics.BitmapFactory; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Message; -import android.support.v4.app.NotificationCompat; import android.util.Log; +import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests; import cy.agorise.crystalwallet.manager.BitsharesAccountManager; /** @@ -28,6 +24,7 @@ public class CrystalWalletService extends Service { private BitsharesAccountManager bitsharesAccountManager; private Thread LoadAccountTransactionsThread; private boolean keepLoadingAccountTransactions; + private CryptoNetInfoRequests cryptoNetInfoRequests; // Handler that receives messages from the thread private final class ServiceHandler extends Handler { @@ -50,8 +47,9 @@ public class CrystalWalletService extends Service { while(this.keepLoadingAccountTransactions){ try{ - Log.i("CrystalServiceLATThread","Searching for transactions..."); - Thread.sleep(60000);//Sleep for 1 minutes //TODO Configurable time + Log.i("Crystal Service","Searching for transactions..."); + Thread.sleep(60000);//Sleep for 1 minutes + // TODO search for accounts and make managers find new transactions } catch (InterruptedException e) { Thread.currentThread().interrupt(); } @@ -60,7 +58,13 @@ public class CrystalWalletService extends Service { @Override public void onCreate() { + //Creates a instance for the cryptoNetInfoRequest and the managers + this.cryptoNetInfoRequests = CryptoNetInfoRequests.getInstance(); this.bitsharesAccountManager = new BitsharesAccountManager(); + + //Add the managers as listeners of the CryptoNetInfoRequest so + //they can carry out the info requests from the ui + this.cryptoNetInfoRequests.addListener(this.bitsharesAccountManager); } @Override diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/AccountSeedViewModel.java b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/AccountSeedViewModel.java index a4b9a28..4c8a90a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/AccountSeedViewModel.java +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/AccountSeedViewModel.java @@ -39,7 +39,7 @@ public class AccountSeedViewModel extends AndroidViewModel { this.importSeedValidator = new ImportSeedValidator(this.app.getResources()); } - return null; + return this.importSeedValidator; } public void addSeed(AccountSeed seed){