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

View File

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

View File

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

View File

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