use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.
the class GistsListActivity method setupTabs.
private void setupTabs() {
pager.setAdapter(new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForGists(this)));
tabs.setupWithViewPager(pager);
}
use of com.fastaccess.ui.adapter.FragmentsPagerAdapter in project FastHub by k0shk0sh.
the class CommitPagerActivity method onSetup.
@Override
public void onSetup() {
hideProgress();
if (getPresenter().getCommit() == null) {
return;
}
supportInvalidateOptionsMenu();
Commit commit = getPresenter().getCommit();
String login = commit.getAuthor() != null ? commit.getAuthor().getLogin() : commit.getGitCommit().getAuthor().getName();
String avatar = commit.getAuthor() != null ? commit.getAuthor().getAvatarUrl() : null;
Date dateValue = commit.getGitCommit().getAuthor().getDate();
HtmlHelper.htmlIntoTextView(title, commit.getGitCommit().getMessage(), title.getWidth());
setTaskName(commit.getLogin() + "/" + commit.getRepoId() + " - Commit " + StringsKt.take(commit.getSha(), 5));
detailsIcon.setVisibility(View.VISIBLE);
size.setVisibility(View.GONE);
date.setText(SpannableBuilder.builder().bold(getPresenter().repoId).append(" ").append(" ").append(ParseDateFormat.getTimeAgo(dateValue)));
avatarLayout.setUrl(avatar, login, false, LinkParserHelper.isEnterprise(commit.getHtmlUrl()));
addition.setText(String.valueOf(commit.getStats() != null ? commit.getStats().getAdditions() : 0));
deletion.setText(String.valueOf(commit.getStats() != null ? commit.getStats().getDeletions() : 0));
changes.setText(String.valueOf(commit.getFiles() != null ? commit.getFiles().size() : 0));
pager.setAdapter(new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForCommit(this, commit)));
tabs.setupWithViewPager(pager);
pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
hideShowFab();
}
});
hideShowFab();
TabLayout.Tab tabOne = tabs.getTabAt(0);
TabLayout.Tab tabTwo = tabs.getTabAt(1);
if (tabOne != null && commit.getFiles() != null) {
tabOne.setText(getString(R.string.files) + " (" + commit.getFiles().size() + ")");
}
if (tabTwo != null && commit.getGitCommit() != null && commit.getGitCommit().getCommentCount() > 0) {
tabTwo.setText(getString(R.string.comments) + " (" + commit.getGitCommit().getCommentCount() + ")");
}
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 RepoCodePagerFragment method onFragmentCreated.
@Override
protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
if (getArguments() != null) {
String repoId = getArguments().getString(BundleConstant.ID);
String login = getArguments().getString(BundleConstant.EXTRA);
String url = getArguments().getString(BundleConstant.EXTRA_TWO);
String htmlUrl = getArguments().getString(BundleConstant.EXTRA_FOUR);
String defaultBranch = getArguments().getString(BundleConstant.EXTRA_THREE);
if (InputHelper.isEmpty(repoId) || InputHelper.isEmpty(login) || InputHelper.isEmpty(url) || InputHelper.isEmpty(htmlUrl)) {
return;
}
pager.setAdapter(new FragmentsPagerAdapter(getChildFragmentManager(), FragmentPagerAdapterModel.buildForRepoCode(getContext(), repoId, login, url, Objects.toString(defaultBranch, "master"), htmlUrl)));
tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
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 GistActivity method onSetupDetails.
@Override
public void onSetupDetails() {
hideProgress();
Gist gistsModel = getPresenter().getGist();
if (gistsModel == null) {
return;
}
onUpdatePinIcon(gistsModel);
String url = gistsModel.getOwner() != null ? gistsModel.getOwner().getAvatarUrl() : gistsModel.getUser() != null ? gistsModel.getUser().getAvatarUrl() : "";
String login = gistsModel.getOwner() != null ? gistsModel.getOwner().getLogin() : gistsModel.getUser() != null ? gistsModel.getUser().getLogin() : "";
avatarLayout.setUrl(url, login, false, LinkParserHelper.isEnterprise(gistsModel.getHtmlUrl()));
title.setText(gistsModel.getDisplayTitle(false, true));
setTaskName(gistsModel.getDisplayTitle(false, true).toString());
edit.setVisibility(Login.getUser().getLogin().equals(login) ? View.VISIBLE : View.GONE);
detailsIcon.setVisibility(InputHelper.isEmpty(gistsModel.getDescription()) || !ViewHelper.isEllipsed(title) ? View.GONE : View.VISIBLE);
if (gistsModel.getCreatedAt().before(gistsModel.getUpdatedAt())) {
date.setText(String.format("%s %s", ParseDateFormat.getTimeAgo(gistsModel.getCreatedAt()), getString(R.string.edited)));
} else {
date.setText(ParseDateFormat.getTimeAgo(gistsModel.getCreatedAt()));
}
size.setText(Formatter.formatFileSize(this, gistsModel.getSize()));
pager.setAdapter(new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForGist(this, gistsModel)));
tabs.setupWithViewPager(pager);
pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
hideShowFab();
}
});
supportInvalidateOptionsMenu();
onGistForked(getPresenter().isForked());
onGistStarred(getPresenter().isStarred());
hideShowFab();
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 PinnedReposActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
selectPinned();
tabbedPager.setAdapter(new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForPinned(this)));
tabs.setupWithViewPager(tabbedPager);
tabs.setPadding(0, 0, 0, 0);
tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
}
Aggregations