use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.
the class TeamPagerActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
id = getIntent().getExtras().getLong(BundleConstant.ID);
name = getIntent().getExtras().getString(BundleConstant.EXTRA);
}
setTitle(name);
if (id <= 0) {
finish();
return;
}
FragmentsPagerAdapter adapter = new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForTeam(this, id));
pager.setAdapter(adapter);
tabs.setTabGravity(TabLayout.GRAVITY_FILL);
tabs.setTabMode(TabLayout.MODE_FIXED);
tabs.setupWithViewPager(pager);
tabs.setPaddingRelative(0, 0, 0, 0);
tabs.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager) {
@Override
public void onTabReselected(TabLayout.Tab tab) {
super.onTabReselected(tab);
onScrollTop(tab.getPosition());
}
});
}
use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.
the class NotificationActivity method setupTabs.
private void setupTabs() {
pager.setAdapter(new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForNotifications(this)));
tabs.setupWithViewPager(pager);
}
use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.
the class RepoPullRequestPagerFragment method onFragmentCreated.
@Override
protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
String repoId = getArguments().getString(BundleConstant.ID);
String login = getArguments().getString(BundleConstant.EXTRA);
if (login == null || repoId == null)
throw new NullPointerException("repoId || login is null???");
pager.setAdapter(new FragmentsPagerAdapter(getChildFragmentManager(), FragmentPagerAdapterModel.buildForRepoPullRequest(getContext(), login, repoId)));
tabs.setupWithViewPager(pager);
if (savedInstanceState != null && !counts.isEmpty()) {
Stream.of(counts).forEach(this::updateCount);
}
tabs.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager) {
@Override
public void onTabReselected(TabLayout.Tab tab) {
super.onTabReselected(tab);
onScrollTop(tab.getPosition());
}
});
}
use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.
the class MyIssuesPagerFragment method onFragmentCreated.
@Override
protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
FragmentsPagerAdapter adapter = new FragmentsPagerAdapter(getChildFragmentManager(), FragmentPagerAdapterModel.buildForMyIssues(getContext()));
pager.setAdapter(adapter);
// noinspection deprecation
tabs.setTabsFromPagerAdapter(adapter);
tabs.setTabGravity(TabLayout.GRAVITY_FILL);
tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
if (savedInstanceState == null) {
tabs.getTabAt(0).select();
}
pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
selectTab(position, true);
}
});
tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
if (tab.getTag() == null) {
int position = tab.getPosition();
selectTab(position, false);
}
tab.setTag(null);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
selectTab(tab.getPosition(), false);
}
});
if (savedInstanceState != null && !counts.isEmpty()) {
Stream.of(counts).forEach(this::updateCount);
}
}
use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.
the class MyPullsPagerFragment method onFragmentCreated.
@Override
protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
FragmentsPagerAdapter adapter = new FragmentsPagerAdapter(getChildFragmentManager(), FragmentPagerAdapterModel.buildForMyPulls(getContext()));
pager.setAdapter(adapter);
// noinspection deprecation
tabs.setTabsFromPagerAdapter(adapter);
tabs.setTabGravity(TabLayout.GRAVITY_FILL);
tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
if (savedInstanceState == null) {
tabs.getTabAt(0).select();
}
pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
selectTab(position, true);
}
});
tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
if (tab.getTag() == null) {
int position = tab.getPosition();
selectTab(position, false);
}
tab.setTag(null);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
selectTab(tab.getPosition(), false);
}
});
if (savedInstanceState != null && !counts.isEmpty()) {
Stream.of(counts).forEach(this::updateCount);
}
}
Aggregations