Skip to content

Commit

Permalink
Prevent channel management view from scrolling to top when closing ch…
Browse files Browse the repository at this point in the history
…annel details
  • Loading branch information
michaelWuensch committed Jan 5, 2025
1 parent d103c10 commit dfab448
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class ManageChannelsActivity extends BaseAppCompatActivity implements Cha
private CustomViewPager mViewPager;
private ChannelsPagerAdapter mPagerAdapter;
private boolean isOpenChannelView = true;
private long createOptionsMenuTimestamp;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -292,6 +293,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
MenuItem menuItem = menu.findItem(R.id.searchButton);
SearchView searchView = (SearchView) menuItem.getActionView();
searchView.setQueryHint(getResources().getString(R.string.search));
createOptionsMenuTimestamp = System.currentTimeMillis();

searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
Expand All @@ -304,11 +306,13 @@ public boolean onQueryTextChange(String newText) {
mCurrentSearchString = newText;
final List<ChannelListItem> filteredChannelList = filter(mChannelItems, newText);
mPagerAdapter.getOpenChannelsList().replaceAllItems(filteredChannelList);
mPagerAdapter.getOpenChannelsList().scrollToPosition(0);
if (System.currentTimeMillis() - createOptionsMenuTimestamp > 500)
mPagerAdapter.getOpenChannelsList().scrollToPosition(0);

final List<ChannelListItem> filteredClosedChannelList = filter(mClosedChannelItems, newText);
mPagerAdapter.getClosedChannelsList().replaceAllItems(filteredClosedChannelList);
mPagerAdapter.getClosedChannelsList().scrollToPosition(0);
if (System.currentTimeMillis() - createOptionsMenuTimestamp > 500)
mPagerAdapter.getClosedChannelsList().scrollToPosition(0);

return true;
}
Expand Down

0 comments on commit dfab448

Please sign in to comment.