mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
this commit retain instance of tabs text count & also list down tags to filter commits & files.
This commit is contained in:
parent
8b445afed5
commit
0ed1e993fe
@ -126,6 +126,9 @@ public interface RepoService {
|
||||
@NonNull @GET("repos/{owner}/{repo}/branches")
|
||||
Observable<Pageable<BranchesModel>> getBranches(@NonNull @Path("owner") String owner, @NonNull @Path("repo") String repo);
|
||||
|
||||
@NonNull @GET("repos/{owner}/{repo}/tags")
|
||||
Observable<Pageable<BranchesModel>> getTags(@NonNull @Path("owner") String owner, @NonNull @Path("repo") String repo);
|
||||
|
||||
@NonNull @GET("repos/{owner}/{repo}/milestones")
|
||||
Observable<Pageable<MilestoneModel>> getMilestones(@Path("owner") String owner, @Path("repo") String repo);
|
||||
|
||||
@ -137,5 +140,5 @@ public interface RepoService {
|
||||
Observable<Pageable<User>> getAssignees(@Path("owner") String owner, @Path("repo") String repo);
|
||||
|
||||
@NonNull @GET("repos/{owner}/{repo}/commits?per_page=1")
|
||||
Observable<Pageable<Commit>> getCommitCounts(@Path("owner") String owner, @Path("repo") String repo);
|
||||
Observable<Pageable<Commit>> getCommitCounts(@Path("owner") String owner, @Path("repo") String repo, @Query("ref") String ref);
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import com.fastaccess.ui.widgets.SpannableBuilder;
|
||||
import com.fastaccess.ui.widgets.ViewPagerView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import icepick.State;
|
||||
|
||||
/**
|
||||
* Created by Kosh on 26 Mar 2017, 12:14 AM
|
||||
@ -27,6 +28,8 @@ public class MyIssuesPagerView extends BaseFragment<MyIssuesPagerMvp.View, MyIss
|
||||
|
||||
@BindView(R.id.tabs) TabLayout tabs;
|
||||
@BindView(R.id.pager) ViewPagerView pager;
|
||||
@State int openCount = -1;
|
||||
@State int closeCount = -1;
|
||||
|
||||
public static MyIssuesPagerView newInstance() {
|
||||
return new MyIssuesPagerView();
|
||||
@ -39,6 +42,10 @@ public class MyIssuesPagerView extends BaseFragment<MyIssuesPagerMvp.View, MyIss
|
||||
@Override protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
pager.setAdapter(new FragmentsPagerAdapter(getChildFragmentManager(), FragmentPagerAdapterModel.buildForMyIssues(getContext())));
|
||||
tabs.setupWithViewPager(pager);
|
||||
if (savedInstanceState != null && openCount != -1 && closeCount != -1) {
|
||||
onSetBadge(0, openCount);
|
||||
onSetBadge(1, closeCount);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Override public MyIssuesPagerPresenter providePresenter() {
|
||||
@ -46,6 +53,11 @@ public class MyIssuesPagerView extends BaseFragment<MyIssuesPagerMvp.View, MyIss
|
||||
}
|
||||
|
||||
@Override public void onSetBadge(int tabIndex, int count) {
|
||||
if (tabIndex == 0) {
|
||||
openCount = count;
|
||||
} else {
|
||||
closeCount = count;
|
||||
}
|
||||
if (tabs != null) {
|
||||
TextView tv = ViewHelper.getTabTextView(tabs, tabIndex);
|
||||
tv.setText(SpannableBuilder.builder()
|
||||
|
||||
@ -16,6 +16,7 @@ import com.fastaccess.ui.widgets.SpannableBuilder;
|
||||
import com.fastaccess.ui.widgets.ViewPagerView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import icepick.State;
|
||||
|
||||
/**
|
||||
* Created by Kosh on 26 Mar 2017, 12:14 AM
|
||||
@ -27,6 +28,8 @@ public class MyPullsPagerView extends BaseFragment<MyPullsPagerMvp.View, MyPulls
|
||||
|
||||
@BindView(R.id.tabs) TabLayout tabs;
|
||||
@BindView(R.id.pager) ViewPagerView pager;
|
||||
@State int openCount = -1;
|
||||
@State int closeCount = -1;
|
||||
|
||||
public static MyPullsPagerView newInstance() {
|
||||
return new MyPullsPagerView();
|
||||
@ -39,6 +42,10 @@ public class MyPullsPagerView extends BaseFragment<MyPullsPagerMvp.View, MyPulls
|
||||
@Override protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
pager.setAdapter(new FragmentsPagerAdapter(getChildFragmentManager(), FragmentPagerAdapterModel.buildForMyPulls(getContext())));
|
||||
tabs.setupWithViewPager(pager);
|
||||
if (savedInstanceState != null && openCount != -1 && closeCount != -1) {
|
||||
onSetBadge(0, openCount);
|
||||
onSetBadge(1, closeCount);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Override public MyPullsPagerPresenter providePresenter() {
|
||||
@ -46,6 +53,11 @@ public class MyPullsPagerView extends BaseFragment<MyPullsPagerMvp.View, MyPulls
|
||||
}
|
||||
|
||||
@Override public void onSetBadge(int tabIndex, int count) {
|
||||
if (tabIndex == 0) {
|
||||
openCount = count;
|
||||
} else {
|
||||
closeCount = count;
|
||||
}
|
||||
if (tabs != null) {
|
||||
TextView tv = ViewHelper.getTabTextView(tabs, tabIndex);
|
||||
tv.setText(SpannableBuilder.builder()
|
||||
|
||||
@ -65,14 +65,17 @@ class RepoCommitsPresenter extends BasePresenter<RepoCommitsMvp.View> implements
|
||||
return;
|
||||
}
|
||||
if (repoId == null || login == null) return;
|
||||
makeRestCall(RestProvider.getRepoService().getCommits(login, repoId, branch, page),
|
||||
makeRestCall(RestProvider.getRepoService()
|
||||
.getCommits(login, repoId, branch, page),
|
||||
response -> {
|
||||
lastPage = response.getLast();
|
||||
if (getCurrentPage() == 1) {
|
||||
getCommits().clear();
|
||||
manageSubscription(Commit.save(response.getItems(), repoId, login).subscribe());
|
||||
if (response != null) {
|
||||
lastPage = response.getLast();
|
||||
if (getCurrentPage() == 1) {
|
||||
getCommits().clear();
|
||||
manageSubscription(Commit.save(response.getItems(), repoId, login).subscribe());
|
||||
}
|
||||
getCommits().addAll(response.getItems());
|
||||
}
|
||||
getCommits().addAll(response.getItems());
|
||||
sendToView(RepoCommitsMvp.View::onNotifyAdapter);
|
||||
});
|
||||
}
|
||||
@ -83,16 +86,15 @@ class RepoCommitsPresenter extends BasePresenter<RepoCommitsMvp.View> implements
|
||||
branch = bundle.getString(BundleConstant.EXTRA_TWO);
|
||||
if (branches.isEmpty()) {
|
||||
manageSubscription(RxHelper.safeObservable(RxHelper.getObserver(RestProvider.getRepoService()
|
||||
.getCommitCounts(login, repoId)))
|
||||
.getCommitCounts(login, repoId, branch)))
|
||||
.subscribe(response -> {
|
||||
if (response != null) {
|
||||
sendToView(view -> view.onShowCommitCount(response.getLast()));
|
||||
}
|
||||
}));
|
||||
makeRestCall(RestProvider.getRepoService()
|
||||
.getBranches(login, repoId)
|
||||
.doOnSubscribe(() -> sendToView(RepoCommitsMvp.View::showBranchesProgress)),
|
||||
response -> {
|
||||
manageSubscription(RxHelper.safeObservable(RxHelper.getObserver(RestProvider.getRepoService()
|
||||
.getBranches(login, repoId)
|
||||
.doOnNext(response -> {
|
||||
if (response != null && response.getItems() != null) {
|
||||
branches.clear();
|
||||
branches.addAll(response.getItems());
|
||||
@ -101,7 +103,17 @@ class RepoCommitsPresenter extends BasePresenter<RepoCommitsMvp.View> implements
|
||||
view.hideBranchesProgress();
|
||||
});
|
||||
}
|
||||
});
|
||||
})))
|
||||
.flatMap(branchesModelPageable -> RxHelper.safeObservable(RxHelper.getObserver(RestProvider.getRepoService()
|
||||
.getTags(login, repoId))))
|
||||
.doOnNext(response -> {
|
||||
branches.addAll(response.getItems());
|
||||
sendToView(view -> {
|
||||
view.setBranchesData(branches, true);
|
||||
view.hideBranchesProgress();
|
||||
});
|
||||
})
|
||||
.subscribe());
|
||||
}
|
||||
if (!InputHelper.isEmpty(login) && !InputHelper.isEmpty(repoId)) {
|
||||
onCallApi(1, null);
|
||||
|
||||
@ -27,6 +27,7 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnItemSelected;
|
||||
import icepick.State;
|
||||
|
||||
/**
|
||||
* Created by Kosh on 03 Dec 2016, 3:56 PM
|
||||
@ -38,6 +39,7 @@ public class RepoCommitsView extends BaseFragment<RepoCommitsMvp.View, RepoCommi
|
||||
@BindView(R.id.stateLayout) StateLayout stateLayout;
|
||||
@BindView(R.id.branches) AppCompatSpinner branches;
|
||||
@BindView(R.id.branchesProgress) ProgressBar branchesProgress;
|
||||
@State long commitCount = -1;
|
||||
private OnLoadMore onLoadMore;
|
||||
private CommitsAdapter adapter;
|
||||
private RepoPagerMvp.View repoCallback;
|
||||
@ -106,6 +108,8 @@ public class RepoCommitsView extends BaseFragment<RepoCommitsMvp.View, RepoCommi
|
||||
getPresenter().onFragmentCreated(getArguments());
|
||||
} else if (getPresenter().getCommits().isEmpty() && !getPresenter().isApiCalled()) {
|
||||
onRefresh();
|
||||
} else {
|
||||
if (commitCount != -1) onShowCommitCount(commitCount);
|
||||
}
|
||||
setBranchesData(getPresenter().getBranches(), false);
|
||||
}
|
||||
@ -171,6 +175,7 @@ public class RepoCommitsView extends BaseFragment<RepoCommitsMvp.View, RepoCommi
|
||||
}
|
||||
|
||||
@Override public void onShowCommitCount(long sum) {
|
||||
this.commitCount = sum;
|
||||
if (tabsBadgeListener != null) {
|
||||
tabsBadgeListener.onSetBadge(2, (int) sum);
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import com.fastaccess.data.dao.BranchesModel;
|
||||
import com.fastaccess.data.dao.model.RepoFile;
|
||||
import com.fastaccess.helper.BundleConstant;
|
||||
import com.fastaccess.helper.InputHelper;
|
||||
import com.fastaccess.helper.RxHelper;
|
||||
import com.fastaccess.provider.rest.RestProvider;
|
||||
import com.fastaccess.ui.base.mvp.presenter.BasePresenter;
|
||||
|
||||
@ -46,8 +47,9 @@ class RepoFilePathPresenter extends BasePresenter<RepoFilePathMvp.View> implemen
|
||||
}
|
||||
sendToView(RepoFilePathMvp.View::onSendData);
|
||||
if (branches.isEmpty()) {
|
||||
makeRestCall(RestProvider.getRepoService().getBranches(login, repoId),
|
||||
response -> {
|
||||
manageSubscription(RxHelper.safeObservable(RxHelper.getObserver(RestProvider.getRepoService()
|
||||
.getBranches(login, repoId)
|
||||
.doOnNext(response -> {
|
||||
if (response != null && response.getItems() != null) {
|
||||
branches.clear();
|
||||
branches.addAll(response.getItems());
|
||||
@ -56,7 +58,17 @@ class RepoFilePathPresenter extends BasePresenter<RepoFilePathMvp.View> implemen
|
||||
view.hideProgress();
|
||||
});
|
||||
}
|
||||
});
|
||||
})))
|
||||
.flatMap(branchesModelPageable -> RxHelper.safeObservable(RxHelper.getObserver(RestProvider.getRepoService()
|
||||
.getTags(login, repoId))))
|
||||
.doOnNext(response -> {
|
||||
branches.addAll(response.getItems());
|
||||
sendToView(view -> {
|
||||
view.setBranchesData(branches, true);
|
||||
view.hideProgress();
|
||||
});
|
||||
})
|
||||
.subscribe());
|
||||
}
|
||||
} else {
|
||||
throw new NullPointerException("Bundle is null");
|
||||
|
||||
@ -19,6 +19,7 @@ import com.fastaccess.ui.widgets.SpannableBuilder;
|
||||
import com.fastaccess.ui.widgets.ViewPagerView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import icepick.State;
|
||||
|
||||
/**
|
||||
* Created by Kosh on 31 Dec 2016, 1:36 AM
|
||||
@ -30,6 +31,8 @@ public class RepoIssuesPagerView extends BaseFragment<RepoIssuesPagerMvp.View, R
|
||||
public static final String TAG = RepoIssuesPagerView.class.getSimpleName();
|
||||
@BindView(R.id.tabs) TabLayout tabs;
|
||||
@BindView(R.id.pager) ViewPagerView pager;
|
||||
@State int openCount = -1;
|
||||
@State int closeCount = -1;
|
||||
|
||||
public static RepoIssuesPagerView newInstance(@NonNull String repoId, @NonNull String login) {
|
||||
RepoIssuesPagerView view = new RepoIssuesPagerView();
|
||||
@ -51,6 +54,10 @@ public class RepoIssuesPagerView extends BaseFragment<RepoIssuesPagerMvp.View, R
|
||||
pager.setAdapter(new FragmentsPagerAdapter(getChildFragmentManager(),
|
||||
FragmentPagerAdapterModel.buildForRepoIssue(getContext(), login, repoId)));
|
||||
tabs.setupWithViewPager(pager);
|
||||
if (savedInstanceState != null && openCount != -1 && closeCount != -1) {
|
||||
onSetBadge(0, openCount);
|
||||
onSetBadge(1, closeCount);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Override public RepoIssuesPagerPresenter providePresenter() {
|
||||
@ -68,6 +75,11 @@ public class RepoIssuesPagerView extends BaseFragment<RepoIssuesPagerMvp.View, R
|
||||
}
|
||||
|
||||
@Override public void onSetBadge(int tabIndex, int count) {
|
||||
if (tabIndex == 0) {
|
||||
openCount = count;
|
||||
} else {
|
||||
closeCount = count;
|
||||
}
|
||||
if (tabs != null) {
|
||||
TextView tv = ViewHelper.getTabTextView(tabs, tabIndex);
|
||||
tv.setText(SpannableBuilder.builder()
|
||||
|
||||
@ -18,6 +18,7 @@ import com.fastaccess.ui.widgets.SpannableBuilder;
|
||||
import com.fastaccess.ui.widgets.ViewPagerView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import icepick.State;
|
||||
|
||||
/**
|
||||
* Created by Kosh on 31 Dec 2016, 1:36 AM
|
||||
@ -30,6 +31,9 @@ public class RepoPullRequestPagerView extends BaseFragment<RepoPullRequestPagerM
|
||||
|
||||
@BindView(R.id.tabs) TabLayout tabs;
|
||||
@BindView(R.id.pager) ViewPagerView pager;
|
||||
@State int openCount = -1;
|
||||
@State int closeCount = -1;
|
||||
|
||||
|
||||
public static RepoPullRequestPagerView newInstance(@NonNull String repoId, @NonNull String login) {
|
||||
RepoPullRequestPagerView view = new RepoPullRequestPagerView();
|
||||
@ -51,6 +55,10 @@ public class RepoPullRequestPagerView extends BaseFragment<RepoPullRequestPagerM
|
||||
pager.setAdapter(new FragmentsPagerAdapter(getChildFragmentManager(),
|
||||
FragmentPagerAdapterModel.buildForRepoPullRequest(getContext(), login, repoId)));
|
||||
tabs.setupWithViewPager(pager);
|
||||
if (savedInstanceState != null && openCount != -1 && closeCount != -1) {
|
||||
onSetBadge(0, openCount);
|
||||
onSetBadge(1, closeCount);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Override public RepoPullRequestPagerPresenter providePresenter() {
|
||||
@ -58,6 +66,11 @@ public class RepoPullRequestPagerView extends BaseFragment<RepoPullRequestPagerM
|
||||
}
|
||||
|
||||
@Override public void onSetBadge(int tabIndex, int count) {
|
||||
if (tabIndex == 0) {
|
||||
openCount = count;
|
||||
} else {
|
||||
closeCount = count;
|
||||
}
|
||||
if (tabs != null) {
|
||||
TextView tv = ViewHelper.getTabTextView(tabs, tabIndex);
|
||||
tv.setText(SpannableBuilder.builder()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user