Search in sources :

Example 1 with FragmentsPagerAdapter

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());
        }
    });
}
Also used : FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter) TabLayout(android.support.design.widget.TabLayout)

Example 2 with FragmentsPagerAdapter

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);
}
Also used : FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter)

Example 3 with FragmentsPagerAdapter

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());
        }
    });
}
Also used : FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter) TabLayout(android.support.design.widget.TabLayout)

Example 4 with FragmentsPagerAdapter

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);
    }
}
Also used : FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter) TabLayout(android.support.design.widget.TabLayout) ViewPager(android.support.v4.view.ViewPager)

Example 5 with FragmentsPagerAdapter

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);
    }
}
Also used : FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter) TabLayout(android.support.design.widget.TabLayout) ViewPager(android.support.v4.view.ViewPager)

Aggregations

FragmentsPagerAdapter (com.fastaccess.ui.adapter.FragmentsPagerAdapter)17 TabLayout (android.support.design.widget.TabLayout)11 ViewPager (android.support.v4.view.ViewPager)7 Commit (com.fastaccess.data.dao.model.Commit)1 Gist (com.fastaccess.data.dao.model.Gist)1 Issue (com.fastaccess.data.dao.model.Issue)1 Login (com.fastaccess.data.dao.model.Login)1 PullRequest (com.fastaccess.data.dao.model.PullRequest)1 IssueTimelineFragment (com.fastaccess.ui.modules.repos.issues.issue.details.timeline.IssueTimelineFragment)1 PullRequestTimelineFragment (com.fastaccess.ui.modules.repos.pull_requests.pull_request.details.timeline.timeline.PullRequestTimelineFragment)1 Date (java.util.Date)1