fixed tab behaviour

This commit is contained in:
nuclearfog 2022-10-20 19:37:59 +02:00
parent 949974af10
commit 3ffdfd96aa
4 changed files with 10 additions and 5 deletions

View File

@ -64,7 +64,6 @@ public class MainActivity extends AppCompatActivity implements OnTabSelectedList
private FragmentAdapter adapter;
private GlobalSettings settings;
// Views and dialogs
private Dialog loadingCircle;
private TabLayout tabLayout;
private ViewPager pager;

View File

@ -300,6 +300,7 @@ public class UserlistActivity extends AppCompatActivity implements OnTabSelected
@Override
public void onTabReselected(Tab tab) {
adapter.scrollToTop(tab.getPosition());
}

View File

@ -14,6 +14,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayout.Tab;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.adapter.FragmentAdapter;
@ -130,17 +131,18 @@ public class UserlistsActivity extends AppCompatActivity implements TabLayout.On
@Override
public void onTabSelected(TabLayout.Tab tab) {
public void onTabSelected(Tab tab) {
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
public void onTabUnselected(Tab tab) {
adapter.scrollToTop(tab.getPosition());
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
public void onTabReselected(Tab tab) {
adapter.scrollToTop(tab.getPosition());
}
}

View File

@ -95,6 +95,7 @@ public class UsersActivity extends AppCompatActivity implements OnTabSelectedLis
private GlobalSettings settings;
private FilterLoader userExclTask;
private FragmentAdapter adapter;
private Toolbar toolbar;
private TabLayout tablayout;
@ -114,7 +115,7 @@ public class UsersActivity extends AppCompatActivity implements OnTabSelectedLis
tablayout = findViewById(R.id.userexclude_tab);
ViewPager pager = findViewById(R.id.userexclude_pager);
FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager());
adapter = new FragmentAdapter(getSupportFragmentManager());
pager.setAdapter(adapter);
settings = GlobalSettings.getInstance(this);
@ -228,11 +229,13 @@ public class UsersActivity extends AppCompatActivity implements OnTabSelectedLis
@Override
public void onTabUnselected(Tab tab) {
adapter.scrollToTop(tab.getPosition());
}
@Override
public void onTabReselected(Tab tab) {
adapter.scrollToTop(tab.getPosition());
}