Fix crash

This commit is contained in:
Grishka 2022-04-13 01:21:17 +03:00
parent 12ac5e9425
commit 0f61cb12d4
2 changed files with 18 additions and 3 deletions

View File

@ -10,7 +10,7 @@ android {
applicationId "org.joinmastodon.android"
minSdk 23
targetSdk 31
versionCode 25
versionCode 26
versionName "0.1"
}

View File

@ -4,10 +4,12 @@ import android.text.TextUtils;
import com.google.gson.annotations.SerializedName;
import org.joinmastodon.android.api.ObjectValidationException;
import org.joinmastodon.android.api.RequiredField;
import java.time.Instant;
import java.util.EnumSet;
import java.util.List;
import java.util.regex.Pattern;
public class Filter extends BaseModel{
@ -15,14 +17,27 @@ public class Filter extends BaseModel{
public String id;
@RequiredField
public String phrase;
@RequiredField
public EnumSet<FilterContext> context;
public transient EnumSet<FilterContext> context=EnumSet.noneOf(FilterContext.class);
public Instant expiresAt;
public boolean irreversible;
public boolean wholeWord;
@SerializedName("context")
private List<FilterContext> _context;
private transient Pattern pattern;
@Override
public void postprocess() throws ObjectValidationException{
super.postprocess();
if(_context==null)
throw new ObjectValidationException();
for(FilterContext c:_context){
if(c!=null)
context.add(c);
}
}
public boolean matches(CharSequence text){
if(TextUtils.isEmpty(text))
return false;