From 94b0c7bc014f56705f96664205f9625b6252c6d8 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Tue, 26 May 2020 16:25:37 +0100 Subject: [PATCH] Fix additional Play Store crash bugs. --- app/src/main/java/io/lbry/browser/MainActivity.java | 4 ++++ .../io/lbry/browser/ui/publish/PublishFormFragment.java | 2 +- .../java/io/lbry/browser/ui/wallet/RewardsFragment.java | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/lbry/browser/MainActivity.java b/app/src/main/java/io/lbry/browser/MainActivity.java index 7d73aac0..eace68dd 100644 --- a/app/src/main/java/io/lbry/browser/MainActivity.java +++ b/app/src/main/java/io/lbry/browser/MainActivity.java @@ -255,6 +255,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener public static final String ACTION_USER_AUTHENTICATION_FAILED = "io.lbry.browser.Broadcast.UserAuthenticationFailed"; public static final String ACTION_NOW_PLAYING_CLAIM_UPDATED = "io.lbry.browser.Broadcast.NowPlayingClaimUpdated"; public static final String ACTION_NOW_PLAYING_CLAIM_CLEARED = "io.lbry.browser.Broadcast.NowPlayingClaimCleared"; + public static final String ACTION_PUBLISH_SUCCESSFUL = "io.lbry.browser.Broadcast.PublishSuccessful"; public static final String ACTION_OPEN_ALL_CONTENT_TAG = "io.lbry.browser.Broadcast.OpenAllContentTag"; public static final String ACTION_WALLET_BALANCE_UPDATED = "io.lbry.browser.Broadcast.WalletBalanceUpdated"; public static final String ACTION_OPEN_CHANNEL_URL = "io.lbry.browser.Broadcast.OpenChannelUrl"; @@ -1842,6 +1843,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener intentFilter.addAction(ACTION_OPEN_CHANNEL_URL); intentFilter.addAction(ACTION_OPEN_WALLET_PAGE); intentFilter.addAction(ACTION_OPEN_REWARDS_PAGE); + intentFilter.addAction(ACTION_PUBLISH_SUCCESSFUL); intentFilter.addAction(ACTION_SAVE_SHARED_USER_STATE); requestsReceiver = new BroadcastReceiver() { @Override @@ -1861,6 +1863,8 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener pendingOpenRewardsPage = true; } else if (ACTION_SAVE_SHARED_USER_STATE.equalsIgnoreCase(action)) { saveSharedUserState(); + } else if (ACTION_PUBLISH_SUCCESSFUL.equalsIgnoreCase(action)) { + openPublishesOnSuccessfulPublish(); } } diff --git a/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java b/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java index 120f235b..87a1665f 100644 --- a/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java @@ -1102,7 +1102,7 @@ public class PublishFormFragment extends BaseFragment implements if (context instanceof MainActivity) { MainActivity activity = (MainActivity) context; activity.showMessage(R.string.publish_successful); - activity.openPublishesOnSuccessfulPublish(); + activity.sendBroadcast(new Intent(MainActivity.ACTION_PUBLISH_SUCCESSFUL)); } } diff --git a/app/src/main/java/io/lbry/browser/ui/wallet/RewardsFragment.java b/app/src/main/java/io/lbry/browser/ui/wallet/RewardsFragment.java index eee6ebb0..32955a5b 100644 --- a/app/src/main/java/io/lbry/browser/ui/wallet/RewardsFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/wallet/RewardsFragment.java @@ -286,8 +286,10 @@ public class RewardsFragment extends BaseFragment implements RewardListAdapter.R @Override public void onError(Exception error) { - Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG). - setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show(); + View view = getView(); + if (view != null && error != null && !Helper.isNullOrEmpty(error.getMessage())) { + Snackbar.make(view, error.getMessage(), Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show(); + } Helper.setViewEnabled(buttonClaim, true); Helper.setViewEnabled(inputClaimCode, true); rewardClaimInProgress = false;