SponsorBlock: Added some null checks for the blockSponsorsButton

In case it's null for whatever reason...
This commit is contained in:
polymorphicshade 2020-08-20 22:37:45 -06:00
parent 472089eb8f
commit e18579b016

View file

@ -362,7 +362,11 @@ public class VideoPlayerImpl extends VideoPlayer
playWithKodi.setVisibility(View.GONE); playWithKodi.setVisibility(View.GONE);
openInBrowser.setVisibility(View.GONE); openInBrowser.setVisibility(View.GONE);
muteButton.setVisibility(View.GONE); muteButton.setVisibility(View.GONE);
blockSponsorsButton.setVisibility(View.GONE);
if (blockSponsorsButton != null) {
blockSponsorsButton.setVisibility(View.GONE);
}
playerCloseButton.setVisibility(View.GONE); playerCloseButton.setVisibility(View.GONE);
getTopControlsRoot().bringToFront(); getTopControlsRoot().bringToFront();
getTopControlsRoot().setClickable(false); getTopControlsRoot().setClickable(false);
@ -385,9 +389,11 @@ public class VideoPlayerImpl extends VideoPlayer
openInBrowser.setVisibility(View.VISIBLE); openInBrowser.setVisibility(View.VISIBLE);
muteButton.setVisibility(View.VISIBLE); muteButton.setVisibility(View.VISIBLE);
final boolean isSponsorBlockEnabled = mPrefs.getBoolean( if (blockSponsorsButton != null) {
context.getString(R.string.sponsor_block_enable_key), false); final boolean isSponsorBlockEnabled = mPrefs.getBoolean(
blockSponsorsButton.setVisibility(isSponsorBlockEnabled ? View.VISIBLE : View.GONE); context.getString(R.string.sponsor_block_enable_key), false);
blockSponsorsButton.setVisibility(isSponsorBlockEnabled ? View.VISIBLE : View.GONE);
}
playerCloseButton.setVisibility(isFullscreen ? View.GONE : View.VISIBLE); playerCloseButton.setVisibility(isFullscreen ? View.GONE : View.VISIBLE);
// Top controls have a large minHeight which is allows to drag the player // Top controls have a large minHeight which is allows to drag the player
@ -474,7 +480,10 @@ public class VideoPlayerImpl extends VideoPlayer
openInBrowser.setOnClickListener(this); openInBrowser.setOnClickListener(this);
playerCloseButton.setOnClickListener(this); playerCloseButton.setOnClickListener(this);
muteButton.setOnClickListener(this); muteButton.setOnClickListener(this);
blockSponsorsButton.setOnClickListener(this);
if (blockSponsorsButton != null) {
blockSponsorsButton.setOnClickListener(this);
}
settingsContentObserver = new ContentObserver(new Handler()) { settingsContentObserver = new ContentObserver(new Handler()) {
@Override @Override
@ -822,7 +831,7 @@ public class VideoPlayerImpl extends VideoPlayer
} }
} else if (v.getId() == muteButton.getId()) { } else if (v.getId() == muteButton.getId()) {
onMuteUnmuteButtonClicked(); onMuteUnmuteButtonClicked();
} else if (v.getId() == blockSponsorsButton.getId()) { } else if (blockSponsorsButton != null && v.getId() == blockSponsorsButton.getId()) {
onBlockingSponsorsButtonClicked(); onBlockingSponsorsButtonClicked();
} else if (v.getId() == playerCloseButton.getId()) { } else if (v.getId() == playerCloseButton.getId()) {
service.sendBroadcast(new Intent(VideoDetailFragment.ACTION_HIDE_MAIN_PLAYER)); service.sendBroadcast(new Intent(VideoDetailFragment.ACTION_HIDE_MAIN_PLAYER));