start to resize status bar area based on device dimensions so that devices with nonstandard status bars don't draw the app window
beneath the statusbar.
This commit is contained in:
parent
42a9dbe392
commit
823f0ca856
3 changed files with 24 additions and 0 deletions
|
|
@ -57,6 +57,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
AppBarLayout appbar;
|
||||
@BindView(R.id.pager)
|
||||
ViewPager pager;
|
||||
@BindView(R.id.status_bar)
|
||||
View statusBar;
|
||||
|
||||
private MusicLibraryPagerAdapter pagerAdapter;
|
||||
private MaterialCab cab;
|
||||
|
|
@ -90,6 +92,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
|
||||
setUpToolbar();
|
||||
setUpViewPager();
|
||||
setUpStatusBar();
|
||||
}
|
||||
|
||||
private void setUpToolbar() {
|
||||
|
|
@ -122,6 +125,12 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
pager.addOnPageChangeListener(this);
|
||||
}
|
||||
|
||||
private void setUpStatusBar() {
|
||||
ViewGroup.LayoutParams layoutParams = statusBar.getLayoutParams();
|
||||
layoutParams.height = Util.getStatusBarHeight(getMainActivity());
|
||||
statusBar.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
public Fragment getCurrentFragment() {
|
||||
return pagerAdapter.getFragment(pager.getCurrentItem());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
impl.init();
|
||||
|
||||
setUpPlayerToolbar();
|
||||
setUpStatusBar();
|
||||
setUpSubFragments();
|
||||
|
||||
setUpRecyclerView();
|
||||
|
|
@ -230,6 +231,12 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
toolbar.setOnMenuItemClickListener(this);
|
||||
}
|
||||
|
||||
private void setUpStatusBar() {
|
||||
ViewGroup.LayoutParams layoutParams = playerStatusBar.getLayoutParams();
|
||||
layoutParams.height = Util.getStatusBarHeight(getActivity());
|
||||
playerStatusBar.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
|
|
|||
|
|
@ -135,4 +135,12 @@ public class Util {
|
|||
}
|
||||
}
|
||||
|
||||
public static int getStatusBarHeight(final Context context) {
|
||||
int result = 0;
|
||||
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
result = context.getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue