Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

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