mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
fix: null checking
This commit is contained in:
parent
c4b9db303a
commit
fe3ba9fb89
1 changed files with 23 additions and 10 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
package com.cappielloantonio.tempo.util;
|
package com.cappielloantonio.tempo.util;
|
||||||
|
|
||||||
|
import androidx.annotation.OptIn;
|
||||||
import androidx.media3.common.Metadata;
|
import androidx.media3.common.Metadata;
|
||||||
import androidx.media3.common.Tracks;
|
import androidx.media3.common.Tracks;
|
||||||
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.exoplayer.ExoPlayer;
|
import androidx.media3.exoplayer.ExoPlayer;
|
||||||
|
|
||||||
import com.cappielloantonio.tempo.model.ReplayGain;
|
import com.cappielloantonio.tempo.model.ReplayGain;
|
||||||
|
|
@ -10,6 +12,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@OptIn(markerClass = UnstableApi.class)
|
||||||
public class ReplayGainUtil {
|
public class ReplayGainUtil {
|
||||||
private static final String[] tags = {"REPLAYGAIN_TRACK_GAIN", "REPLAYGAIN_ALBUM_GAIN", "R128_TRACK_GAIN", "R128_ALBUM_GAIN"};
|
private static final String[] tags = {"REPLAYGAIN_TRACK_GAIN", "REPLAYGAIN_ALBUM_GAIN", "R128_TRACK_GAIN", "R128_ALBUM_GAIN"};
|
||||||
|
|
||||||
|
|
@ -23,11 +26,15 @@ public class ReplayGainUtil {
|
||||||
private static List<Metadata> getMetadata(Tracks tracks) {
|
private static List<Metadata> getMetadata(Tracks tracks) {
|
||||||
List<Metadata> metadata = new ArrayList<>();
|
List<Metadata> metadata = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < tracks.getGroups().size(); i++) {
|
if (tracks != null && !tracks.getGroups().isEmpty()) {
|
||||||
Tracks.Group group = tracks.getGroups().get(i);
|
for (int i = 0; i < tracks.getGroups().size(); i++) {
|
||||||
|
Tracks.Group group = tracks.getGroups().get(i);
|
||||||
|
|
||||||
for (int j = 0; j < group.getMediaTrackGroup().length; j++) {
|
if (group != null && group.getMediaTrackGroup() != null) {
|
||||||
metadata.add(group.getTrackFormat(j).metadata);
|
for (int j = 0; j < group.getMediaTrackGroup().length; j++) {
|
||||||
|
metadata.add(group.getTrackFormat(j).metadata);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,13 +44,19 @@ public class ReplayGainUtil {
|
||||||
private static List<ReplayGain> getReplayGains(List<Metadata> metadata) {
|
private static List<ReplayGain> getReplayGains(List<Metadata> metadata) {
|
||||||
List<ReplayGain> gains = new ArrayList<>();
|
List<ReplayGain> gains = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < metadata.size(); i++) {
|
if (metadata != null) {
|
||||||
for (int j = 0; j < metadata.get(i).length(); j++) {
|
for (int i = 0; i < metadata.size(); i++) {
|
||||||
Metadata.Entry entry = metadata.get(i).get(j);
|
Metadata singleMetadata = metadata.get(i);
|
||||||
|
|
||||||
if (checkReplayGain(entry)) {
|
if (singleMetadata != null) {
|
||||||
ReplayGain replayGain = setReplayGains(entry);
|
for (int j = 0; j < singleMetadata.length(); j++) {
|
||||||
gains.add(replayGain);
|
Metadata.Entry entry = singleMetadata.get(j);
|
||||||
|
|
||||||
|
if (checkReplayGain(entry)) {
|
||||||
|
ReplayGain replayGain = setReplayGains(entry);
|
||||||
|
gains.add(replayGain);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue