Search in sources :

Example 1 with CommentRequestModel

use of com.fastaccess.data.dao.CommentRequestModel in project FastHub by k0shk0sh.

the class PullRequestFilesFragment method onCommentAdded.

@Override
public void onCommentAdded(@NonNull String comment, @NonNull CommitLinesModel item, Bundle bundle) {
    if (bundle != null) {
        String path = bundle.getString(BundleConstant.ITEM);
        if (path == null)
            return;
        CommentRequestModel commentRequestModel = new CommentRequestModel();
        commentRequestModel.setBody(comment);
        commentRequestModel.setPath(path);
        commentRequestModel.setPosition(item.getPosition());
        if (viewCallback != null)
            viewCallback.onAddComment(commentRequestModel);
        int groupPosition = bundle.getInt(BundleConstant.EXTRA_TWO);
        int childPosition = bundle.getInt(BundleConstant.EXTRA_THREE);
        CommitFileChanges commitFileChanges = adapter.getItem(groupPosition);
        List<CommitLinesModel> models = commitFileChanges.getLinesModel();
        if (models != null && !models.isEmpty()) {
            CommitLinesModel current = models.get(childPosition);
            if (current != null) {
                current.setHasCommentedOn(true);
            }
            models.set(childPosition, current);
            adapter.notifyItemChanged(groupPosition);
        }
    }
}
Also used : CommentRequestModel(com.fastaccess.data.dao.CommentRequestModel) CommitLinesModel(com.fastaccess.data.dao.CommitLinesModel) CommitFileChanges(com.fastaccess.data.dao.CommitFileChanges)

Example 2 with CommentRequestModel

use of com.fastaccess.data.dao.CommentRequestModel in project FastHub by k0shk0sh.

the class PullRequestTimelinePresenter method onHandleComment.

@Override
public void onHandleComment(@NonNull String text, @Nullable Bundle bundle) {
    if (getView() == null)
        return;
    PullRequest pullRequest = getView().getPullRequest();
    if (pullRequest != null) {
        if (bundle == null) {
            CommentRequestModel commentRequestModel = new CommentRequestModel();
            commentRequestModel.setBody(text);
            manageDisposable(RxHelper.getObservable(RestProvider.getIssueService(isEnterprise()).createIssueComment(pullRequest.getLogin(), pullRequest.getRepoId(), pullRequest.getNumber(), commentRequestModel)).doOnSubscribe(disposable -> sendToView(view -> view.showBlockingProgress(0))).subscribe(comment -> sendToView(view -> view.addComment(TimelineModel.constructComment(comment))), throwable -> {
                onError(throwable);
                sendToView(PullRequestTimelineMvp.View::onHideBlockingProgress);
            }));
        }
    }
}
Also used : PullRequestStatusModel(com.fastaccess.data.dao.PullRequestStatusModel) Comment(com.fastaccess.data.dao.model.Comment) GenericEvent(com.fastaccess.data.dao.timeline.GenericEvent) Bundle(android.os.Bundle) SourceModel(com.fastaccess.data.dao.timeline.SourceModel) ActivityHelper(com.fastaccess.helper.ActivityHelper) TimelineModel(com.fastaccess.data.dao.TimelineModel) CommentsHelper(com.fastaccess.provider.timeline.CommentsHelper) Uri(android.net.Uri) InputHelper(com.fastaccess.helper.InputHelper) NonNull(android.support.annotation.NonNull) CreateIssueActivity(com.fastaccess.ui.modules.repos.issues.create.CreateIssueActivity) SchemeParser(com.fastaccess.provider.scheme.SchemeParser) ArrayList(java.util.ArrayList) RxHelper(com.fastaccess.helper.RxHelper) PopupMenu(android.widget.PopupMenu) EditReviewCommentModel(com.fastaccess.data.dao.EditReviewCommentModel) View(android.view.View) Observable(io.reactivex.Observable) ReactionTypes(com.fastaccess.data.dao.types.ReactionTypes) BasePresenter(com.fastaccess.ui.base.mvp.presenter.BasePresenter) BundleConstant(com.fastaccess.helper.BundleConstant) CommentRequestModel(com.fastaccess.data.dao.CommentRequestModel) Login(com.fastaccess.data.dao.model.Login) RestProvider(com.fastaccess.provider.rest.RestProvider) GroupedReviewModel(com.fastaccess.data.dao.GroupedReviewModel) BaseMvp(com.fastaccess.ui.base.mvp.BaseMvp) ReactionsProvider(com.fastaccess.provider.timeline.ReactionsProvider) SparseArray(android.util.SparseArray) List(java.util.List) PullRequest(com.fastaccess.data.dao.model.PullRequest) IssueEventType(com.fastaccess.data.dao.types.IssueEventType) R(com.fastaccess.R) FilterIssuesActivity(com.fastaccess.ui.modules.filter.issues.FilterIssuesActivity) ReviewCommentModel(com.fastaccess.data.dao.ReviewCommentModel) TimelineConverter(com.fastaccess.provider.timeline.TimelineConverter) Nullable(android.support.annotation.Nullable) Activity(android.app.Activity) Collections(java.util.Collections) CommentRequestModel(com.fastaccess.data.dao.CommentRequestModel) PullRequest(com.fastaccess.data.dao.model.PullRequest)

Example 3 with CommentRequestModel

use of com.fastaccess.data.dao.CommentRequestModel in project FastHub by k0shk0sh.

the class IssuePopupPresenter method onSubmit.

@Override
public void onSubmit(@NonNull String login, @NonNull String repoId, int issueNumber, @NonNull String text) {
    CommentRequestModel requestModel = new CommentRequestModel();
    requestModel.setBody(text);
    makeRestCall(RestProvider.getIssueService(isEnterprise()).createIssueComment(login, repoId, issueNumber, requestModel), comment -> sendToView(IssuePopupMvp.View::onSuccessfullySubmitted));
}
Also used : CommentRequestModel(com.fastaccess.data.dao.CommentRequestModel)

Example 4 with CommentRequestModel

use of com.fastaccess.data.dao.CommentRequestModel in project FastHub by k0shk0sh.

the class CommitCommentsPresenter method onHandleComment.

@Override
public void onHandleComment(@NonNull String text, @Nullable Bundle bundle) {
    CommentRequestModel model = new CommentRequestModel();
    model.setBody(text);
    manageDisposable(RxHelper.getObservable(RestProvider.getRepoService(isEnterprise()).postCommitComment(login, repoId, sha, model)).doOnSubscribe(disposable -> sendToView(view -> view.showBlockingProgress(0))).subscribe(comment -> sendToView(view -> view.addComment(comment)), throwable -> {
        onError(throwable);
        sendToView(CommitCommentsMvp.View::hideBlockingProgress);
    }));
}
Also used : Comment(com.fastaccess.data.dao.model.Comment) BundleConstant(com.fastaccess.helper.BundleConstant) CommentRequestModel(com.fastaccess.data.dao.CommentRequestModel) Bundle(android.os.Bundle) Login(com.fastaccess.data.dao.model.Login) RestProvider(com.fastaccess.provider.rest.RestProvider) ActivityHelper(com.fastaccess.helper.ActivityHelper) TimelineModel(com.fastaccess.data.dao.TimelineModel) CommentsHelper(com.fastaccess.provider.timeline.CommentsHelper) ReactionsProvider(com.fastaccess.provider.timeline.ReactionsProvider) NonNull(android.support.annotation.NonNull) ArrayList(java.util.ArrayList) RxHelper(com.fastaccess.helper.RxHelper) R(com.fastaccess.R) PopupMenu(android.widget.PopupMenu) View(android.view.View) Observable(io.reactivex.Observable) ReactionTypes(com.fastaccess.data.dao.types.ReactionTypes) Nullable(android.support.annotation.Nullable) BasePresenter(com.fastaccess.ui.base.mvp.presenter.BasePresenter) CommentRequestModel(com.fastaccess.data.dao.CommentRequestModel)

Example 5 with CommentRequestModel

use of com.fastaccess.data.dao.CommentRequestModel in project FastHub by k0shk0sh.

the class CommitFilesPresenter method onSubmitComment.

@Override
public void onSubmitComment(@NonNull String comment, @NonNull CommitLinesModel item, @Nullable Bundle bundle) {
    if (bundle != null) {
        String blob = bundle.getString(BundleConstant.ITEM);
        String path = bundle.getString(BundleConstant.EXTRA);
        if (path == null || sha == null)
            return;
        CommentRequestModel commentRequestModel = new CommentRequestModel();
        commentRequestModel.setBody(comment);
        commentRequestModel.setPath(path);
        commentRequestModel.setPosition(item.getPosition());
        commentRequestModel.setLine(item.getRightLineNo() > 0 ? item.getRightLineNo() : item.getLeftLineNo());
        NameParser nameParser = new NameParser(blob);
        onSubmit(nameParser.getUsername(), nameParser.getName(), commentRequestModel);
    }
}
Also used : CommentRequestModel(com.fastaccess.data.dao.CommentRequestModel) NameParser(com.fastaccess.data.dao.NameParser)

Aggregations

CommentRequestModel (com.fastaccess.data.dao.CommentRequestModel)7 Bundle (android.os.Bundle)4 NonNull (android.support.annotation.NonNull)4 Nullable (android.support.annotation.Nullable)4 View (android.view.View)4 PopupMenu (android.widget.PopupMenu)4 R (com.fastaccess.R)4 Comment (com.fastaccess.data.dao.model.Comment)4 Login (com.fastaccess.data.dao.model.Login)4 BundleConstant (com.fastaccess.helper.BundleConstant)4 RxHelper (com.fastaccess.helper.RxHelper)4 RestProvider (com.fastaccess.provider.rest.RestProvider)4 BasePresenter (com.fastaccess.ui.base.mvp.presenter.BasePresenter)4 ArrayList (java.util.ArrayList)4 TimelineModel (com.fastaccess.data.dao.TimelineModel)3 ReactionTypes (com.fastaccess.data.dao.types.ReactionTypes)3 ActivityHelper (com.fastaccess.helper.ActivityHelper)3 CommentsHelper (com.fastaccess.provider.timeline.CommentsHelper)3 ReactionsProvider (com.fastaccess.provider.timeline.ReactionsProvider)3 BaseMvp (com.fastaccess.ui.base.mvp.BaseMvp)3