LinkHelper: try to fix error if account url is null

This commit is contained in:
Alibek Omarov 2020-05-03 02:48:16 +03:00
parent c674d5c4e6
commit 335f45d321
2 changed files with 10 additions and 2 deletions

View File

@ -187,7 +187,7 @@ data class Status(
data class Mention (
val id: String,
val url: String,
val url: String?, // can be null due to bug in some Pleroma versions
@SerializedName("acct") val username: String,
@SerializedName("username") val localUsername: String
)

View File

@ -43,6 +43,10 @@ import java.net.URISyntaxException;
public class LinkHelper {
public static String getDomain(String urlString) {
// sometimes URL can be null due to Pleroma bug
if(urlString == null)
return "";
URI uri;
try {
uri = new URI(urlString);
@ -94,7 +98,8 @@ public class LinkHelper {
for (Status.Mention mention : mentions) {
if (mention.getLocalUsername().equalsIgnoreCase(accountUsername)) {
id = mention.getId();
if (mention.getUrl().contains(getDomain(span.getURL()))) {
String url = mention.getUrl();
if (url != null && url.contains(getDomain(span.getURL()))) {
break;
}
}
@ -194,6 +199,9 @@ public class LinkHelper {
* @param context context
*/
public static void openLink(String url, Context context) {
if(url == null)
return;
Uri uri = Uri.parse(url).normalizeScheme();
boolean useCustomTabs = PreferenceManager.getDefaultSharedPreferences(context)