display container and codec in dialog
This commit is contained in:
parent
aaaf7566f3
commit
868c8fb96d
5 changed files with 62 additions and 47 deletions
|
|
@ -1,6 +1,5 @@
|
|||
package com.dkanada.gramophone.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -16,7 +15,7 @@ import com.dkanada.gramophone.model.DirectPlayCodec;
|
|||
import java.util.List;
|
||||
|
||||
public class DirectPlayCodecAdapter extends RecyclerView.Adapter<DirectPlayCodecAdapter.ViewHolder> {
|
||||
private List<DirectPlayCodec> directPlayCodecs;
|
||||
private final List<DirectPlayCodec> directPlayCodecs;
|
||||
|
||||
public DirectPlayCodecAdapter(List<DirectPlayCodec> directPlayCodecs) {
|
||||
this.directPlayCodecs = directPlayCodecs;
|
||||
|
|
@ -29,17 +28,17 @@ public class DirectPlayCodecAdapter extends RecyclerView.Adapter<DirectPlayCodec
|
|||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DirectPlayCodecAdapter.ViewHolder holder, int position) {
|
||||
DirectPlayCodec directPlayCodec = directPlayCodecs.get(position);
|
||||
|
||||
holder.checkBox.setChecked(directPlayCodec.selected);
|
||||
holder.title.setText(directPlayCodec.title);
|
||||
holder.checkbox.setChecked(directPlayCodec.selected);
|
||||
holder.container.setText(directPlayCodec.codec.container);
|
||||
holder.codec.setText(directPlayCodec.codec.codec);
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
directPlayCodec.selected = !directPlayCodec.selected;
|
||||
holder.checkBox.setChecked(directPlayCodec.selected);
|
||||
holder.checkbox.setChecked(directPlayCodec.selected);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -53,13 +52,16 @@ public class DirectPlayCodecAdapter extends RecyclerView.Adapter<DirectPlayCodec
|
|||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public CheckBox checkBox;
|
||||
public TextView title;
|
||||
public CheckBox checkbox;
|
||||
public TextView container;
|
||||
public TextView codec;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
checkBox = view.findViewById(R.id.checkbox);
|
||||
title = view.findViewById(R.id.title);
|
||||
|
||||
checkbox = view.findViewById(R.id.checkbox);
|
||||
container = view.findViewById(R.id.container);
|
||||
codec = view.findViewById(R.id.codec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,31 @@
|
|||
package com.dkanada.gramophone.model;
|
||||
|
||||
public class DirectPlayCodec {
|
||||
public String codecName;
|
||||
public String title;
|
||||
public String value;
|
||||
public Codec codec;
|
||||
public boolean selected;
|
||||
|
||||
public DirectPlayCodec(String codecName, String title, String value, boolean selected) {
|
||||
this.codecName = codecName;
|
||||
this.title = title;
|
||||
this.value = value;
|
||||
public DirectPlayCodec(Codec codec, boolean selected) {
|
||||
this.codec = codec;
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public enum Codec {
|
||||
FLAC("FLAC","flac|flac"),
|
||||
MP3("MP3", "mp3|mp3"),
|
||||
OPUS("Opus", "opus|opus"),
|
||||
AAC("M4A-AAC", "m4a|aac"),
|
||||
OGG("OGG-Vorbis", "ogg|vorbis"),
|
||||
OOPUS("OGG-Opus", "ogg|opus"),
|
||||
MKA("MKA-Opus", "mka|opus");
|
||||
FLAC("FLAC", "FLAC", "flac|flac"),
|
||||
MP3("MP3", "MP3", "mp3|mp3"),
|
||||
OPUS("Opus", "Opus", "opus|opus"),
|
||||
AAC("M4A", "AAC", "m4a|aac"),
|
||||
VORBIS("OGG", "Vorbis", "ogg|vorbis"),
|
||||
OGG("OGG", "Opus", "ogg|opus"),
|
||||
MKA("MKA", "Opus", "mka|opus");
|
||||
|
||||
public final String title;
|
||||
public final String container;
|
||||
public final String codec;
|
||||
public final String value;
|
||||
|
||||
Codec(String title, String value) {
|
||||
Codec(String container, String codec, String value) {
|
||||
this.container = container;
|
||||
this.codec = codec;
|
||||
this.value = value;
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class MusicUtil {
|
|||
containerAdded = true;
|
||||
}
|
||||
|
||||
builder.append(directPlayCodec.value).append(',');
|
||||
builder.append(directPlayCodec.codec.value).append(',');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -432,6 +432,7 @@ public final class PreferenceUtil {
|
|||
|
||||
Set<String> selectedCodecNames = new HashSet<>();
|
||||
for (DirectPlayCodec.Codec codec : codecs) {
|
||||
// this will be the default value
|
||||
selectedCodecNames.add(codec.name());
|
||||
}
|
||||
|
||||
|
|
@ -441,7 +442,7 @@ public final class PreferenceUtil {
|
|||
for (DirectPlayCodec.Codec codec : codecs) {
|
||||
String name = codec.name();
|
||||
boolean selected = selectedCodecNames.contains(name);
|
||||
directPlayCodecs.add(new DirectPlayCodec(name, codec.title, codec.value, selected));
|
||||
directPlayCodecs.add(new DirectPlayCodec(codec, selected));
|
||||
}
|
||||
|
||||
return directPlayCodecs;
|
||||
|
|
@ -451,7 +452,7 @@ public final class PreferenceUtil {
|
|||
Set<String> codecNames = new HashSet<>();
|
||||
for (DirectPlayCodec directPlayCodec : directPlayCodecs) {
|
||||
if (directPlayCodec.selected) {
|
||||
codecNames.add(directPlayCodec.codecName);
|
||||
codecNames.add(directPlayCodec.codec.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue