Scroll to selected position on tab switcher display

This commit is contained in:
Abdul Wadood 2018-08-05 23:59:25 +05:30 committed by Isaac Hutt
parent 86e62ea7ca
commit 574f68e81a
4 changed files with 10 additions and 4 deletions

View File

@ -455,6 +455,9 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
backToTopButton.hide();
tabSwitcherRoot.setVisibility(View.VISIBLE);
supportInvalidateOptionsMenu();
if (tabsAdapter.getSelected() < webViewList.size()) {
tabRecyclerView.getLayoutManager().scrollToPosition(tabsAdapter.getSelected());
}
}
private void hideTabSwitcher() {
@ -1365,8 +1368,8 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
break;
case REQUEST_PREFERENCES:
if (resultCode == RESULT_RESTART) {
finish();
startActivity(new Intent(MainActivity.this, MainActivity.class));
finish();
}
if (resultCode == RESULT_HISTORY_CLEARED) {
webViewList.clear();

View File

@ -128,6 +128,10 @@ public class TabsAdapter extends RecyclerView.Adapter<TabsAdapter.ViewHolder> {
return webViews.size();
}
int getSelected() {
return selectedPosition;
}
public void setSelected(int position) {
this.selectedPosition = position;
}

View File

@ -124,6 +124,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="?attr/drawerBackground"
android:fitsSystemWindows="true"
app:headerLayout="@layout/drawer_right" />
</android.support.v4.widget.DrawerLayout>

View File

@ -3,8 +3,6 @@
android:id="@+id/right_drawer_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/drawerBackground"
android:clickable="true"
android:fitsSystemWindows="true"
android:focusable="true"
android:orientation="vertical" />
android:focusable="true" />