Skip to content

Commit

Permalink
fixed actionbar colour issue - was getting decorview before the activ…
Browse files Browse the repository at this point in the history
…ity was loaded. Removed the actionBar.hide() and show() calls, un-neccessary with the decorView stuff
  • Loading branch information
[email protected] committed Oct 1, 2018
1 parent 95d7542 commit 27d4fdf
Showing 1 changed file with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,10 @@ public class ReadArticleActivity extends BaseActionBarActivity {
private boolean onPageFinishedCallPostponedUntilResume;
private boolean loadingFinished;

private ActionBar actionBar;
private boolean isFullscreen;
private View decorView;

public void onCreate(Bundle savedInstanceState) {
// Grab the action bar and decorView for making reading view fullscreen
actionBar = super.getSupportActionBar();
decorView = getWindow().getDecorView();
isFullscreen = false;

// Toggle stable and fullscreen layout flags so everything is overlaid by the
// actionbar AND the status bar when article is opened
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);


settings = App.getInstance().getSettings();

Expand All @@ -171,7 +158,7 @@ public void onCreate(Bundle savedInstanceState) {
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);

ActionBar actionBar = super.getSupportActionBar();
if(actionBar != null) actionBar.hide();
}

Expand Down Expand Up @@ -216,10 +203,22 @@ public void onCreate(Bundle savedInstanceState) {
// article is loaded - update menu
invalidateOptionsMenu();

// Grab the action bar and decorView for making reading view fullscreen
decorView = getWindow().getDecorView();
isFullscreen = false;

// Toggle stable and fullscreen layout flags so everything is overlaid by the
// actionbar AND the status bar when article is opened
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);


scrollView = (ScrollView)findViewById(R.id.scroll);

// Hide status and action bar when scrolling down, show when scrolling up
// TODO: change to a method compatible with API 14.
// // Hide status and action bar when scrolling down, show when scrolling up
// // TODO: change to a method compatible with API 14.
if (Build.VERSION.SDK_INT >= 23 && settings.isAutoFullscreenArticleView()) {
scrollView.setOnScrollChangeListener(new View.OnScrollChangeListener(){
@Override
Expand Down Expand Up @@ -522,14 +521,12 @@ private boolean goFullscreen(boolean gofs) {
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_FULLSCREEN
);
actionBar.hide();
return true;
} else {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);
actionBar.show();
return false;
}
}
Expand Down

0 comments on commit 27d4fdf

Please sign in to comment.