Fix Crash on closed PRs with deleted Fork (#559)

Fix edge-case DeletedFork of a Pull-Branch

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-by: M M Arif <mmarif@noreply.codeberg.org>
This commit is contained in:
6543 2020-06-26 17:09:18 +02:00 committed by M M Arif
parent 2483968f11
commit f285d47a0b
2 changed files with 10 additions and 2 deletions

View File

@ -190,9 +190,16 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
prMergeable.setText(String.valueOf(prModel.isMergeable())); prMergeable.setText(String.valueOf(prModel.isMergeable()));
if(prModel.getHead() != null) { if(prModel.getHead() != null) {
prHeadBranch.setText(prModel.getHead().getRef()); prHeadBranch.setText(prModel.getHead().getRef());
if(prModel.getHead().getRepo() != null) {
prIsFork.setText(String.valueOf(prModel.getHead().getRepo().isFork())); prIsFork.setText(String.valueOf(prModel.getHead().getRepo().isFork()));
prForkFullName.setText(prModel.getHead().getRepo().getFull_name()); prForkFullName.setText(prModel.getHead().getRepo().getFull_name());
} }
else {
// pull was done from a deleted fork
prIsFork.setText("true");
prForkFullName.setText(context.getString(R.string.prDeletedFrok));
}
}
prCommentsCount.setText(String.valueOf(prModel.getComments())); prCommentsCount.setText(String.valueOf(prModel.getComments()));
prCreatedTime.setText(TimeHelper.formatTime(prModel.getCreated_at(), new Locale(locale), timeFormat, context)); prCreatedTime.setText(TimeHelper.formatTime(prModel.getCreated_at(), new Locale(locale), timeFormat, context));

View File

@ -587,6 +587,7 @@
<string name="unauthorizedApiError">Instance has returned an error - Unauthorized. Check your credentials and try again</string> <string name="unauthorizedApiError">Instance has returned an error - Unauthorized. Check your credentials and try again</string>
<string name="loginTokenError">Please enter the correct token</string> <string name="loginTokenError">Please enter the correct token</string>
<string name="prDeletedFrok">Deleted Fork</string>
<string name="noDataPullRequests">No pull requests found</string> <string name="noDataPullRequests">No pull requests found</string>
<string name="prCreator">Creator :\u0020</string> <string name="prCreator">Creator :\u0020</string>
<string name="editPrText">Edit Pull Request</string> <string name="editPrText">Edit Pull Request</string>