1 |
iliev |
2302 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
|
|
* Copyright (C) 2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
|
|
* |
6 |
|
|
* This file is part of JSampler. |
7 |
|
|
* |
8 |
|
|
* JSampler is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License version 2 |
10 |
|
|
* as published by the Free Software Foundation. |
11 |
|
|
* |
12 |
|
|
* JSampler is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with JSampler; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
|
|
* MA 02111-1307 USA |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
package org.jsampler.android.view; |
24 |
|
|
|
25 |
|
|
import static org.jsampler.android.view.AndroidI18n.i18n; |
26 |
|
|
|
27 |
|
|
import org.jsampler.AudioDeviceModel; |
28 |
|
|
import org.jsampler.CC; |
29 |
|
|
import org.jsampler.event.ListEvent; |
30 |
|
|
import org.jsampler.event.ListListener; |
31 |
|
|
|
32 |
|
|
public class AudioDeviceSpinnerAdapter extends AbstractSpinnerAdapter<AudioDeviceModel> |
33 |
|
|
implements ListListener<AudioDeviceModel> { |
34 |
|
|
public AudioDeviceSpinnerAdapter() { |
35 |
|
|
CC.getSamplerModel().addAudioDeviceListListener(this); |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
public void |
39 |
|
|
uninstall() { CC.getSamplerModel().removeAudioDeviceListListener(this); } |
40 |
|
|
|
41 |
|
|
@Override |
42 |
|
|
public int |
43 |
|
|
size() { return CC.getSamplerModel().getAudioDeviceCount(); } |
44 |
|
|
|
45 |
|
|
@Override |
46 |
|
|
public Object |
47 |
|
|
get(int position) { return CC.getSamplerModel().getAudioDevice(position); } |
48 |
|
|
|
49 |
|
|
public String |
50 |
|
|
getEmptyItemText() { return i18n.getLabel("AudioDeviceSpinnerAdapter.selectDevice"); } |
51 |
|
|
|
52 |
|
|
public String |
53 |
|
|
getItemText(int position) { |
54 |
|
|
AudioDeviceModel dev = (AudioDeviceModel)getItem(position); |
55 |
|
|
return i18n.getLabel("AudioDeviceSpinnerAdapter.device", dev.getDeviceId()); |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
@Override |
59 |
|
|
public boolean |
60 |
|
|
compare(AudioDeviceModel d1, AudioDeviceModel d2) { |
61 |
|
|
if(d1 == null || d2 == null) return false; |
62 |
|
|
return d1.getDeviceId() == d2.getDeviceId(); |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
/** Invoked when a new audio device is created. */ |
66 |
|
|
@Override |
67 |
|
|
public void |
68 |
|
|
entryAdded(ListEvent<AudioDeviceModel> e) { notifyDataSetChanged(); } |
69 |
|
|
|
70 |
|
|
/** Invoked when an audio device is removed. */ |
71 |
|
|
@Override |
72 |
|
|
public void |
73 |
|
|
entryRemoved(ListEvent<AudioDeviceModel> e) { notifyDataSetChanged(); } |
74 |
|
|
} |