去掉List对象列表中重复的bean

  PlayListLiveData.getInstance().observe(this, new Observer>() {
            @Override
            public void onChanged(@Nullable List songInfos) {
                List integerList=new ArrayList<>();
                if(songInfos!=null&&songInfos.size()>0) {
                    for (int i = 0; i <= songInfos.size() - 1; i++) {
                        for (int j = i + 1; j <= songInfos.size() - 1; j++) {
                            if (songInfos.get(i).getSong_id() == songInfos.get(j).getSong_id()) {
                                integerList.add(i);
                            }
                        }
                    }
                }
                if(integerList.size()>0) {
                    for (int i = 0; i < integerList.size(); i++) {
                        songInfos.remove(songInfos.get(integerList.get(i)));
                    }
                }
                adapter.clear();
                adapter.addAll(songInfos);
            }
        });

你可能感兴趣的:(去掉List对象列表中重复的bean)