From f75fad2bea685009519bbfdb80f93ce44ed4b0d2 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Thu, 16 Jun 2022 00:11:56 +0200 Subject: [PATCH] Fix bugs (#1154) - fix some bugs (see discord) Closes https://codeberg.org/gitnex/GitNex/issues/1153 Co-authored-by: qwerty287 Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1154 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 Co-committed-by: qwerty287 --- .../org/mian/gitnex/actions/IssueActions.java | 6 +++++- .../fragments/CommitDetailFragment.java | 5 ++++- .../gitnex/fragments/RepoInfoFragment.java | 20 ++++++++++++------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/actions/IssueActions.java b/app/src/main/java/org/mian/gitnex/actions/IssueActions.java index b9ce83fe..9590fba0 100644 --- a/app/src/main/java/org/mian/gitnex/actions/IssueActions.java +++ b/app/src/main/java/org/mian/gitnex/actions/IssueActions.java @@ -1,5 +1,6 @@ package org.mian.gitnex.actions; +import android.app.Activity; import android.content.Context; import androidx.annotation.NonNull; import org.gitnex.tea4j.v2.models.Comment; @@ -112,7 +113,10 @@ public class IssueActions { IssueDetailActivity.singleIssueUpdate = true; ((IssueDetailActivity) ctx).onResume(); - RepoDetailActivity.updateRepo = true; + if(((Activity) ctx).getIntent().getStringExtra("openedFromLink") == null || + !((Activity) ctx).getIntent().getStringExtra("openedFromLink").equals("true")) { + RepoDetailActivity.updateRepo = true; + } } } else if(response.code() == 401) { diff --git a/app/src/main/java/org/mian/gitnex/fragments/CommitDetailFragment.java b/app/src/main/java/org/mian/gitnex/fragments/CommitDetailFragment.java index 7cd33d7b..1282a785 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/CommitDetailFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/CommitDetailFragment.java @@ -146,8 +146,11 @@ public class CommitDetailFragment extends Fragment { // we need a ClickListener here to prevent that the ItemClickListener of the diffFiles ListView handles clicks for the header }); CommitDetailFragment.this.binding.diffFiles.addHeaderView(binding.getRoot()); - assert response.body() != null; Commit commitsModel = response.body(); + if(commitsModel == null) { + onFailure(call, new Throwable()); + return; + } String[] commitMessageParts = commitsModel.getCommit().getMessage().split("(\r\n|\n)", 2); if(commitMessageParts.length > 1 && !commitMessageParts[1].trim().isEmpty()) { diff --git a/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java b/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java index 687f428b..3d0ee1e2 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java @@ -263,13 +263,19 @@ public class RepoInfoFragment extends Fragment { switch(response.code()) { case 200: - try { - assert response.body() != null; - Markdown.render(ctx, response.body().string(), binding.repoFileContents, repository); - } - catch(IOException e) { - e.printStackTrace(); - } + assert response.body() != null; + new Thread(() -> { + try { + Markdown.render(ctx, response.body().string(), binding.repoFileContents, repository); + } + catch(IOException e) { + requireActivity().runOnUiThread(() -> { + Toasty.error(ctx, ctx.getString(R.string.genericError)); + binding.fileContentsFrameHeader.setVisibility(View.GONE); + binding.fileContentsFrame.setVisibility(View.GONE); + }); + } + }).start(); break; case 401: