parent
b898dc010e
commit
187693883c
|
@ -73,7 +73,7 @@ public class CacheController{
|
||||||
status.hasGapAfter=((flags & POST_FLAG_GAP_AFTER)!=0);
|
status.hasGapAfter=((flags & POST_FLAG_GAP_AFTER)!=0);
|
||||||
newMaxID=status.id;
|
newMaxID=status.id;
|
||||||
for(Filter filter:filters){
|
for(Filter filter:filters){
|
||||||
if(filter.matches(status.getContentStatus().content))
|
if(filter.matches(status))
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
result.add(status);
|
result.add(status);
|
||||||
|
@ -145,7 +145,7 @@ public class CacheController{
|
||||||
newMaxID=ntf.id;
|
newMaxID=ntf.id;
|
||||||
if(ntf.status!=null){
|
if(ntf.status!=null){
|
||||||
for(Filter filter:filters){
|
for(Filter filter:filters){
|
||||||
if(filter.matches(ntf.status.getContentStatus().content))
|
if(filter.matches(ntf.status))
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ public class CacheController{
|
||||||
callback.onSuccess(new PaginatedResponse<>(result.stream().filter(ntf->{
|
callback.onSuccess(new PaginatedResponse<>(result.stream().filter(ntf->{
|
||||||
if(ntf.status!=null){
|
if(ntf.status!=null){
|
||||||
for(Filter filter:filters){
|
for(Filter filter:filters){
|
||||||
if(filter.matches(ntf.status.getContentStatus().content)){
|
if(filter.matches(ntf.status)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ public class HomeTimelineFragment extends StatusListFragment{
|
||||||
if(idsBelowGap.contains(s.id))
|
if(idsBelowGap.contains(s.id))
|
||||||
break;
|
break;
|
||||||
for(Filter filter:filters){
|
for(Filter filter:filters){
|
||||||
if(filter.matches(s.getContentStatus().content)){
|
if(filter.matches(s)){
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class ThreadFragment extends StatusListFragment{
|
||||||
return statuses;
|
return statuses;
|
||||||
return statuses.stream().filter(status->{
|
return statuses.stream().filter(status->{
|
||||||
for(Filter filter:filters){
|
for(Filter filter:filters){
|
||||||
if(filter.matches(status.getContentStatus().content))
|
if(filter.matches(status))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -50,6 +50,10 @@ public class Filter extends BaseModel{
|
||||||
return pattern.matcher(text).find();
|
return pattern.matcher(text).find();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean matches(Status status){
|
||||||
|
return matches(status.getContentStatus().getStrippedText());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return "Filter{"+
|
return "Filter{"+
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.joinmastodon.android.model;
|
||||||
import org.joinmastodon.android.api.ObjectValidationException;
|
import org.joinmastodon.android.api.ObjectValidationException;
|
||||||
import org.joinmastodon.android.api.RequiredField;
|
import org.joinmastodon.android.api.RequiredField;
|
||||||
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
|
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
|
||||||
|
import org.joinmastodon.android.ui.text.HtmlParser;
|
||||||
import org.parceler.Parcel;
|
import org.parceler.Parcel;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
@ -56,6 +57,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
|
||||||
|
|
||||||
public transient boolean spoilerRevealed;
|
public transient boolean spoilerRevealed;
|
||||||
public transient boolean hasGapAfter;
|
public transient boolean hasGapAfter;
|
||||||
|
private transient String strippedText;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postprocess() throws ObjectValidationException{
|
public void postprocess() throws ObjectValidationException{
|
||||||
|
@ -132,4 +134,10 @@ public class Status extends BaseModel implements DisplayItemsParent{
|
||||||
public Status getContentStatus(){
|
public Status getContentStatus(){
|
||||||
return reblog!=null ? reblog : this;
|
return reblog!=null ? reblog : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStrippedText(){
|
||||||
|
if(strippedText==null)
|
||||||
|
strippedText=HtmlParser.strip(content);
|
||||||
|
return strippedText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,8 @@ public class StatusFilterPredicate implements Predicate<Status>{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Status status){
|
public boolean test(Status status){
|
||||||
CharSequence content=status.getContentStatus().content;
|
|
||||||
for(Filter filter:filters){
|
for(Filter filter:filters){
|
||||||
if(filter.matches(content))
|
if(filter.matches(status))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue