use of com.fastaccess.data.dao.model.Comment 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);
}));
}
use of com.fastaccess.data.dao.model.Comment in project FastHub by k0shk0sh.
the class GistCommentsFragment method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (requestCode == BundleConstant.REQUEST_CODE) {
if (data == null) {
onRefresh();
return;
}
Bundle bundle = data.getExtras();
if (bundle != null) {
boolean isNew = bundle.getBoolean(BundleConstant.EXTRA);
Comment commentsModel = bundle.getParcelable(BundleConstant.ITEM);
if (commentsModel == null)
return;
if (isNew) {
adapter.addItem(commentsModel);
recycler.smoothScrollToPosition(adapter.getItemCount());
} else {
int position = adapter.getItem(commentsModel);
if (position != -1) {
adapter.swapItem(commentsModel, position);
recycler.smoothScrollToPosition(position);
} else {
adapter.addItem(commentsModel);
recycler.smoothScrollToPosition(adapter.getItemCount());
}
}
}
}
}
}
use of com.fastaccess.data.dao.model.Comment in project FastHub by k0shk0sh.
the class GistCommentsPresenter method onHandleComment.
@Override
public void onHandleComment(@NonNull String text, @Nullable Bundle bundle, String gistId) {
CommentRequestModel model = new CommentRequestModel();
model.setBody(text);
manageDisposable(RxHelper.getObservable(RestProvider.getGistService(isEnterprise()).createGistComment(gistId, model)).doOnSubscribe(disposable -> sendToView(view -> view.showBlockingProgress(0))).subscribe(comment -> sendToView(view -> view.onAddNewComment(comment)), throwable -> {
onError(throwable);
sendToView(GistCommentsMvp.View::hideBlockingProgress);
}));
}
use of com.fastaccess.data.dao.model.Comment in project FastHub by k0shk0sh.
the class GistCommentsPresenter method onHandleDeletion.
@Override
public void onHandleDeletion(@Nullable Bundle bundle) {
if (bundle != null) {
long commId = bundle.getLong(BundleConstant.EXTRA, 0);
String gistId = bundle.getString(BundleConstant.ID);
if (commId != 0 && gistId != null) {
makeRestCall(RestProvider.getGistService(isEnterprise()).deleteGistComment(gistId, commId), booleanResponse -> sendToView(view -> {
if (booleanResponse.code() == 204) {
Comment comment = new Comment();
comment.setId(commId);
view.onRemove(comment);
} else {
view.showMessage(R.string.error, R.string.error_deleting_comment);
}
}));
}
}
}
use of com.fastaccess.data.dao.model.Comment in project FastHub by k0shk0sh.
the class IssueTimelineFragment method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (requestCode == BundleConstant.REQUEST_CODE) {
if (data == null) {
onRefresh();
return;
}
Bundle bundle = data.getExtras();
if (bundle != null) {
boolean isNew = bundle.getBoolean(BundleConstant.EXTRA);
Comment commentsModel = bundle.getParcelable(BundleConstant.ITEM);
if (commentsModel == null) {
// shit happens, refresh()?
onRefresh();
return;
}
adapter.notifyDataSetChanged();
if (isNew) {
adapter.addItem(TimelineModel.constructComment(commentsModel));
recycler.smoothScrollToPosition(adapter.getItemCount());
} else {
int position = adapter.getItem(TimelineModel.constructComment(commentsModel));
if (position != -1) {
adapter.swapItem(TimelineModel.constructComment(commentsModel), position);
recycler.smoothScrollToPosition(position);
} else {
adapter.addItem(TimelineModel.constructComment(commentsModel));
recycler.smoothScrollToPosition(adapter.getItemCount());
}
}
} else {
// bundle size is too large? refresh the api
onRefresh();
}
}
}
}
Aggregations