Skip to content

Commit

Permalink
feat(crash-status-display-item): makes the app not crash when creatin…
Browse files Browse the repository at this point in the history
…g the status display items

This is the first part of a 2 part patch, because crashes can still happpen when the item is being "binded", which makes it necessary to handle those errors as well, which we currently DON'T do.

Also the Error item is still needing to be better, so there is also that to work on
  • Loading branch information
LucasGGamerM committed May 19, 2024
1 parent 44e3e5f commit a082a3d
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 179 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.joinmastodon.android.ui.displayitems;

import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.joinmastodon.android.R;
import org.joinmastodon.android.fragments.BaseStatusListFragment;
import org.joinmastodon.android.model.Attachment;
import org.joinmastodon.android.ui.utils.UiUtils;

public class ErrorStatusDisplayItem extends StatusDisplayItem{
private final Exception exception;

public ErrorStatusDisplayItem(String parentID, BaseStatusListFragment<?> parentFragment, Exception exception) {
super(parentID, parentFragment);
this.exception=exception;
}

@Override
public Type getType() {
return Type.ERROR_ITEM;
}

public static class Holder extends StatusDisplayItem.Holder<ErrorStatusDisplayItem> {
private final TextView title, domain;

public Holder(Context context, ViewGroup parent) {
super(context, R.layout.display_item_file, parent);
title=findViewById(R.id.title);
domain=findViewById(R.id.domain);
findViewById(R.id.inner).setOnClickListener(this::onClick);
}

@Override
public void onBind(ErrorStatusDisplayItem item) {
title.setText(item.exception.getMessage());
// title.setEllipsize(item.attachment.description != null ? TextUtils.TruncateAt.END : TextUtils.TruncateAt.MIDDLE);
// domain.setText(url.getHost());
}

private void onClick(View v) {
// UiUtils.openURL(itemView.getContext(), item.parentFragment.getAccountID(), getUrl());
}
}
}

Loading

0 comments on commit a082a3d

Please sign in to comment.