リファクタリング

This commit is contained in:
r-ca 2024-01-23 05:24:11 +09:00
parent fda8adae80
commit 6e4904967b
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
3 changed files with 21 additions and 39 deletions

View File

@ -61,19 +61,13 @@ public class HomeTopFragment extends Fragment {
// Set status bar color // Set status bar color
AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout); AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { appBarLayout.addOnOffsetChangedListener((appBarLayout1, verticalOffset) -> {
@Override if (Math.abs(verticalOffset) == appBarLayout1.getTotalScrollRange()) {
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
// Collapsed // Collapsed
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
} else if (verticalOffset == 0) { } else if (verticalOffset == 0) {
// Expanded // Expanded
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSurface)); getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSurface));
} else {
// Somewhere in between
// Here you can add a color transition if you want
}
} }
}); });
return view; return view;

View File

@ -119,19 +119,13 @@ public class LibraryPageFragment extends Fragment {
// Set status bar color // Set status bar color
AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout); AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { appBarLayout.addOnOffsetChangedListener((appBarLayout1, verticalOffset) -> {
@Override if (Math.abs(verticalOffset) == appBarLayout1.getTotalScrollRange()) {
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
// Collapsed // Collapsed
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
} else if (verticalOffset == 0) { } else if (verticalOffset == 0) {
// Expanded // Expanded
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSurface)); getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSurface));
} else {
// Somewhere in between
// Here you can add a color transition if you want
}
} }
}); });
return view; return view;

View File

@ -90,19 +90,13 @@ public class SettingTopFragment extends Fragment {
// Set status bar color // Set status bar color
AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout); AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { appBarLayout.addOnOffsetChangedListener((appBarLayout1, verticalOffset) -> {
@Override if (Math.abs(verticalOffset) == appBarLayout1.getTotalScrollRange()) {
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
// Collapsed // Collapsed
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
} else if (verticalOffset == 0) { } else if (verticalOffset == 0) {
// Expanded // Expanded
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSurface)); getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSurface));
} else {
// Somewhere in between
// Here you can add a color transition if you want
}
} }
}); });
return view; return view;