Proyectos de Subversion Android Microlearning

Rev

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