I have a List which contains a record of various CallLog objects. Every CallLog is different, and when I pass this to my ListView, each log is correctly displayed on my screen. What I want to do, however, is remove logs which have the same RemoteAddress attribute (ie a person who called me or has received a call by me should only appear once in my ListView). This is because I will display all log details for that remote contact directly below it.
How can I create a method (or class), which could filter out my List to only keep unique Remote Addresses? Below is how I retrieve this log list from the core. It has the form of a CallLog[]:
// Filter this
List<CallLog> mLogs = Arrays.asList(LinphoneManager.getCore().getCallLogs());
List<CallLog> mLogs = Stream.<CallLog>of(LinphoneManager.getCore().getCallLogs())
.collect(ArrayList::new,
(a, l) -> { if (!a.stream().anyMatch(o -> ((CallLog) o).remoteaddress.equals(l.remoteaddress))) a.add(l); },
(a, b) -> { a.addAll(b); })
Have you tried something like this before? You can use set method rather than add.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.