|
@@ -2,6 +2,7 @@ package com.fusi24.entryPermitScanner.data;
|
2
|
2
|
|
3
|
3
|
import android.content.SharedPreferences;
|
4
|
4
|
|
|
5
|
+import com.fusi24.entryPermitScanner.data.entity.DataEntryPermit;
|
5
|
6
|
import com.fusi24.entryPermitScanner.data.entity.DataSite;
|
6
|
7
|
import com.google.gson.Gson;
|
7
|
8
|
import com.google.gson.reflect.TypeToken;
|
|
@@ -21,6 +22,7 @@ public class SessionManager {
|
21
|
22
|
private static final String USER_RFID_NUMBER = "user_rfid_number";
|
22
|
23
|
private static final String GATE = "gate";
|
23
|
24
|
private static final String SITE_LIST = "site_list";
|
|
25
|
+ private static final String PERMIT_LIST = "permit_list";
|
24
|
26
|
private static final String IS_SERIALPORT_2 = "serial_port_2";
|
25
|
27
|
private static final String IS_DEVELOPMENT = "development";
|
26
|
28
|
|
|
@@ -138,6 +140,24 @@ public class SessionManager {
|
138
|
140
|
editor.apply();
|
139
|
141
|
}
|
140
|
142
|
|
|
143
|
+ public List<DataEntryPermit> getPermitList(){
|
|
144
|
+ List<DataEntryPermit> permitList;
|
|
145
|
+ String jsonPreferences = preferences.getString(PERMIT_LIST, "");
|
|
146
|
+
|
|
147
|
+ Type type = new TypeToken<List<DataEntryPermit>>() {}.getType();
|
|
148
|
+ permitList = new Gson().fromJson(jsonPreferences, type);
|
|
149
|
+
|
|
150
|
+ return permitList;
|
|
151
|
+ }
|
|
152
|
+
|
|
153
|
+ public void setPermitList(List<DataEntryPermit> list){
|
|
154
|
+ String jsonCurProduct = new Gson().toJson(list);
|
|
155
|
+
|
|
156
|
+ SharedPreferences.Editor editor = preferences.edit();
|
|
157
|
+ editor.putString(PERMIT_LIST , jsonCurProduct);
|
|
158
|
+ editor.apply();
|
|
159
|
+ }
|
|
160
|
+
|
141
|
161
|
public Boolean isSerialPort2() {
|
142
|
162
|
return preferences.getBoolean(IS_SERIALPORT_2, false);
|
143
|
163
|
}
|
|
@@ -169,6 +189,8 @@ public class SessionManager {
|
169
|
189
|
editor.remove(USER_TELEPHONE);
|
170
|
190
|
editor.remove(USER_RFID_NUMBER);
|
171
|
191
|
editor.remove(GATE);
|
|
192
|
+ editor.remove(SITE_LIST);
|
|
193
|
+ editor.remove(PERMIT_LIST);
|
172
|
194
|
editor.apply();
|
173
|
195
|
}
|
174
|
196
|
}
|