fix(ErrorStatusDisplayItem): disable button in onBind

Fixes a NullPointerException, where the `item` was null in the
constructor, ironically causing the ErrorStatusDisplayItem to
crash immediately.
This commit is contained in:
FineFindus 2024-07-06 13:35:59 +02:00
parent 0788b03828
commit 94ce329f49
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
1 changed files with 5 additions and 3 deletions

View File

@ -30,17 +30,19 @@ public class ErrorStatusDisplayItem extends StatusDisplayItem{
}
public static class Holder extends StatusDisplayItem.Holder<ErrorStatusDisplayItem> {
private final Button openInBrowserButton;
public Holder(Context context, ViewGroup parent) {
super(context, R.layout.display_item_error, parent);
Button openInBrowserButton=findViewById(R.id.button_open_browser);
openInBrowserButton.setEnabled(item.status.url!=null);
openInBrowserButton=findViewById(R.id.button_open_browser);
openInBrowserButton.setOnClickListener(v -> UiUtils.launchWebBrowser(v.getContext(), item.status.url));
findViewById(R.id.button_copy_error_details).setOnClickListener(this::copyErrorDetails);
}
@Override
public void onBind(ErrorStatusDisplayItem item) {}
public void onBind(ErrorStatusDisplayItem item) {
openInBrowserButton.setEnabled(item.status!=null && item.status.url!=null);
}
private void copyErrorDetails(View v) {
StringWriter stringWriter=new StringWriter();