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" applicationId "org.joinmastodon.android"
minSdk 23 minSdk 23
targetSdk 31 targetSdk 31
versionCode 25 versionCode 26
versionName "0.1" versionName "0.1"
} }

View File

@ -4,10 +4,12 @@ import android.text.TextUtils;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import org.joinmastodon.android.api.ObjectValidationException;
import org.joinmastodon.android.api.RequiredField; import org.joinmastodon.android.api.RequiredField;
import java.time.Instant; import java.time.Instant;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class Filter extends BaseModel{ public class Filter extends BaseModel{
@ -15,14 +17,27 @@ public class Filter extends BaseModel{
public String id; public String id;
@RequiredField @RequiredField
public String phrase; public String phrase;
@RequiredField public transient EnumSet<FilterContext> context=EnumSet.noneOf(FilterContext.class);
public EnumSet<FilterContext> context;
public Instant expiresAt; public Instant expiresAt;
public boolean irreversible; public boolean irreversible;
public boolean wholeWord; public boolean wholeWord;
@SerializedName("context")
private List<FilterContext> _context;
private transient Pattern pattern; 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){ public boolean matches(CharSequence text){
if(TextUtils.isEmpty(text)) if(TextUtils.isEmpty(text))
return false; return false;