mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2026-01-25 14:47:05 +00:00
fixed PR reviews & commit comments on line
where index should be used instead of line number :o
This commit is contained in:
parent
1940a8c91e
commit
fa2a025e52
@ -6,7 +6,6 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.fastaccess.helper.InputHelper;
|
||||
import com.fastaccess.helper.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -35,24 +34,7 @@ import static com.fastaccess.ui.widgets.DiffLineSpan.HUNK_TITLE;
|
||||
public int leftLineNo;
|
||||
public int rightLineNo;
|
||||
public boolean noNewLine;
|
||||
|
||||
@Override public int describeContents() { return 0; }
|
||||
|
||||
@Override public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(this.text);
|
||||
dest.writeInt(this.color);
|
||||
}
|
||||
|
||||
protected CommitLinesModel(Parcel in) {
|
||||
this.text = in.readString();
|
||||
this.color = in.readInt();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<CommitLinesModel> CREATOR = new Parcelable.Creator<CommitLinesModel>() {
|
||||
@Override public CommitLinesModel createFromParcel(Parcel source) {return new CommitLinesModel(source);}
|
||||
|
||||
@Override public CommitLinesModel[] newArray(int size) {return new CommitLinesModel[size];}
|
||||
};
|
||||
public int position;
|
||||
|
||||
@NonNull public static List<CommitLinesModel> getLines(@Nullable String text) {
|
||||
ArrayList<CommitLinesModel> models = new ArrayList<>();
|
||||
@ -61,11 +43,13 @@ import static com.fastaccess.ui.widgets.DiffLineSpan.HUNK_TITLE;
|
||||
if (split.length > 1) {
|
||||
int leftLineNo = -1;
|
||||
int rightLineNo = -1;
|
||||
int position = 0;
|
||||
for (String token : split) {
|
||||
char firstChar = token.charAt(0);
|
||||
boolean addLeft = false;
|
||||
boolean addRight = false;
|
||||
int color = TRANSPARENT;
|
||||
position++;
|
||||
if (token.startsWith("@@")) {
|
||||
color = PATCH;
|
||||
Matcher matcher = HUNK_TITLE.matcher(token.trim());
|
||||
@ -96,10 +80,36 @@ 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));
|
||||
token.startsWith("@@") || !addRight ? -1 : rightLineNo, index != -1, position));
|
||||
}
|
||||
}
|
||||
}
|
||||
return models;
|
||||
}
|
||||
|
||||
@Override public int describeContents() { return 0; }
|
||||
|
||||
@Override public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(this.text);
|
||||
dest.writeInt(this.color);
|
||||
dest.writeInt(this.leftLineNo);
|
||||
dest.writeInt(this.rightLineNo);
|
||||
dest.writeByte(this.noNewLine ? (byte) 1 : (byte) 0);
|
||||
dest.writeInt(this.position);
|
||||
}
|
||||
|
||||
protected CommitLinesModel(Parcel in) {
|
||||
this.text = in.readString();
|
||||
this.color = in.readInt();
|
||||
this.leftLineNo = in.readInt();
|
||||
this.rightLineNo = in.readInt();
|
||||
this.noNewLine = in.readByte() != 0;
|
||||
this.position = in.readInt();
|
||||
}
|
||||
|
||||
public static final Creator<CommitLinesModel> CREATOR = new Creator<CommitLinesModel>() {
|
||||
@Override public CommitLinesModel createFromParcel(Parcel source) {return new CommitLinesModel(source);}
|
||||
|
||||
@Override public CommitLinesModel[] newArray(int size) {return new CommitLinesModel[size];}
|
||||
};
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ class MainNavDrawer(val view: BaseActivity<*, *>, val extraNav: NavigationView?,
|
||||
TransitionManager.beginDelayedTransition(menusHolder ?: extraNav!!)
|
||||
val isVisible = recyclerView.visibility == View.VISIBLE
|
||||
recyclerView.visibility = if (isVisible) View.GONE else View.VISIBLE
|
||||
toggleImage.rotation = if (!isVisible) 180f else 0f
|
||||
toggleImage.rotation = if (recyclerView.visibility == View.VISIBLE) 180f else 0f
|
||||
}
|
||||
val adapter = LoginAdapter(true)
|
||||
view.getPresenter().manageViewDisposable(Login.getAccounts()
|
||||
@ -89,12 +89,13 @@ class MainNavDrawer(val view: BaseActivity<*, *>, val extraNav: NavigationView?,
|
||||
val togglePinned = view.findViewById<View>(R.id.togglePinned)
|
||||
val pinnedList = view.findViewById<DynamicRecyclerView>(R.id.pinnedList)
|
||||
val pinnedListAdapter = PinnedReposAdapter(true)
|
||||
togglePinnedImage.rotation = if (pinnedList.visibility == View.VISIBLE) 180f else 0f
|
||||
|
||||
togglePinned.setOnClickListener {
|
||||
TransitionManager.beginDelayedTransition(menusHolder ?: extraNav!!)
|
||||
val isVisible = pinnedList.visibility == View.VISIBLE
|
||||
pinnedList.visibility = if (isVisible) View.GONE else View.VISIBLE
|
||||
togglePinnedImage.rotation = if (isVisible) 180f else 0f
|
||||
togglePinnedImage.rotation = if (pinnedList.visibility == View.VISIBLE) 180f else 0f
|
||||
}
|
||||
|
||||
view.getPresenter().manageViewDisposable(PinnedRepos.getMenuRepos()
|
||||
|
||||
@ -198,13 +198,14 @@ public class RepoPagerActivity extends BaseActivity<RepoPagerMvp.View, RepoPager
|
||||
}
|
||||
|
||||
@OnClick(R.id.tagsIcon) void onTagsClick() {
|
||||
if (topicsList.getAdapter().getItemCount() > 0)
|
||||
if (topicsList.getAdapter().getItemCount() > 0) {
|
||||
TransitionManager.beginDelayedTransition(topicsList);
|
||||
topicsList.setVisibility(topicsList.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
topicsList.setVisibility(topicsList.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick({R.id.forkRepoLayout, R.id.starRepoLayout, R.id.watchRepoLayout, R.id.pinLayout, R.id.wikiLayout, R.id.licenseLayout})
|
||||
void onClick(View view) {
|
||||
@OnClick({R.id.forkRepoLayout, R.id.starRepoLayout, R.id.watchRepoLayout,
|
||||
R.id.pinLayout, R.id.wikiLayout, R.id.licenseLayout}) void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.forkRepoLayout:
|
||||
MessageDialogView.newInstance(getString(R.string.fork), String.format("%s %s/%s?", getString(R.string.fork), login, repoId),
|
||||
|
||||
@ -100,7 +100,7 @@ class CommitFilesPresenter extends BasePresenter<CommitFilesMvp.View> implements
|
||||
CommentRequestModel commentRequestModel = new CommentRequestModel();
|
||||
commentRequestModel.setBody(comment);
|
||||
commentRequestModel.setPath(path);
|
||||
commentRequestModel.setPosition(item.getRightLineNo() > 0 ? item.getRightLineNo() : item.getLeftLineNo());
|
||||
commentRequestModel.setPosition(item.getPosition());
|
||||
NameParser nameParser = new NameParser(blob);
|
||||
makeRestCall(RestProvider.getRepoService(isEnterprise()).postCommitComment(nameParser.getUsername(),
|
||||
nameParser.getName(), sha, commentRequestModel), newComment -> sendToView(view -> view.onCommentAdded(newComment)));
|
||||
|
||||
@ -17,6 +17,7 @@ import com.fastaccess.data.dao.CommitLinesModel;
|
||||
import com.fastaccess.helper.ActivityHelper;
|
||||
import com.fastaccess.helper.BundleConstant;
|
||||
import com.fastaccess.helper.Bundler;
|
||||
import com.fastaccess.helper.Logger;
|
||||
import com.fastaccess.provider.rest.loadmore.OnLoadMore;
|
||||
import com.fastaccess.ui.adapter.CommitFilesAdapter;
|
||||
import com.fastaccess.ui.base.BaseFragment;
|
||||
@ -176,7 +177,8 @@ public class PullRequestFilesFragment extends BaseFragment<PullRequestFilesMvp.V
|
||||
CommentRequestModel commentRequestModel = new CommentRequestModel();
|
||||
commentRequestModel.setBody(comment);
|
||||
commentRequestModel.setPath(path);
|
||||
commentRequestModel.setPosition(item.getRightLineNo() > 0 ? item.getRightLineNo() : item.getLeftLineNo());
|
||||
commentRequestModel.setPosition(item.getPosition());
|
||||
Logger.e(commentRequestModel.getPosition());
|
||||
if (viewCallback != null) viewCallback.onAddComment(commentRequestModel);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user