Sound.java
public class Sound {
private String mAssetPath;
private String mName;
public Sound(String assetPath) {
mAssetPath = assetPath;
String[] components = assetPath.split("/");
String filename = components[components.length - 1];
mName = filename.replace(".wav", "");
}
public String getAssetPath() {
return mAssetPath;
}
public String getName() {
return mName;
}
}
SoundViewModel.java
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.util.Log;
public class SoundViewModel extends BaseObservable {
private Sound mSound;
private BeatBox mBeatBox;
public SoundViewModel(BeatBox beatBox) {
mBeatBox = beatBox;
}
@Bindable
public String getTitle() {
return mSound.getName();
}
public Sound getSound() {
return mSound;
}
public void setSound(Sound sound) {
mSound = sound;
notifyChange();
}
}