Proyectos de Subversion Android Microlearning

Rev

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

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