Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

Rev 3 | Rev 18 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 gabriel 1
package com.cesams.twogetskills.preference;
2
 
3
import android.content.Context;
4
import android.content.SharedPreferences;
5
import com.cesams.twogetskills.Constants;
6
 
7
public class Preference {
3 gabriel 8
 
9
    private static Preference instance;
10
    private Context context;
11
 
1 gabriel 12
    private String userUuid;
13
 
14
    private String email;
15
    private String firstName;
16
    private String lastName;
17
    private String maxDateChanges;
18
    private String lastDataRefresh;
19
    private String image;
20
    private String password;
21
    private String aes;
22
    private int fragmentIdxActive;
23
    private String topicUuidActive;
24
    private String capsuleUuidActive;
25
    private String lastCapsuleUuidActive;
3 gabriel 26
    private String slideNameActive;
1 gabriel 27
    private String slideUuidActive;
28
    private String companyUuidActive;
29
    private int companyCount;
30
 
31
    //Device
32
    private String deviceUuid;
33
    private String deviceToken;
34
 
3 gabriel 35
    public static Preference getInstance(Context context)
36
    {
37
        if (instance == null) {
38
            instance = new Preference(context);
39
        }
40
 
41
        return instance;
42
    }
43
 
44
 
45
 
1 gabriel 46
    public String getUserUuid() {
47
        return userUuid;
48
    }
49
    public void setUserUuid(String userUuid) {
50
        this.userUuid = userUuid;
51
    }
52
 
3 gabriel 53
    public String getSlideName() {
54
        return slideNameActive;
55
    }
56
 
57
    public void setSlideName(String slideNameActive) {
58
        this.slideNameActive = slideNameActive;
59
    }
60
 
1 gabriel 61
    public String getEmail() {
62
        return email;
63
    }
64
 
65
    public void setEmail(String email) {
66
        this.email = email;
67
    }
68
 
69
    public String getFirstName() {
70
        return firstName;
71
    }
72
 
73
    public void setFirstName(String firstName) {
74
        this.firstName = firstName;
75
    }
76
 
77
    public String getLastName() {
78
        return lastName;
79
    }
80
 
81
    public void setLastName(String lastName) {
82
        this.lastName = lastName;
83
    }
84
 
85
    public String getMaxDateChanges() {
86
        return maxDateChanges;
87
    }
88
 
89
    public void setMaxDateChanges(String maxDateChanges) {
90
        this.maxDateChanges = maxDateChanges;
91
    }
92
 
93
    public String getLastDataRefresh() {
94
        return lastDataRefresh;
95
    }
96
 
97
    public void setLastDataRefresh(String lastDataRefresh) {
98
        this.lastDataRefresh = lastDataRefresh;
99
    }
100
 
101
    public String getImage() {
102
        return image;
103
    }
104
 
105
    public void setImage(String image) {
106
        this.image = image;
107
    }
108
 
109
    public String getPassword() {
110
        return password;
111
    }
112
 
113
    public void setPassword(String password) {
114
        this.password = password;
115
    }
116
 
117
    public String getAes() {
118
        return aes;
119
    }
120
 
121
    public void setAes(String aes) {
122
        this.aes = aes;
123
    }
124
 
125
    public int getFragmentIdxActive() {
126
        return fragmentIdxActive;
127
    }
128
 
129
    public void setFragmentIdxActive(int fragmentIdxActive) {
130
        this.fragmentIdxActive = fragmentIdxActive;
131
    }
132
 
133
    public String getTopicUuidActive() {
134
        return topicUuidActive;
135
    }
136
 
137
    public void setTopicUuidActive(String topicUuidActive) {
138
        this.topicUuidActive = topicUuidActive;
139
    }
140
 
141
    public String getCapsuleUuidActive() {
142
        return capsuleUuidActive;
143
    }
144
 
145
    public void setCapsuleUuidActive(String capsuleUuidActive) {
146
        this.capsuleUuidActive = capsuleUuidActive;
147
    }
148
 
149
    public String getSlideUuidActive() {
150
        return slideUuidActive;
151
    }
152
 
153
    public void setSlideUuidActive(String slideUuidActive) {
154
        this.slideUuidActive = slideUuidActive;
155
    }
156
 
157
    public String getCompanyUuidActive() {
158
        return companyUuidActive;
159
    }
160
 
161
    public void setCompanyUuidActive(String companyUuidActive) {
162
        this.companyUuidActive = companyUuidActive;
163
    }
164
 
165
    public String getLastCapsuleUuidActive() {
166
        return lastCapsuleUuidActive;
167
    }
168
 
169
    public void setLastCapsuleUuidActive(String lastCapsuleUuidActive) {
170
        this.lastCapsuleUuidActive = lastCapsuleUuidActive;
171
    }
172
 
173
    public int getCompanyCount() {
174
        return companyCount;
175
    }
176
 
177
    public void setCompanyCount(int companyCount) {
178
        this.companyCount = companyCount;
179
    }
180
 
181
    public String getDeviceUuid() {
182
        return deviceUuid;
183
    }
184
 
185
    public void setDeviceUuid(String deviceUuid) {
186
        this.deviceUuid = deviceUuid;
187
    }
188
 
189
    public String getDeviceToken() {
190
        return deviceToken;
191
    }
192
 
193
    public void setDeviceToken(String deviceToken) {
194
        this.deviceToken = deviceToken;
195
    }
196
 
3 gabriel 197
    private Preference(Context context) {
198
        this.context = context;
199
        this.load();
200
 
201
    }
202
 
203
    public void load()
204
    {
205
 
206
 
1 gabriel 207
        SharedPreferences sharedPreferences = context.getSharedPreferences(
208
                Constants.PREFERENCE_FILENAME, Context.MODE_PRIVATE);
209
 
210
        deviceUuid = sharedPreferences.getString("device_uuid" , "");
211
        deviceToken = sharedPreferences.getString("device_token" , "");
212
        userUuid = sharedPreferences.getString("user_uuid", "");
213
        email = sharedPreferences.getString("email", "");
214
        firstName = sharedPreferences.getString("first_name", "");
215
        lastName = sharedPreferences.getString("last_name", "");
216
        image = sharedPreferences.getString("image", "");
217
 
218
        maxDateChanges = sharedPreferences.getString("max_date_changes", "");
219
        lastDataRefresh = sharedPreferences.getString("last_date_refresh", "");
220
 
221
        password = sharedPreferences.getString("password", "");
222
        aes = sharedPreferences.getString("aes", "");
223
 
224
        fragmentIdxActive = sharedPreferences.getInt("fragment_idx_active", Constants.IDX_FRAGMENT_INTRO);
225
        topicUuidActive = sharedPreferences.getString("topic_uuid_active", "");
226
        capsuleUuidActive = sharedPreferences.getString("capsule_uuid_active", "");
227
        slideUuidActive = sharedPreferences.getString("slide_uuid_active", "");
228
        companyUuidActive = sharedPreferences.getString("company_uuid_active", "");
229
        companyCount = sharedPreferences.getInt("company_count", 0);
230
        lastCapsuleUuidActive = sharedPreferences.getString("last_capsule_uuid_active", "");
231
 
232
    }
233
 
3 gabriel 234
    public void save()
1 gabriel 235
    {
236
        SharedPreferences sharedPreferences = context.getSharedPreferences(
237
                Constants.PREFERENCE_FILENAME, Context.MODE_PRIVATE);
238
 
239
        SharedPreferences.Editor editor = sharedPreferences.edit();
240
        editor.putString("device_uuid" , deviceUuid);
241
        editor.putString("device_token" , deviceToken);
242
        editor.putString("user_uuid", userUuid);
243
        editor.putString("email", email);
244
        editor.putString("first_name", firstName);
245
        editor.putString("last_name", lastName);
246
        editor.putString("image", image);
247
        editor.putString("max_date_changes", maxDateChanges);
248
        editor.putString("last_date_refresh", lastDataRefresh);
3 gabriel 249
        editor.putString("last_slidename",slideNameActive);
1 gabriel 250
        editor.putString("password", password);
251
        editor.putString("aes", aes);
252
 
253
 
254
        editor.putInt("fragment_idx_active", fragmentIdxActive);
255
        editor.putString("topic_uuid_active", topicUuidActive);
256
        editor.putString("capsule_uuid_active", capsuleUuidActive);
257
        editor.putString("slide_uuid_active", slideUuidActive);
258
        editor.putString("company_uuid_active", companyUuidActive);
259
        editor.putInt("company_count", companyCount);
260
        editor.putString("last_capsule_uuid_active", lastCapsuleUuidActive);
261
 
3 gabriel 262
        editor.apply();
1 gabriel 263
    }
264
}