Merge pull request #6025 from ByteHamster/filter-funding-by-length
When multiple funding tags reference the same URL, display the one with longer title
This commit is contained in:
commit
0c8eb31b40
@ -57,7 +57,7 @@ import io.reactivex.schedulers.Schedulers;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays information about a feed.
|
* Displays information about a feed.
|
||||||
@ -236,13 +236,24 @@ public class FeedInfoFragment extends Fragment implements Toolbar.OnMenuItemClic
|
|||||||
} else {
|
} else {
|
||||||
lblSupport.setVisibility(View.VISIBLE);
|
lblSupport.setVisibility(View.VISIBLE);
|
||||||
ArrayList<FeedFunding> fundingList = feed.getPaymentLinks();
|
ArrayList<FeedFunding> fundingList = feed.getPaymentLinks();
|
||||||
StringBuilder str = new StringBuilder();
|
|
||||||
HashSet<String> seen = new HashSet<String>();
|
// Filter for duplicates, but keep items in the order that they have in the feed.
|
||||||
for (FeedFunding funding : fundingList) {
|
Iterator<FeedFunding> i = fundingList.iterator();
|
||||||
if (seen.contains(funding.url)) {
|
while (i.hasNext()) {
|
||||||
continue;
|
FeedFunding funding = i.next();
|
||||||
|
for (FeedFunding other : fundingList) {
|
||||||
|
if (TextUtils.equals(other.url, funding.url)) {
|
||||||
|
if (other.content != null && funding.content != null
|
||||||
|
&& other.content.length() > funding.content.length()) {
|
||||||
|
i.remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
seen.add(funding.url);
|
}
|
||||||
|
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
for (FeedFunding funding : fundingList) {
|
||||||
str.append(funding.content.isEmpty()
|
str.append(funding.content.isEmpty()
|
||||||
? getContext().getResources().getString(R.string.support_podcast)
|
? getContext().getResources().getString(R.string.support_podcast)
|
||||||
: funding.content).append(" ").append(funding.url);
|
: funding.content).append(" ").append(funding.url);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user