this commit fixes #755

This commit is contained in:
k0shk0sh 2017-09-02 16:38:44 +02:00
parent 220ae1edce
commit 7b58388d08
5 changed files with 72 additions and 40 deletions

View File

@ -35,6 +35,7 @@ import static com.fastaccess.ui.widgets.DiffLineSpan.HUNK_TITLE;
public int rightLineNo;
public boolean noNewLine;
public int position;
private boolean hasCommentedOn;
@NonNull public static List<CommitLinesModel> getLines(@Nullable String text) {
ArrayList<CommitLinesModel> models = new ArrayList<>();
@ -82,7 +83,7 @@ import static com.fastaccess.ui.widgets.DiffLineSpan.HUNK_TITLE;
token = token.replace("\\ No newline at end of file", "");
}
models.add(new CommitLinesModel(token, color, token.startsWith("@@") || !addLeft ? -1 : leftLineNo,
token.startsWith("@@") || !addRight ? -1 : rightLineNo, index != -1, position));
token.startsWith("@@") || !addRight ? -1 : rightLineNo, index != -1, position, false));
}
}
}

View File

@ -26,6 +26,7 @@ public class CommitLinesViewHolder extends BaseViewHolder<CommitLinesModel> {
@BindView(R.id.textView) AppCompatTextView textView;
@BindView(R.id.leftLinNo) AppCompatTextView leftLinNo;
@BindView(R.id.rightLinNo) AppCompatTextView rightLinNo;
@BindView(R.id.hasComment) View hasComment;
private final int patchAdditionColor;
private final int patchDeletionColor;
private final int patchRefColor;
@ -44,6 +45,7 @@ public class CommitLinesViewHolder extends BaseViewHolder<CommitLinesModel> {
@Override public void bind(@NonNull CommitLinesModel item) {
leftLinNo.setText(item.getLeftLineNo() > 0 ? String.valueOf(item.getLeftLineNo()) : " ");
rightLinNo.setText(item.getRightLineNo() > 0 ? String.valueOf(item.getRightLineNo()) : " ");
hasComment.setVisibility(item.isHasCommentedOn() ? View.VISIBLE : View.GONE);
switch (item.getColor()) {
case CommitLinesModel.ADDITION:
textView.setBackgroundColor(patchAdditionColor);

View File

@ -45,6 +45,7 @@ import com.fastaccess.ui.modules.repos.extras.assignees.AssigneesDialogFragment;
import com.fastaccess.ui.modules.repos.extras.labels.LabelsDialogFragment;
import com.fastaccess.ui.modules.repos.extras.milestone.create.MilestoneDialogFragment;
import com.fastaccess.ui.modules.repos.issues.create.CreateIssueActivity;
import com.fastaccess.ui.modules.repos.pull_requests.pull_request.details.files.PullRequestFilesFragment;
import com.fastaccess.ui.modules.repos.pull_requests.pull_request.details.timeline.timeline.PullRequestTimelineFragment;
import com.fastaccess.ui.modules.repos.pull_requests.pull_request.merge.MergePullRequestDialogFragment;
import com.fastaccess.ui.modules.reviews.changes.ReviewChangesActivity;
@ -111,7 +112,6 @@ public class PullRequestPagerActivity extends BaseActivity<PullRequestPagerMvp.V
.show(getSupportFragmentManager(), MessageDialogView.TAG);
}
@OnClick(R.id.submitReviews) void onSubmitReviews(View view) {
addPrReview(view);
}
@ -445,9 +445,14 @@ public class PullRequestPagerActivity extends BaseActivity<PullRequestPagerMvp.V
}
protected void hideAndClearReviews() {
onUpdateTimeline();
getPresenter().getCommitComment().clear();
AnimHelper.mimicFabVisibility(false, prReviewHolder, null);
if (pager == null || pager.getAdapter() == null) return;
PullRequestFilesFragment fragment = (PullRequestFilesFragment) pager.getAdapter().instantiateItem(pager, 2);
if (fragment != null) {
fragment.onRefresh();
}
}
private void addPrReview(@NonNull View view) {

View File

@ -215,13 +215,20 @@ public class PullRequestFilesFragment extends BaseFragment<PullRequestFilesMvp.V
CommentRequestModel commentRequestModel = new CommentRequestModel();
commentRequestModel.setBody(comment);
commentRequestModel.setPath(path);
if (item.getRightLineNo() > 0 && item.getLeftLineNo() > 0) {
commentRequestModel.setPosition(item.getPosition());
} else {
commentRequestModel.setPosition(item.getPosition());
// commentRequestModel.setLine(item.getRightLineNo() > 0 ? item.getRightLineNo() : item.getLeftLineNo());
}
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);
}
}
}

View File

@ -5,40 +5,57 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:orientation="vertical"
android:paddingBottom="@dimen/spacing_micro"
android:paddingTop="@dimen/spacing_micro">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/leftLinNo"
style="@style/TextAppearance.AppCompat.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:fontFamily="monospace"
android:text="?android:textColorSecondary"
tools:text="1"/>
<View
android:layout_width="@dimen/spacing_normal"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/rightLinNo"
style="@style/TextAppearance.AppCompat.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:fontFamily="monospace"
android:text="?android:textColorSecondary"
tools:text="1"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/textView"
style="@style/TextAppearance.AppCompat.Caption"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_micro"
android:fontFamily="monospace"
android:textColor="?android:textColorPrimary"
tools:text="Per guest prepare a handfull teaspoons of soy sauce with squeezed sausages for dessert."/>
android:orientation="horizontal">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/leftLinNo"
style="@style/TextAppearance.AppCompat.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:fontFamily="monospace"
android:text="?android:textColorSecondary"
tools:text="1"/>
<View
android:layout_width="@dimen/spacing_normal"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/rightLinNo"
style="@style/TextAppearance.AppCompat.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:fontFamily="monospace"
android:text="?android:textColorSecondary"
tools:text="1"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/textView"
style="@style/TextAppearance.AppCompat.Caption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_micro"
android:fontFamily="monospace"
android:textColor="?android:textColorPrimary"
tools:text="Per guest prepare a handfull teaspoons of soy sauce with squeezed sausages for dessert."/>
</LinearLayout>
<View
android:id="@+id/hasComment"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginBottom="@dimen/spacing_micro"
android:layout_marginTop="@dimen/spacing_micro"
android:background="?colorAccent"
android:visibility="gone"/>
</LinearLayout>