Proyectos de Subversion Android Microlearning

Rev

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