|
146 | 146 | import me.vkryl.core.collection.IntList;
|
147 | 147 | import me.vkryl.core.lambda.CancellableRunnable;
|
148 | 148 | import me.vkryl.core.lambda.FutureBool;
|
| 149 | +import me.vkryl.core.lambda.RunnableData; |
149 | 150 | import me.vkryl.core.lambda.RunnableLong;
|
150 | 151 | import tgx.td.ChatId;
|
151 | 152 | import tgx.td.Td;
|
@@ -945,6 +946,19 @@ private void makeChannelChecks () {
|
945 | 946 | private RtlViewPager pager;
|
946 | 947 | private ViewControllerPagerAdapter pagerAdapter;
|
947 | 948 |
|
| 949 | + @Override |
| 950 | + public boolean supportsBottomInset () { |
| 951 | + return true; |
| 952 | + } |
| 953 | + |
| 954 | + @Override |
| 955 | + protected void onBottomInsetChanged (int extraBottomInset, int extraBottomInsetWithoutIme, boolean isImeInset) { |
| 956 | + super.onBottomInsetChanged(extraBottomInset, extraBottomInsetWithoutIme, isImeInset); |
| 957 | + iterateControllers(c -> |
| 958 | + c.setBottomInset(extraBottomInset, extraBottomInsetWithoutIme) |
| 959 | + ); |
| 960 | + } |
| 961 | + |
948 | 962 | @Override
|
949 | 963 | protected int getBackButton () {
|
950 | 964 | return BackHeaderButton.TYPE_BACK;
|
@@ -5511,12 +5525,7 @@ private int calculateCachedContentScrollY () {
|
5511 | 5525 | }
|
5512 | 5526 |
|
5513 | 5527 | private void stopCachedScrolls () {
|
5514 |
| - for (int i = 0; i < pagerAdapter.getCount(); i++) { |
5515 |
| - ViewController<?> c = pagerAdapter.findCachedControllerByPosition(i); |
5516 |
| - if (c != null) { |
5517 |
| - ((SharedBaseController<?>) c).stopScroll(); |
5518 |
| - } |
5519 |
| - } |
| 5528 | + iterateControllers(SharedBaseController::stopScroll); |
5520 | 5529 | }
|
5521 | 5530 |
|
5522 | 5531 | private boolean belongsToBaseRecycler (int width, float y) {
|
@@ -5548,26 +5557,25 @@ private boolean belongsToBaseRecycler (int width, float y) {
|
5548 | 5557 |
|
5549 | 5558 | private void onItemsHeightProbablyChanged () {
|
5550 | 5559 | cachedItemsWidth = cachedItemsHeight = 0;
|
| 5560 | + iterateControllers(SharedBaseController::onItemsHeightProbablyChanged); |
| 5561 | + checkTopViewPosition(); |
| 5562 | + } |
| 5563 | + |
| 5564 | + private void iterateControllers (RunnableData<SharedBaseController<?>> callback) { |
5551 | 5565 | for (int i = 0; i < pagerAdapter.getCount(); i++) {
|
5552 | 5566 | ViewController<?> c = pagerAdapter.findCachedControllerByPosition(i);
|
5553 | 5567 | if (c != null) {
|
5554 |
| - ((SharedBaseController<?>) c).onItemsHeightProbablyChanged(); |
| 5568 | + callback.runWithData((SharedBaseController<?>) c); |
5555 | 5569 | }
|
5556 | 5570 | }
|
5557 |
| - checkTopViewPosition(); |
5558 | 5571 | }
|
5559 | 5572 |
|
5560 | 5573 | private void onGlobalHeightChanged () {
|
5561 | 5574 | if (baseAdapter.indexOfViewById(R.id.btn_description) != -1 || baseAdapter.indexOfViewById(R.id.description) != -1) {
|
5562 | 5575 | onItemsHeightProbablyChanged();
|
5563 | 5576 | }
|
5564 | 5577 | baseRecyclerView.invalidateItemDecorations();
|
5565 |
| - for (int i = 0; i < pagerAdapter.getCount(); i++) { |
5566 |
| - ViewController<?> c = pagerAdapter.findCachedControllerByPosition(i); |
5567 |
| - if (c != null) { |
5568 |
| - ((SharedBaseController<?>) c).onGlobalHeightChanged(); |
5569 |
| - } |
5570 |
| - } |
| 5578 | + iterateControllers(SharedBaseController::onGlobalHeightChanged); |
5571 | 5579 | }
|
5572 | 5580 |
|
5573 | 5581 | private boolean eventsBelongToPager;
|
@@ -6127,6 +6135,7 @@ public ViewController<?> createControllerForPosition (int position) {
|
6127 | 6135 | @Override
|
6128 | 6136 | public void onPrepareToShow (int position, ViewController<?> controller) {
|
6129 | 6137 | super.onPrepareToShow();
|
| 6138 | + controller.setBottomInset(extraBottomInset, extraBottomInsetWithoutIme); |
6130 | 6139 | if (baseRecyclerView.getMeasuredWidth() != 0) {
|
6131 | 6140 | checkContentScrollY(controller);
|
6132 | 6141 | }
|
@@ -6674,36 +6683,24 @@ private void addMessage (TdApi.Message message) {
|
6674 | 6683 | }
|
6675 | 6684 | }
|
6676 | 6685 |
|
6677 |
| - final int size = pagerAdapter.getCount(); |
6678 |
| - for (int i = 0; i < size; i++) { |
6679 |
| - ViewController<?> c = pagerAdapter.findCachedControllerByPosition(i); |
6680 |
| - if (c != null) { |
6681 |
| - ((SharedBaseController<?>) c).addMessage(message); |
6682 |
| - } |
6683 |
| - } |
| 6686 | + iterateControllers(c -> |
| 6687 | + c.addMessage(message) |
| 6688 | + ); |
6684 | 6689 | }
|
6685 | 6690 |
|
6686 | 6691 | @UiThread
|
6687 | 6692 | private void removeMessages (long[] messageIds) {
|
6688 |
| - final int size = pagerAdapter.getCount(); |
6689 |
| - for (int i = 0; i < size; i++) { |
6690 |
| - ViewController<?> c = pagerAdapter.findCachedControllerByPosition(i); |
6691 |
| - if (c != null) { |
6692 |
| - ((SharedBaseController<?>) c).removeMessages(messageIds); |
6693 |
| - } |
6694 |
| - } |
| 6693 | + iterateControllers(c -> |
| 6694 | + c.removeMessages(messageIds) |
| 6695 | + ); |
6695 | 6696 | refreshCounters();
|
6696 | 6697 | }
|
6697 | 6698 |
|
6698 | 6699 | @UiThread
|
6699 | 6700 | private void editMessage (long messageId, TdApi.MessageContent content) {
|
6700 |
| - final int size = pagerAdapter.getCount(); |
6701 |
| - for (int i = 0; i < size; i++) { |
6702 |
| - ViewController<?> c = pagerAdapter.findCachedControllerByPosition(i); |
6703 |
| - if (c != null) { |
6704 |
| - ((SharedBaseController<?>) c).editMessage(messageId, content); |
6705 |
| - } |
6706 |
| - } |
| 6701 | + iterateControllers(c -> |
| 6702 | + c.editMessage(messageId, content) |
| 6703 | + ); |
6707 | 6704 | }
|
6708 | 6705 |
|
6709 | 6706 | public static boolean filterMediaMessage (TdApi.Message message) {
|
|
0 commit comments