I have pass from my MainFragment to my adapter list:
viewModelAppe.getResponseLiveDataCombinedResult().observe(getActivity(),
combinedResult -> mainAdapter.setProjectList(combinedResult.getArtistsWithPhoto()
)) ;
my method in adaper:
private List<Pair<String,String>> localList = Collections.emptyList();
public void setProjectList (final List<Pair<String,String>> list ){
if (list != null){
localList = list;
notifyDataSetChanged();
}else {
Log.v("LOGer","isssue in adapter");
}
}
my class CombinedResult
public class CombinedResult {
List<Pair<String,String>> perfectMapNameAndFoto; private final RootiTune ituneResult; private final RootLastFm lastFmResult; public CombinedResult(RootiTune ituneResult, RootLastFm lastFmResult) { this.ituneResult = ituneResult; this.lastFmResult = lastFmResult; } public List<Pair<String,String>> getArtistsWithPhoto () { perfectMapNameAndFoto = new ArrayList<>() ; if (ituneResult.getListSongs() != null){ for (ResultiTune item : ituneResult.getListSongs() ){ perfectMapNameAndFoto.add(new Pair <String,String> (item.getArtistName(),item.getArtworkUrl100() )); } } if(lastFmResult.getResults().getArtistmatches().getListOfLatsFmArtists() != null) { for (ArtistLastFm item : lastFmResult.getResults().getArtistmatches().getListOfLatsFmArtists()) perfectMapNameAndFoto.add(new Pair<String, String>(item.getName(), item.getUrl())); } return perfectMapNameAndFoto; }
}
and method:
@BindingAdapter("setName")
public static void setName (@NonNull TextView textView, Pair <String,String> value, CombinedResult name){
name.getArtistsWithPhoto();
List<Pair<String, String>> valuePair = name.getArtistsWithPhoto();
textView.setText(String.valueOf(valuePair));
}
Question:
my problem is that I dont know how to pull out data from first String
List<Pair<String,String>
first String contain name that I want put in my textView at item_list in recyclerView, second is foto that in this case is irrelevant.