forked from sk22/megalodon
-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(crash-status-display-item): makes the app not crash when creatin…
…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
1 parent
44e3e5f
commit a082a3d
Showing
2 changed files
with
235 additions
and
179 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ErrorStatusDisplayItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.