Fix scrolling to correct comment after closing replies
This commit is contained in:
parent
df5e35e315
commit
bf5825c3b4
3 changed files with 80 additions and 44 deletions
|
|
@ -1014,10 +1014,16 @@ public final class VideoDetailFragment
|
|||
}
|
||||
|
||||
public void scrollToComment(final CommentsInfoItem comment) {
|
||||
final Fragment fragment = pageAdapter.getItem(
|
||||
pageAdapter.getItemPositionByTitle(COMMENTS_TAB_TAG));
|
||||
if (fragment instanceof CommentsFragment) {
|
||||
((CommentsFragment) fragment).scrollToComment(comment);
|
||||
final int commentsTabPos = pageAdapter.getItemPositionByTitle(COMMENTS_TAB_TAG);
|
||||
final Fragment fragment = pageAdapter.getItem(commentsTabPos);
|
||||
if (!(fragment instanceof CommentsFragment)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// unexpand the app bar only if scrolling to the comment succeeded
|
||||
if (((CommentsFragment) fragment).scrollToComment(comment)) {
|
||||
binding.appBarLayout.setExpanded(false, false);
|
||||
binding.viewPager.setCurrentItem(commentsTabPos, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,13 @@ public class CommentsFragment extends BaseListInfoFragment<CommentsInfoItem, Com
|
|||
return ItemViewMode.LIST;
|
||||
}
|
||||
|
||||
public void scrollToComment(final CommentsInfoItem comment) {
|
||||
itemsList.scrollToPosition(infoListAdapter.getItemsList().indexOf(comment));
|
||||
public boolean scrollToComment(final CommentsInfoItem comment) {
|
||||
final int position = infoListAdapter.getItemsList().indexOf(comment);
|
||||
if (position < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
itemsList.scrollToPosition(position);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue