Skip to content
26 changes: 14 additions & 12 deletions app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,26 @@ class ErrorActivity : AppCompatActivity() {

// Collapse all logs to a single paragraph when there are more than one
// to keep the GitHub issue clean.
if (errorInfo.stackTraces.isNotEmpty()) {
if (errorInfo.stackTraces.size > 1) {
append("<details><summary><b>Exceptions (")
append(errorInfo.stackTraces.size)
append(")</b></summary><p>\n")
}

// add the logs
errorInfo.stackTraces.forEachIndexed { index, stacktrace ->
append("<details><summary><b>Crash log ")
if (errorInfo.stackTraces.isNotEmpty()) {
append(index + 1)
}
append("</b>")
append("</summary><p>\n")
append("\n```\n${stacktrace}\n```\n")
append("</details>\n")
// add the logs
errorInfo.stackTraces.forEachIndexed { index, stacktrace ->
append("<details><summary><b>Crash log ")
if (errorInfo.stackTraces.size > 1) {
append(index + 1)
}
append("</b>")
append("</summary><p>\n")
append("\n```\n${stacktrace}\n```\n")
append("</details>\n")
}

// make sure to close everything
// make sure to close everything
if (errorInfo.stackTraces.size > 1) {
append("</p></details>\n")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,12 @@ protected void initViews(final View rootView, final Bundle savedInstanceState) {
protected void initListeners() {
super.initListeners();

// Workaround for #5600
// Forcefully catch click events uncaught by children because otherwise
// they will be caught by underlying view and "click through" will happen
binding.getRoot().setOnClickListener(v -> { });
binding.getRoot().setOnLongClickListener(v -> true);

setOnClickListeners();
setOnLongClickListeners();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,11 @@ public void handleSuggestions(@NonNull final List<SuggestionItem> suggestions) {
Log.d(TAG, "handleSuggestions() called with: suggestions = [" + suggestions + "]");
}
suggestionListAdapter.submitList(suggestions,
() -> searchBinding.suggestionsList.scrollToPosition(0));
() -> {
if (searchBinding != null) {
searchBinding.suggestionsList.scrollToPosition(0);
}
});

if (suggestionsPanelVisible && isErrorPanelVisible()) {
hideLoading();
Expand Down
36 changes: 36 additions & 0 deletions app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,49 @@ public static void openCommentAuthorIfPresent(@NonNull final FragmentActivity ac

public static void openCommentRepliesFragment(@NonNull final FragmentActivity activity,
@NonNull final CommentsInfoItem comment) {
closeCommentRepliesFragments(activity);
defaultTransaction(activity.getSupportFragmentManager())
.replace(R.id.fragment_holder, new CommentRepliesFragment(comment),
CommentRepliesFragment.TAG)
.addToBackStack(CommentRepliesFragment.TAG)
.commit();
}

/**
* Closes all open {@link CommentRepliesFragment}s in {@code activity},
* including those that are not at the top of the back stack.
* This is needed to prevent multiple open CommentRepliesFragments
* Ideally there should only be one since we remove existing before opening a new one.
* @param activity the activity in which to close the CommentRepliesFragments
*/
public static void closeCommentRepliesFragments(@NonNull final FragmentActivity activity) {
final FragmentManager fm = activity.getSupportFragmentManager();

// Remove all existing fragment instances tagged as CommentRepliesFragment
final FragmentTransaction tx = defaultTransaction(fm);
boolean removed = false;
for (final Fragment fragment : fm.getFragments()) {
if (fragment != null && CommentRepliesFragment.TAG.equals(fragment.getTag())) {
tx.remove(fragment);
removed = true;
}
}
if (removed) {
tx.commit();
}

// Only pop back stack entries named CommentRepliesFragment.TAG if they are at the top.
while (fm.getBackStackEntryCount() > 0
&& CommentRepliesFragment.TAG.equals(
fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName()
)
) {
fm.popBackStackImmediate(CommentRepliesFragment.TAG,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
}

}

public static void openPlaylistFragment(final FragmentManager fragmentManager,
final int serviceId, final String url,
@NonNull final String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ int process(SharpStream out, SharpStream... sources) throws IOException {

try {
writer.build(sources[0]);
} catch (IOException err) {
Log.e(TAG, "subtitle conversion failed due to I/O error", err);
throw err;
} catch (Exception err) {
Log.e(TAG, "subtitle parse failed", err);
return err instanceof IOException ? 1 : 8;
Log.e(TAG, "subtitle conversion failed", err);
throw new IOException("TTML to SRT conversion failed", err);
}

return OK_RESULT;
Expand Down
Loading