Set the final strings and the titles of the songs to be synchronized in the home alert

This commit is contained in:
antonio 2023-03-19 18:47:41 +01:00
parent b0b5fc2172
commit c77e23af13
3 changed files with 24 additions and 8 deletions

View file

@ -57,6 +57,7 @@ import com.google.android.gms.cast.framework.CastButtonFactory;
import com.google.android.material.snackbar.Snackbar;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -267,17 +268,19 @@ public class HomeFragment extends Fragment implements ClickCallback {
@Override
public void onChanged(List<Child> songs) {
if (songs != null) {
boolean showAlert = false;
DownloaderManager manager = DownloadUtil.getDownloadTracker(requireContext());
List<String> toSync = new ArrayList<>();
for (Child song : songs) {
if (!manager.isDownloaded(song.getId())) {
showAlert = true;
break;
toSync.add(song.getTitle());
}
}
if (showAlert) bind.homeSyncStarredCard.setVisibility(View.VISIBLE);
if (!toSync.isEmpty()) {
bind.homeSyncStarredCard.setVisibility(View.VISIBLE);
bind.homeSyncStarredTracksToSync.setText(String.join(", ", toSync));
}
}
homeViewModel.getAllStarredTracks().removeObserver(this);