Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

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