From 574b61d2b7324f24e94f995a73eb4547cb6977ff Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sun, 10 Jun 2018 20:10:55 -0400 Subject: [PATCH] - Fixed Toast when trying to upgrade account - Now the CryptoNetRequests are deleted when carry out --- .../fragments/BitsharesSettingsFragment.java | 37 +++++++++++++++---- .../requestmanagers/CryptoNetInfoRequest.java | 1 + 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/BitsharesSettingsFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/BitsharesSettingsFragment.java index f748898..17c2ddc 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/BitsharesSettingsFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/BitsharesSettingsFragment.java @@ -17,6 +17,7 @@ import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; import android.widget.TextView; +import android.widget.Toast; import com.vincent.filepicker.Constant; import com.vincent.filepicker.activity.AudioPickActivity; @@ -125,13 +126,35 @@ public class BitsharesSettingsFragment extends Fragment { request.setListener(new CryptoNetInfoRequestListener() { @Override public void onCarryOut() { - switch (request.getStatus()){ - case SUCCEEDED: - tvUpgradeToLtm.setVisibility(View.GONE); - btnUpgradeToLtm.setVisibility(View.GONE); - tvAlreadyLtm.setVisibility(View.VISIBLE); - break; - } + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + Toast toast; + + switch (request.getStatus()){ + case SUCCEEDED: + tvUpgradeToLtm.setVisibility(View.GONE); + btnUpgradeToLtm.setVisibility(View.GONE); + tvAlreadyLtm.setVisibility(View.VISIBLE); + break; + case NO_INTERNET: + case NO_SERVER_CONNECTION: + toast = Toast.makeText(getContext(), "There was an error connecting to the server. Please try again.", Toast.LENGTH_SHORT); + toast.show(); + break; + case NO_FUNDS: + toast = Toast.makeText(getContext(), "Not enough funds to make the upgrade.", Toast.LENGTH_SHORT); + toast.show(); + break; + case NO_ASSET_INFO_DB: + case NO_ASSET_INFO: + case PETITION_FAILED: + default: + toast = Toast.makeText(getContext(), "There was an error with the request. Please try again.", Toast.LENGTH_SHORT); + toast.show(); + } + } + }); } }); diff --git a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetInfoRequest.java b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetInfoRequest.java index 6a207b6..103411b 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetInfoRequest.java +++ b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CryptoNetInfoRequest.java @@ -29,5 +29,6 @@ public abstract class CryptoNetInfoRequest { protected void _fireOnCarryOutEvent(){ listener.onCarryOut(); + CryptoNetInfoRequests.getInstance().removeRequest(this); } }