Cannot scroll vertical anymore

pull/210/head
M66B 2 years ago
parent e5e71f6023
commit bb9900e1e8

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

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

@ -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 @Override
public void onItemsAdded(@NonNull RecyclerView recyclerView, int positionStart, int itemCount) { public void onItemsAdded(@NonNull RecyclerView recyclerView, int positionStart, int itemCount) {
iProperties.layoutChanged(); iProperties.layoutChanged();
@ -1122,13 +1137,17 @@ public class FragmentMessages extends FragmentBase
} }
} }
if (hide_toolbar && dy != 0) { if (hide_toolbar && dy != 0)
int range = rv.computeVerticalScrollRange(); try {
int extend = rv.computeVerticalScrollExtent(); int range = rv.computeVerticalScrollRange();
int offset = rv.computeVerticalScrollOffset(); int extend = rv.computeVerticalScrollExtent();
boolean canScrollVertical = (range > extend); boolean canScrollVertical = (range > extend);
show = (!canScrollVertical || (offset == 0 || dy < 0)); show = (!canScrollVertical ||
} (dy < 0 || rv.computeVerticalScrollOffset() == 0));
} catch (Throwable ex) {
Log.e(ex);
show = true;
}
} }
@Override @Override

Loading…
Cancel
Save