From dff4b6f931a4e2201f7e215cb83e438378c132f3 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sun, 1 Oct 2017 21:50:12 -0400 Subject: [PATCH] - Added CryptoNetInfoRequests for specific information retrieval from the api servers --- .../activities/ImportSeedActivity.java | 1 + .../CryptoNetInfoRequest.java | 24 ++++++++++ .../CryptoNetInfoRequestListener.java | 10 ++++ .../CryptoNetInfoRequests.java | 48 +++++++++++++++++++ .../CryptoNetInfoRequestsListener.java | 9 ++++ ...ValidateImportBitsharesAccountRequest.java | 44 +++++++++++++++++ 6 files changed, 136 insertions(+) create mode 100644 app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequest.java create mode 100644 app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequestListener.java create mode 100644 app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequests.java create mode 100644 app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequestsListener.java create mode 100644 app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/ValidateImportBitsharesAccountRequest.java diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java index f6c2f45..ac5673a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java @@ -57,6 +57,7 @@ public class ImportSeedActivity extends AppCompatActivity { //TODO verify if PIN and PIN confirmation are not null and are the same //TODO verify if words are already in the db + //TODO check if name has been asigned to other seed seed.setMasterSeed(etSeedWords.getText().toString()); seed.setName(etAccountName.getText().toString()); diff --git a/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequest.java b/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequest.java new file mode 100644 index 0000000..3fb44ba --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequest.java @@ -0,0 +1,24 @@ +package cy.agorise.crystalwallet.cryptonetinforequests; + +import cy.agorise.crystalwallet.enums.CryptoCoin; + +/** + * Created by Henry Varona on 1/10/2017. + */ + +abstract class CryptoNetInfoRequest { + protected CryptoCoin coin; + protected CryptoNetInfoRequestListener listener; + + public CryptoNetInfoRequest(CryptoCoin coin){ + this.coin = coin; + } + + public void setListener(CryptoNetInfoRequestListener listener){ + this.listener = listener; + } + + public void _fireOnCarryOutEvent(){ + listener.onCarryOut(); + } +} diff --git a/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequestListener.java b/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequestListener.java new file mode 100644 index 0000000..8b3d63a --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequestListener.java @@ -0,0 +1,10 @@ +package cy.agorise.crystalwallet.cryptonetinforequests; + +/** + * Created by Henry Varona on 1/10/2017. + */ + +interface CryptoNetInfoRequestListener { + + public void onCarryOut(); +} diff --git a/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequests.java b/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequests.java new file mode 100644 index 0000000..74d9126 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/CryptoNetInfoRequests.java @@ -0,0 +1,48 @@ +package cy.agorise.crystalwallet.cryptonetinforequests; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Henry Varona on 1/10/2017. + */ + +public class CryptoNetInfoRequests { + private List requests; + private List listeners; + private CryptoNetInfoRequests instance; + + private void CryptoNetInfoRequests(){ + //Private constructor for singleton pattern + } + + public CryptoNetInfoRequests getInstance(){ + if (this.instance == null){ + this.instance = new CryptoNetInfoRequests(); + this.requests = new ArrayList(); + this.listeners = new ArrayList(); + } + + return this.instance; + } + + public void addRequest(CryptoNetInfoRequest request){ + this.requests.add(request); + + this._fireNewRequestEvent(request); + } + + public void removeRequest(CryptoNetInfoRequest request){ + this.requests.remove(request); + } + + public void addListener(CryptoNetInfoRequestsListener listener){ + this.listeners.add(listener); + } + + private void _fireNewRequestEvent(CryptoNetInfoRequest request){ + for (int i=0;i