1 /***
2 * Ambient - A music player for the Android platform
3 Copyright (C) 2007 Martin Vysny
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 package sk.baka.ambient.activity;
20
21 import sk.baka.ambient.AmbientApplication;
22 import sk.baka.ambient.AppState;
23 import sk.baka.ambient.R;
24 import sk.baka.ambient.commons.Binder;
25 import android.app.Activity;
26 import android.os.Bundle;
27 import android.view.View;
28 import android.view.View.OnClickListener;
29
30 /***
31 * Displays an Ampache client configuration window.
32 *
33 * @author Martin Vysny
34 */
35 public final class AmpacheClientActivity extends Activity {
36 @Override
37 protected void onCreate(Bundle icicle) {
38 super.onCreate(icicle);
39 setContentView(R.layout.ampache_client_activity);
40 final AmpacheClientBean bean = AmbientApplication.getInstance()
41 .getStateHandler().getStartupState().ampacheClient;
42 if (bean != null) {
43 final View view = findViewById(R.id.ampacheRoot);
44 Binder.bindBeanView(bean, view, true, true);
45 }
46 findViewById(R.id.ampacheSave).setOnClickListener(
47 new OnClickListener() {
48 public void onClick(View v) {
49 final AppState state = AmbientApplication.getInstance()
50 .getStateHandler().getStartupState();
51 if (state.ampacheClient == null) {
52 state.ampacheClient = new AmpacheClientBean();
53 }
54 Binder.bindBeanView(state.ampacheClient,
55 findViewById(R.id.ampacheRoot), false, true);
56 AmbientApplication.getInstance().getStateHandler()
57 .saveState();
58 setResult(Activity.RESULT_OK);
59 finish();
60 }
61 });
62 }
63 }