Search in sources :

Example 11 with FragmentsPagerAdapter

use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.

the class ProfilePagerFragment method onFragmentCreated.

@Override
protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    if (getArguments() == null) {
        throw new RuntimeException("Bundle is null?");
    }
    String login = getArguments().getString(BundleConstant.EXTRA);
    if (login == null) {
        throw new RuntimeException("user is null?");
    }
    FragmentsPagerAdapter adapter = new FragmentsPagerAdapter(getChildFragmentManager(), FragmentPagerAdapterModel.buildForProfile(getContext(), login));
    tabs.setTabGravity(TabLayout.GRAVITY_FILL);
    tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
    pager.setAdapter(adapter);
    tabs.setupWithViewPager(pager);
}
Also used : FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter)

Example 12 with FragmentsPagerAdapter

use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.

the class IssuePagerActivity method onSetupIssue.

@Override
public void onSetupIssue(boolean isUpdate) {
    hideProgress();
    if (getPresenter().getIssue() == null) {
        return;
    }
    onUpdateMenu();
    Issue issueModel = getPresenter().getIssue();
    setTaskName(issueModel.getRepoId() + " - " + issueModel.getTitle());
    setTitle(String.format("#%s", issueModel.getNumber()));
    if (getSupportActionBar() != null) {
        getSupportActionBar().setSubtitle(issueModel.getRepoId());
    }
    updateViews(issueModel);
    if (isUpdate) {
        IssueTimelineFragment issueDetailsView = getIssueTimelineFragment();
        if (issueDetailsView != null && getPresenter().getIssue() != null) {
            issueDetailsView.onUpdateHeader();
        }
    } else {
        if (pager.getAdapter() == null) {
            Logger.e(getPresenter().commentId);
            pager.setAdapter(new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForIssues(this, getPresenter().commentId)));
        } else {
            onUpdateTimeline();
        }
    }
    if (!getPresenter().isLocked() || getPresenter().isOwner()) {
        pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
                hideShowFab();
            }
        });
    }
    hideShowFab();
}
Also used : Issue(com.fastaccess.data.dao.model.Issue) FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter) IssueTimelineFragment(com.fastaccess.ui.modules.repos.issues.issue.details.timeline.IssueTimelineFragment) ViewPager(android.support.v4.view.ViewPager)

Example 13 with FragmentsPagerAdapter

use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.

the class PullRequestPagerActivity method onSetupIssue.

@Override
public void onSetupIssue(boolean update) {
    hideProgress();
    if (getPresenter().getPullRequest() == null) {
        return;
    }
    invalidateOptionsMenu();
    PullRequest pullRequest = getPresenter().getPullRequest();
    setTaskName(pullRequest.getRepoId() + " - " + pullRequest.getTitle());
    updateViews(pullRequest);
    if (update) {
        PullRequestTimelineFragment issueDetailsView = getPullRequestTimelineFragment();
        if (issueDetailsView != null && getPresenter().getPullRequest() != null) {
            issueDetailsView.onUpdateHeader();
        }
    } else {
        if (pager.getAdapter() == null) {
            pager.setAdapter(new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForPullRequest(this, pullRequest)));
            tabs.setupWithViewPager(pager);
            tabs.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager) {

                @Override
                public void onTabReselected(TabLayout.Tab tab) {
                    super.onTabReselected(tab);
                    onScrollTop(tab.getPosition());
                }
            });
        } else {
            onUpdateTimeline();
        }
    }
    pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            hideShowFab();
            super.onPageSelected(position);
        }
    });
    initTabs(pullRequest);
    hideShowFab();
    AnimHelper.mimicFabVisibility(getPresenter().hasReviewComments(), prReviewHolder, null);
    reviewsCount.setText(String.format("%s", getPresenter().getCommitComment().size()));
}
Also used : FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter) TabLayout(android.support.design.widget.TabLayout) PullRequest(com.fastaccess.data.dao.model.PullRequest) PullRequestTimelineFragment(com.fastaccess.ui.modules.repos.pull_requests.pull_request.details.timeline.timeline.PullRequestTimelineFragment) ViewPager(android.support.v4.view.ViewPager)

Example 14 with FragmentsPagerAdapter

use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.

the class UserPagerActivity method onInitOrg.

@Override
public void onInitOrg(boolean isMember) {
    hideProgress();
    FragmentsPagerAdapter adapter = new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForOrg(this, login, isMember));
    pager.setAdapter(adapter);
    tabs.setTabGravity(TabLayout.GRAVITY_FILL);
    tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
    tabs.setupWithViewPager(pager);
    setTaskName(login);
}
Also used : FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter)

Example 15 with FragmentsPagerAdapter

use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.

the class UserPagerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Login currentUser = Login.getUser();
    if (currentUser == null) {
        onRequireLogin();
        return;
    }
    if (savedInstanceState == null) {
        if (getIntent() != null && getIntent().getExtras() != null) {
            login = getIntent().getExtras().getString(BundleConstant.EXTRA);
            isOrg = getIntent().getExtras().getBoolean(BundleConstant.EXTRA_TYPE);
            index = getIntent().getExtras().getInt(BundleConstant.EXTRA_TWO, -1);
            if (!InputHelper.isEmpty(login)) {
                if (isOrg) {
                    getPresenter().checkOrgMembership(login);
                } else {
                    if (!Login.getUser().getLogin().equalsIgnoreCase(login))
                        getPresenter().onCheckBlocking(login);
                }
            }
        } else {
            Login user = Login.getUser();
            if (user == null) {
                onRequireLogin();
                return;
            }
            login = user.getLogin();
        }
    }
    if (InputHelper.isEmpty(login)) {
        finish();
        return;
    }
    setTaskName(login);
    setTitle(login);
    if (login.equalsIgnoreCase(currentUser.getLogin())) {
        selectProfile();
    }
    if (!isOrg) {
        FragmentsPagerAdapter adapter = new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForProfile(this, login));
        pager.setAdapter(adapter);
        tabs.setTabGravity(TabLayout.GRAVITY_FILL);
        tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
        tabs.setupWithViewPager(pager);
        if (savedInstanceState == null) {
            if (index != -1) {
                pager.setCurrentItem(index);
            }
        }
    } else {
        if (getPresenter().getIsMember() == -1) {
            getPresenter().checkOrgMembership(login);
        } else {
            onInitOrg(getPresenter().isMember == 1);
        }
    }
    tabs.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager) {

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            super.onTabReselected(tab);
            onScrollTop(tab.getPosition());
        }
    });
    pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            hideShowFab(position);
        }
    });
    if (!isOrg) {
        if (savedInstanceState != null && !counts.isEmpty()) {
            Stream.of(counts).forEach(this::updateCount);
        }
    }
    hideShowFab(pager.getCurrentItem());
}
Also used : FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter) TabLayout(android.support.design.widget.TabLayout) Login(com.fastaccess.data.dao.model.Login) 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