Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: David Luhmer <david-dev@live.de>
  • Loading branch information
David-Development committed Oct 28, 2023
1 parent d65a8e7 commit 238e1da
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ public void updateActionBarIcons() {

@Override
public void onBackPressed() {
Log.v(TAG,"NewsDetailActivity onBackPressed() Called");
if (!handlePodcastBackPressed())
super.onBackPressed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,26 +149,6 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements

@VisibleForTesting(otherwise = PROTECTED)
public ActivityNewsreaderBinding binding;
OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
// we need to handle two cases:
// - The user has the "Open Sidebar on Backpress" option enabled
// - the callback need to be set because we want to close the podcast pane on back navigation (in case it's open)
// - set callback will be enabled/disabled based on whether the podcast pane is open/closed
// - The user has the "Open Sidebar on Backpress" option disabled
// - the callback needs to check first if the podcast is open - if so - close it and on
// the next back navigation open the sidebar - and then close the app
// - once the podcast pane is open - the callback will be disabled
// - the event listener (onDrawerClosed) will enable the back pressed callback again
@Override
public void handleOnBackPressed() {
Log.d(TAG, "handleOnBackPressed() 1");
if (!handlePodcastBackPressed()) {
Log.d(TAG, "handleOnBackPressed() 2");
binding.drawerLayout.openDrawer(GravityCompat.START);
setEnabled(false);
}
}
};

//private ServiceConnection mConnection = null;

Expand Down Expand Up @@ -292,6 +272,27 @@ public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState prev
}
};

OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
// we need to handle two cases:
// - The user has the "Open Sidebar on Backpress" option enabled
// - the callback need to be set because we want to close the podcast pane on back navigation (in case it's open)
// - set callback will be enabled/disabled based on whether the podcast pane is open/closed
// - The user has the "Open Sidebar on Backpress" option disabled
// - the callback needs to check first if the podcast is open - if so - close it and on
// the next back navigation open the sidebar - and then close the app
// - once the podcast pane is open - the callback will be disabled
// - the event listener (onDrawerClosed) will enable the back pressed callback again
@Override
public void handleOnBackPressed() {
Log.d(TAG, "handleOnBackPressed() 1");
if (!handlePodcastBackPressed()) {
Log.d(TAG, "handleOnBackPressed() 2");
binding.drawerLayout.openDrawer(GravityCompat.START);
setEnabled(false);
}
}
};

@Override
protected void onCreate(Bundle savedInstanceState) {
((NewsReaderApplication) getApplication()).getAppComponent().injectActivity(this);
Expand Down

0 comments on commit 238e1da

Please sign in to comment.