use of com.meisolsson.githubsdk.model.Branch in project gh4a by slapperwan.
the class RepositoryActivity method showRefSelectionDialog.
private void showRefSelectionDialog() {
final BranchAndTagAdapter adapter = new BranchAndTagAdapter();
int current = -1, master = -1, count = adapter.getCount();
for (int i = 0; i < count; i++) {
Branch item = adapter.getItem(i);
if (item.name().equals(mSelectedRef) || item.commit().sha().equals(mSelectedRef)) {
current = i;
}
if (item.name().equals(mRepository.defaultBranch())) {
master = i;
}
}
if (mSelectedRef == null && current == -1) {
current = master;
}
new AlertDialog.Builder(this).setCancelable(true).setTitle(R.string.repo_select_ref_dialog_title).setSingleChoiceItems(adapter, current, (dialog, which) -> {
setSelectedRef(adapter.getItem(which).name());
dialog.dismiss();
}).setNegativeButton(R.string.cancel, null).show();
}
use of com.meisolsson.githubsdk.model.Branch in project gh4a by slapperwan.
the class RepositoryActivity method loadOrShowRefSelection.
private void loadOrShowRefSelection() {
if (mBranches != null) {
showRefSelectionDialog();
} else {
final RepositoryBranchService branchService = ServiceFactory.get(RepositoryBranchService.class, false);
final RepositoryService repoService = ServiceFactory.get(RepositoryService.class, false);
Single<List<Branch>> branchSingle = ApiHelpers.PageIterator.toSingle(page -> branchService.getBranches(mRepoOwner, mRepoName, page));
Single<List<Branch>> tagSingle = ApiHelpers.PageIterator.toSingle(page -> repoService.getTags(mRepoOwner, mRepoName, page));
registerTemporarySubscription(Single.zip(branchSingle, tagSingle, Pair::create).compose(RxUtils::doInBackground).compose(RxUtils.wrapWithProgressDialog(this, R.string.loading_msg)).subscribe(result -> {
mBranches = result.first;
mTags = result.second;
showRefSelectionDialog();
}, this::handleLoadFailure));
}
}
Aggregations