fix search for optimal recording when there is no HD recording

This commit is contained in:
Felix 2017-09-26 22:29:03 +02:00
parent f811fefbcb
commit e6fa7661b3

View file

@ -162,9 +162,25 @@ public class Event extends SugarRecord implements Parcelable, Comparable<Event>
if(r.isHighQuality() && r.getMimeType().equals("video/mp4")) if(r.isHighQuality() && r.getMimeType().equals("video/mp4"))
result.add(r); result.add(r);
} }
if(result.size()== 0){
for(Recording r : getRecordings()){
if(r.getMimeType().equals("video/mp4"))
result.add(r);
}
}
if(result.size()== 0){
for(Recording r : getRecordings()){
if(r.getMimeType().startsWith("video/"))
result.add(r);
}
}
// sort by length of language-string in decending order, so first item has most languages // sort by length of language-string in decending order, so first item has most languages
Collections.sort(result,(o1, o2) -> o2.getLanguage().length() - o1.getLanguage().length()); Collections.sort(result,(o1, o2) -> o2.getLanguage().length() - o1.getLanguage().length());
return result.get(0); if(result.size() > 0){
return result.get(0);
} else {
return getRecordings().get(0);
}
} }
public String getExtendedDescription(){ public String getExtendedDescription(){