Proyectos de Subversion Android Microlearning

Rev

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