From 4276fd0e7cbb6fa0cf6ca1e92ddb37ae372cb849 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Mon, 30 Apr 2018 21:25:11 -0400 Subject: [PATCH] - Now the received funds sound is played --- .../application/CrystalApplication.java | 6 ++++ .../notifiers/CrystalWalletNotifier.java | 33 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 app/src/main/java/cy/agorise/crystalwallet/notifiers/CrystalWalletNotifier.java 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 bfbab09..549aeda 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java @@ -17,6 +17,8 @@ import cy.agorise.crystalwallet.models.BitsharesAssetInfo; import cy.agorise.crystalwallet.models.CryptoCurrencyEquivalence; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.network.CryptoNetManager; +import cy.agorise.crystalwallet.notifiers.CrystalWalletNotifier; +import cy.agorise.crystalwallet.requestmanagers.CryptoNetEvents; import cy.agorise.crystalwallet.service.CrystalWalletService; /** @@ -83,6 +85,10 @@ public class CrystalApplication extends Application { } + //The crystal notifier is initialized + CrystalWalletNotifier crystalWalletNotifier = new CrystalWalletNotifier(getApplicationContext()); + CryptoNetEvents.getInstance().addListener(crystalWalletNotifier); + //Next line is for use the bitshares main net //CryptoNetManager.addCryptoNetURL(CryptoNet.BITSHARES,BITSHARES_URL); diff --git a/app/src/main/java/cy/agorise/crystalwallet/notifiers/CrystalWalletNotifier.java b/app/src/main/java/cy/agorise/crystalwallet/notifiers/CrystalWalletNotifier.java new file mode 100644 index 0000000..0eeec88 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/notifiers/CrystalWalletNotifier.java @@ -0,0 +1,33 @@ +package cy.agorise.crystalwallet.notifiers; + +import android.content.Context; +import android.media.MediaPlayer; + +import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.requestmanagers.CryptoNetEvent; +import cy.agorise.crystalwallet.requestmanagers.CryptoNetEventsListener; +import cy.agorise.crystalwallet.requestmanagers.ReceivedFundsCryptoNetEvent; + +/** + * Created by Henry Varona on 29/4/2018. + */ + +public class CrystalWalletNotifier implements CryptoNetEventsListener{ + + private Context context; + + public CrystalWalletNotifier(Context context){ + this.context = context; + } + + public void onCryptoNetEvent(CryptoNetEvent event) { + if (event instanceof ReceivedFundsCryptoNetEvent){ + playReceivedFundsSound(); + } + } + + private void playReceivedFundsSound() { + MediaPlayer defaultMediaPlayer = MediaPlayer.create(this.context, R.raw.woohoo); + defaultMediaPlayer.start(); + } +}