Cannot scroll vertical anymore

This commit is contained in:
M66B 2023-01-08 08:11:32 +01:00
parent e5e71f6023
commit bb9900e1e8
3 changed files with 43 additions and 7 deletions

View File

@ -834,8 +834,13 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
return super.shouldUpRecreateTask(targetIntent);
}
public boolean abShowing = true;
public ValueAnimator abAnimator = null;
public boolean isActionBarShown() {
return abShowing;
}
public void showActionBar(boolean show) {
ViewGroup abv = findViewById(R.id.action_bar);
if (abv == null) {
@ -847,6 +852,10 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
else
ab.hide();
} else {
if (abShowing == show)
return;
abShowing = show;
int height = Helper.getActionBarHeight(this);
int current = abv.getLayoutParams().height;
int target = (show ? height : 0);

View File

@ -106,6 +106,14 @@ public class FragmentBase extends Fragment {
return null;
}
protected boolean isActionBarShown() {
FragmentActivity activity = getActivity();
if (activity instanceof ActivityBase)
return ((ActivityBase) activity).isActionBarShown();
else
return false;
}
protected void showActionBar(boolean show) {
FragmentActivity activity = getActivity();
if (activity instanceof ActivityBase)

View File

@ -771,6 +771,21 @@ public class FragmentMessages extends FragmentBase
}
}
@Override
public void onLayoutCompleted(RecyclerView.State state) {
super.onLayoutCompleted(state);
if (!isActionBarShown())
try {
int range = computeVerticalScrollRange(state);
int extend = computeVerticalScrollExtent(state);
boolean canScrollVertical = (range > extend);
if (!canScrollVertical) // anymore
showActionBar(true);
} catch (Throwable ex) {
Log.e(ex);
}
}
@Override
public void onItemsAdded(@NonNull RecyclerView recyclerView, int positionStart, int itemCount) {
iProperties.layoutChanged();
@ -1122,13 +1137,17 @@ public class FragmentMessages extends FragmentBase
}
}
if (hide_toolbar && dy != 0) {
int range = rv.computeVerticalScrollRange();
int extend = rv.computeVerticalScrollExtent();
int offset = rv.computeVerticalScrollOffset();
boolean canScrollVertical = (range > extend);
show = (!canScrollVertical || (offset == 0 || dy < 0));
}
if (hide_toolbar && dy != 0)
try {
int range = rv.computeVerticalScrollRange();
int extend = rv.computeVerticalScrollExtent();
boolean canScrollVertical = (range > extend);
show = (!canScrollVertical ||
(dy < 0 || rv.computeVerticalScrollOffset() == 0));
} catch (Throwable ex) {
Log.e(ex);
show = true;
}
}
@Override