fix(ErrorStatusDisplayItem): disable open in browser button on null URL

Disables the Open in Browser, if the URL is null, as otherwise the app
would crash when trying to open the null URL.
This commit is contained in:
FineFindus 2024-06-13 21:25:14 +02:00
parent 6ad8a85044
commit f9f8c4a9ef
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
1 changed files with 4 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import org.joinmastodon.android.BuildConfig;
import org.joinmastodon.android.R;
@ -32,7 +33,9 @@ public class ErrorStatusDisplayItem extends StatusDisplayItem{
public Holder(Context context, ViewGroup parent) {
super(context, R.layout.display_item_error, parent);
findViewById(R.id.button_open_browser).setOnClickListener(v -> UiUtils.launchWebBrowser(v.getContext(), item.status.url));
Button openInBrowserButton=findViewById(R.id.button_open_browser);
openInBrowserButton.setEnabled(item.status.url!=null);
openInBrowserButton.setOnClickListener(v -> UiUtils.launchWebBrowser(v.getContext(), item.status.url));
findViewById(R.id.button_copy_error_details).setOnClickListener(this::copyErrorDetails);
}