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 package sk.baka.ambient;
19
20 import java.io.Serializable;
21
22 import sk.baka.ambient.activity.AmpacheClientBean;
23 import sk.baka.ambient.activity.main.MainActivity;
24 import sk.baka.ambient.playerservice.PlayerStateEnum;
25 import sk.baka.ambient.playlist.IPlaylistStrategy;
26 import sk.baka.ambient.playlist.Random;
27 import sk.baka.ambient.playlist.Repeat;
28
29 /***
30 * A serializable application state.
31 *
32 * @author Martin Vysny
33 */
34 public final class AppState implements Serializable {
35 /***
36 *
37 */
38 private static final long serialVersionUID = 6222503996948628518L;
39
40 /***
41 * The playlist strategy.
42 */
43 public IPlaylistStrategy playlist;
44
45 /***
46 * State of playback.
47 */
48 public PlayerStateEnum state = PlayerStateEnum.Stopped;
49
50 /***
51 * Position in playback, in milliseconds.
52 */
53 public int position = 0;
54
55 /***
56 * The repeat state.
57 */
58 public Repeat repeat = Repeat.NO;
59
60 /***
61 * The random state.
62 */
63 public Random random = Random.NONE;
64
65 /***
66 * The {@link MainActivity} visible controller.
67 */
68 public int visibleController = -1;
69
70 /***
71 * Are we online?
72 */
73 public boolean online = false;
74
75 /***
76 * Is GUI zoomed?
77 */
78 public boolean zoomed = false;
79
80 /***
81 * The Ampache client configuration.
82 */
83 public AmpacheClientBean ampacheClient;
84
85 /***
86 * A welcome dialog was shown for this version of Ambient.
87 */
88 public String welcomeVersion;
89
90 /***
91 * Implemented by components that are aware of the global application state.
92 *
93 * @author Martin Vysny
94 */
95 public static interface IAppStateAware {
96 /***
97 * Cherry-picks values from the application state and reinitializes
98 * itself.
99 *
100 * @param state
101 * the just-loaded state
102 */
103 void reinit(final AppState state);
104
105 /***
106 * Stores the components state into the global state. Must not alter
107 * settings not applicable for this component.
108 *
109 * @param state
110 * the object to store to.
111 */
112 void storeState(final AppState state);
113 }
114 }