Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

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