mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
this adds commit count however disabling it for now #222
This commit is contained in:
parent
828fa20f50
commit
a43f3259b1
@ -0,0 +1,41 @@
|
||||
package com.fastaccess.data.dao;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Created by Kosh on 01 Apr 2017, 12:42 PM
|
||||
*/
|
||||
@Getter @Setter public class CommitCountModel implements Parcelable {
|
||||
|
||||
private List<Integer> all;
|
||||
private List<Integer> owner;
|
||||
|
||||
@Override public int describeContents() { return 0; }
|
||||
|
||||
@Override public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeList(this.all);
|
||||
dest.writeList(this.owner);
|
||||
}
|
||||
|
||||
public CommitCountModel() {}
|
||||
|
||||
protected CommitCountModel(Parcel in) {
|
||||
this.all = new ArrayList<Integer>();
|
||||
in.readList(this.all, Integer.class.getClassLoader());
|
||||
this.owner = new ArrayList<Integer>();
|
||||
in.readList(this.owner, Integer.class.getClassLoader());
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<CommitCountModel> CREATOR = new Parcelable.Creator<CommitCountModel>() {
|
||||
@Override public CommitCountModel createFromParcel(Parcel source) {return new CommitCountModel(source);}
|
||||
|
||||
@Override public CommitCountModel[] newArray(int size) {return new CommitCountModel[size];}
|
||||
};
|
||||
}
|
||||
@ -4,6 +4,7 @@ import android.support.annotation.NonNull;
|
||||
|
||||
import com.fastaccess.data.dao.BranchesModel;
|
||||
import com.fastaccess.data.dao.CommentRequestModel;
|
||||
import com.fastaccess.data.dao.CommitCountModel;
|
||||
import com.fastaccess.data.dao.CreateMilestoneModel;
|
||||
import com.fastaccess.data.dao.LabelModel;
|
||||
import com.fastaccess.data.dao.MarkdownModel;
|
||||
@ -128,4 +129,7 @@ public interface RepoService {
|
||||
|
||||
@NonNull @GET("repos/{owner}/{repo}/assignees")
|
||||
Observable<Pageable<User>> getAssignees(@Path("owner") String owner, @Path("repo") String repo);
|
||||
|
||||
@NonNull @GET("/repos/{owner}/{repo}/stats/participation")
|
||||
Observable<CommitCountModel> getCommitCounts(@Path("owner") String owner, @Path("repo") String repo);
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.fastaccess.ui.modules.repos.code;
|
||||
|
||||
import com.fastaccess.ui.base.mvp.BaseMvp;
|
||||
import com.fastaccess.ui.modules.repos.RepoPagerMvp;
|
||||
|
||||
/**
|
||||
* Created by Kosh on 31 Dec 2016, 1:35 AM
|
||||
@ -8,7 +9,7 @@ import com.fastaccess.ui.base.mvp.BaseMvp;
|
||||
|
||||
public interface RepoCodePagerMvp {
|
||||
|
||||
interface View extends BaseMvp.FAView {
|
||||
interface View extends BaseMvp.FAView, RepoPagerMvp.TabsBadgeListener {
|
||||
boolean canPressBack();
|
||||
|
||||
void onBackPressed();
|
||||
|
||||
@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.annimon.stream.Objects;
|
||||
import com.fastaccess.R;
|
||||
@ -12,9 +13,11 @@ import com.fastaccess.data.dao.FragmentPagerAdapterModel;
|
||||
import com.fastaccess.helper.BundleConstant;
|
||||
import com.fastaccess.helper.Bundler;
|
||||
import com.fastaccess.helper.InputHelper;
|
||||
import com.fastaccess.helper.ViewHelper;
|
||||
import com.fastaccess.ui.adapter.FragmentsPagerAdapter;
|
||||
import com.fastaccess.ui.base.BaseFragment;
|
||||
import com.fastaccess.ui.modules.repos.code.files.paths.RepoFilePathView;
|
||||
import com.fastaccess.ui.widgets.SpannableBuilder;
|
||||
import com.fastaccess.ui.widgets.ViewPagerView;
|
||||
|
||||
import butterknife.BindView;
|
||||
@ -77,4 +80,16 @@ public class RepoCodePagerView extends BaseFragment<RepoCodePagerMvp.View, RepoC
|
||||
pathView.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onSetBadge(int tabIndex, int count) {
|
||||
if (tabs != null && tabIndex == 2) {
|
||||
TextView tv = ViewHelper.getTabTextView(tabs, tabIndex);
|
||||
tv.setText(SpannableBuilder.builder()
|
||||
.append(getString(R.string.commits))
|
||||
.append(" ")
|
||||
.append("(")
|
||||
.bold(String.valueOf(count))
|
||||
.append(")"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,8 @@ import java.util.List;
|
||||
|
||||
interface RepoCommitsMvp {
|
||||
|
||||
interface View extends BaseMvp.FAView, SwipeRefreshLayout.OnRefreshListener, android.view.View.OnClickListener {
|
||||
interface View extends BaseMvp.FAView, SwipeRefreshLayout.OnRefreshListener,
|
||||
android.view.View.OnClickListener {
|
||||
void onNotifyAdapter();
|
||||
|
||||
@NonNull OnLoadMore getLoadMore();
|
||||
@ -29,6 +30,8 @@ interface RepoCommitsMvp {
|
||||
void showBranchesProgress();
|
||||
|
||||
void hideBranchesProgress();
|
||||
|
||||
void onShowCommitCount(long sum);
|
||||
}
|
||||
|
||||
interface Presenter extends BaseMvp.FAPresenter,
|
||||
|
||||
@ -82,6 +82,10 @@ class RepoCommitsPresenter extends BasePresenter<RepoCommitsMvp.View> implements
|
||||
login = bundle.getString(BundleConstant.EXTRA);
|
||||
branch = bundle.getString(BundleConstant.EXTRA_TWO);
|
||||
if (branches.isEmpty()) {
|
||||
// manageSubscription(RxHelper.safeObservable(RxHelper.getObserver(RestProvider.getRepoService()
|
||||
// .getCommitCounts(login, repoId)))
|
||||
// .map(commitCountModel -> Stream.of(commitCountModel.getAll()).mapToLong(Integer::longValue).sum())
|
||||
// .subscribe(sum -> sendToView(view -> view.onShowCommitCount(sum))));
|
||||
makeRestCall(RestProvider.getRepoService()
|
||||
.getBranches(login, repoId)
|
||||
.doOnSubscribe(() -> sendToView(RepoCommitsMvp.View::showBranchesProgress)),
|
||||
|
||||
@ -41,6 +41,7 @@ public class RepoCommitsView extends BaseFragment<RepoCommitsMvp.View, RepoCommi
|
||||
private OnLoadMore onLoadMore;
|
||||
private CommitsAdapter adapter;
|
||||
private RepoPagerMvp.View repoCallback;
|
||||
private RepoPagerMvp.TabsBadgeListener tabsBadgeListener;
|
||||
|
||||
public static RepoCommitsView newInstance(@NonNull String repoId, @NonNull String login, @NonNull String branch) {
|
||||
RepoCommitsView view = new RepoCommitsView();
|
||||
@ -66,6 +67,11 @@ public class RepoCommitsView extends BaseFragment<RepoCommitsMvp.View, RepoCommi
|
||||
} else if (getParentFragment() instanceof RepoPagerMvp.View) {
|
||||
repoCallback = (RepoPagerMvp.View) getParentFragment();
|
||||
}
|
||||
if (context instanceof RepoPagerMvp.TabsBadgeListener) {
|
||||
tabsBadgeListener = (RepoPagerMvp.TabsBadgeListener) context;
|
||||
} else if (getParentFragment() instanceof RepoPagerMvp.TabsBadgeListener) {
|
||||
tabsBadgeListener = (RepoPagerMvp.TabsBadgeListener) getParentFragment();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onDetach() {
|
||||
@ -128,12 +134,6 @@ public class RepoCommitsView extends BaseFragment<RepoCommitsMvp.View, RepoCommi
|
||||
super.showMessage(titleRes, msgRes);
|
||||
}
|
||||
|
||||
private void showReload() {
|
||||
hideBranchesProgress();
|
||||
hideProgress();
|
||||
stateLayout.showReload(adapter.getItemCount());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") @NonNull @Override public OnLoadMore getLoadMore() {
|
||||
if (onLoadMore == null) {
|
||||
onLoadMore = new OnLoadMore(getPresenter());
|
||||
@ -170,6 +170,12 @@ public class RepoCommitsView extends BaseFragment<RepoCommitsMvp.View, RepoCommi
|
||||
branchesProgress.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override public void onShowCommitCount(long sum) {
|
||||
if (tabsBadgeListener != null) {
|
||||
tabsBadgeListener.onSetBadge(2, (int) sum);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onRefresh() {
|
||||
getPresenter().onCallApi(1, null);
|
||||
}
|
||||
@ -177,4 +183,10 @@ public class RepoCommitsView extends BaseFragment<RepoCommitsMvp.View, RepoCommi
|
||||
@Override public void onClick(View view) {
|
||||
onRefresh();
|
||||
}
|
||||
|
||||
private void showReload() {
|
||||
hideBranchesProgress();
|
||||
hideProgress();
|
||||
stateLayout.showReload(adapter.getItemCount());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user