From 41352175489edf77ef158969b161730c2ac68b60 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sat, 28 Apr 2018 21:38:35 -0400 Subject: [PATCH] - Added CryptoNetEvents fired from Service classes --- .../requestmanagers/CryptoNetEvent.java | 21 ++++++++ .../requestmanagers/CryptoNetEvents.java | 48 +++++++++++++++++++ .../CryptoNetEventsListener.java | 11 +++++ .../ReceivedFundsCryptoNetEvent.java | 32 +++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetEvent.java create mode 100644 app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetEvents.java create mode 100644 app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetEventsListener.java create mode 100644 app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ReceivedFundsCryptoNetEvent.java diff --git a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetEvent.java b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetEvent.java new file mode 100644 index 0000000..a6c7fae --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetEvent.java @@ -0,0 +1,21 @@ +package cy.agorise.crystalwallet.requestmanagers; + +import cy.agorise.crystalwallet.enums.CryptoCoin; + +/** + * An event fired from the service + * + * + * Created by Henry Varona on 4/28/2018. + */ + +public abstract class CryptoNetEvent { + /** + * The cryptocoin this events belongs to + */ + protected CryptoCoin coin; + + protected CryptoNetEvent(CryptoCoin coin){ + this.coin = coin; + } +} diff --git a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetEvents.java b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetEvents.java new file mode 100644 index 0000000..3ce60c3 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetEvents.java @@ -0,0 +1,48 @@ +package cy.agorise.crystalwallet.requestmanagers; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class will be used to communicate events related to crypto net accounts data + * + * Created by Henry Varona on 4/28/2018. + */ + +public class CryptoNetEvents { + private List listeners; + private static CryptoNetEvents instance; + + /** + * Private constructor for singleton pattern + */ + private void CryptoNetEvents(){ + } + + /** + * Gets an instance of this manager + * @return the instance to manage the cryptonetinforequest + */ + public static CryptoNetEvents getInstance(){ + if (CryptoNetEvents.instance == null){ + CryptoNetEvents.instance = new CryptoNetEvents(); + CryptoNetEvents.instance.listeners = new ArrayList<>(); + } + + return CryptoNetEvents.instance; + } + + public void fireEvent(CryptoNetEvent event){ + for (int i=0;i