Merge pull request #376 from nitehu/refactor/show_now_playing

Changed how the NowPlaying view is displayed and hidden
This commit is contained in:
Óscar García Amor 2021-01-15 09:14:09 +01:00 committed by GitHub
commit 193fa38dd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 12 deletions

View File

@ -170,6 +170,9 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
restart();
}
// This must be filled here because onCreate is called before the derived objects would call setContentView
getNowPlayingView();
if (!nowPlayingHidden)
{
showNowPlaying();
@ -242,6 +245,19 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
return destroyed;
}
private void getNowPlayingView()
{
if (nowPlayingView == null)
{
try {
nowPlayingView = findViewById(R.id.now_playing);
}
catch (Exception exception) {
Timber.w(exception, "An exception has occurred while trying to get the nowPlayingView by findViewById");
}
}
}
public void showNowPlaying()
{
this.runOnUiThread(new Runnable()
@ -260,8 +276,6 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
return null;
}
nowPlayingView = findViewById(R.id.now_playing);
if (nowPlayingView != null)
{
PlayerState playerState = mediaPlayerControllerLazy.getValue().getPlayerState();
@ -307,11 +321,6 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
return;
}
if (nowPlayingView == null)
{
nowPlayingView = findViewById(R.id.now_playing);
}
if (nowPlayingView != null)
{
try
@ -407,11 +416,6 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
{
try
{
if (nowPlayingView == null)
{
nowPlayingView = findViewById(R.id.now_playing);
}
if (nowPlayingView != null)
{
setVisibilityOnUiThread(nowPlayingView, View.GONE);