Initial commit
This commit is contained in:
255
sources/com/ubt/jimu/base/cache/Cache.java
vendored
Normal file
255
sources/com/ubt/jimu/base/cache/Cache.java
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
package com.ubt.jimu.base.cache;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.base.db.robot.RobotDbHandler;
|
||||
import com.ubt.jimu.base.db.user.UserDbHandler;
|
||||
import com.ubt.jimu.base.entities.Constant;
|
||||
import com.ubt.jimu.base.entities.Robot;
|
||||
import com.ubt.jimu.base.entities.User;
|
||||
import com.ubt.jimu.course.repository.JimuCourse;
|
||||
import com.ubt.jimu.course.repository.JimuCourseMission;
|
||||
import com.ubt.jimu.course.repository.JimuCourseTask;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Cache {
|
||||
private static final String TAG = "Cache";
|
||||
private static Cache instance;
|
||||
private boolean connected;
|
||||
private JimuCourseMission courseMission;
|
||||
private List<JimuCourseTask> courseTaskList;
|
||||
private JimuCourse jimuCourse;
|
||||
private JimuCourseTask jimuCourseTask;
|
||||
private String mBlocklyTestUrl;
|
||||
private BoardInfo mBoardInfo;
|
||||
private BluetoothDevice mLastConnectedDevice;
|
||||
private long packageId;
|
||||
private String packageImagePath;
|
||||
private String packageName;
|
||||
private Robot robot;
|
||||
private User user;
|
||||
private boolean showMobileDataTips = false;
|
||||
public long differ = 0;
|
||||
private SharePreferenceHelper settings = new SharePreferenceHelper();
|
||||
|
||||
private Cache() {
|
||||
}
|
||||
|
||||
public static synchronized Cache getInstance() {
|
||||
Cache cache;
|
||||
synchronized (Cache.class) {
|
||||
if (instance == null) {
|
||||
instance = new Cache();
|
||||
}
|
||||
cache = instance;
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
public void clearCacheUser() {
|
||||
setUser(null);
|
||||
this.settings.put(SharePreferenceHelper.SP_KEY_USER_ID, "local");
|
||||
this.settings.put(SharePreferenceHelper.AUTHOR_TOKEN, "");
|
||||
}
|
||||
|
||||
public String getBlocklyTest() {
|
||||
return this.mBlocklyTestUrl;
|
||||
}
|
||||
|
||||
public BoardInfo getBoardInfo() {
|
||||
return this.mBoardInfo;
|
||||
}
|
||||
|
||||
public JimuCourseMission getCourseMission() {
|
||||
return this.courseMission;
|
||||
}
|
||||
|
||||
public List<JimuCourseTask> getCourseTaskList() {
|
||||
return this.courseTaskList;
|
||||
}
|
||||
|
||||
public JimuCourse getJimuCourse() {
|
||||
return this.jimuCourse;
|
||||
}
|
||||
|
||||
public JimuCourseTask getJimuCourseTask() {
|
||||
return this.jimuCourseTask;
|
||||
}
|
||||
|
||||
public BluetoothDevice getLastConnectedDevice() {
|
||||
return this.mLastConnectedDevice;
|
||||
}
|
||||
|
||||
public long getLoginUserIntId() {
|
||||
String string = this.settings.getString(SharePreferenceHelper.SP_KEY_USER_ID, "");
|
||||
if (TextUtils.isEmpty(string) || string.equals("local") || Integer.parseInt(string) <= 0) {
|
||||
return 0L;
|
||||
}
|
||||
return Integer.parseInt(string);
|
||||
}
|
||||
|
||||
public long getPackageId() {
|
||||
this.packageId = this.settings.getLong(SharePreferenceHelper.SP_KEY_PACKAGE_ID, 0L).longValue();
|
||||
return this.packageId;
|
||||
}
|
||||
|
||||
public String getPackageImagePath() {
|
||||
return this.settings.getString(SharePreferenceHelper.CURRENT_PACKAGE_IMAGE_PATH, null);
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
this.packageName = this.settings.getString(SharePreferenceHelper.SP_KEY_PACKAGE_NAME, "");
|
||||
return this.packageName;
|
||||
}
|
||||
|
||||
public Robot getRobot() {
|
||||
if (this.robot == null) {
|
||||
long longValue = this.settings.getLong(SharePreferenceHelper.SP_KEY_ROBOT_ID, -1L).longValue();
|
||||
long longValue2 = this.settings.getLong(SharePreferenceHelper.SP_KEY_PACKAGE_ID, -1L).longValue();
|
||||
if (longValue < 0 || longValue2 < 0) {
|
||||
return null;
|
||||
}
|
||||
Robot robotById = RobotDbHandler.getRobotById(longValue);
|
||||
if (robotById != null) {
|
||||
setRobot(robotById);
|
||||
}
|
||||
}
|
||||
return this.robot;
|
||||
}
|
||||
|
||||
public SharePreferenceHelper getSettings() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
public String getTTSToken() {
|
||||
return this.settings.getString(Constant.Cache.SP_KEY_TTS_TOKEN, "");
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
if (this.user == null) {
|
||||
this.user = UserDbHandler.getUser();
|
||||
}
|
||||
return this.user;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return this.settings.getString(SharePreferenceHelper.SP_KEY_USER_ID, "local");
|
||||
}
|
||||
|
||||
public String getUserToken() {
|
||||
return this.settings.getString(SharePreferenceHelper.AUTHOR_TOKEN, "");
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
String string = this.settings.getString(SharePreferenceHelper.SP_KEY_UUID, "");
|
||||
if (!TextUtils.isEmpty(string)) {
|
||||
return string;
|
||||
}
|
||||
String replace = UUID.randomUUID().toString().replace("-", "");
|
||||
XLog.d("woo", "UUID.rancomUUID: " + replace, new Object[0]);
|
||||
this.settings.put(SharePreferenceHelper.SP_KEY_UUID, replace);
|
||||
return replace;
|
||||
}
|
||||
|
||||
public int getVersionCode() {
|
||||
return this.settings.getInt(Constant.Cache.APP_VERSION_CODE, 0);
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return this.connected;
|
||||
}
|
||||
|
||||
public boolean isShowMobileDataTips() {
|
||||
return this.showMobileDataTips;
|
||||
}
|
||||
|
||||
public boolean isWifiOnly() {
|
||||
return this.settings.getBoolean(SharePreferenceHelper.SP_KEY_WIFI_VIEW, true).booleanValue();
|
||||
}
|
||||
|
||||
public void putBoolean(String str, boolean z) {
|
||||
this.settings.put(str, Boolean.valueOf(z));
|
||||
}
|
||||
|
||||
public void putInt(String str, int i) {
|
||||
this.settings.put(str, Integer.valueOf(i));
|
||||
}
|
||||
|
||||
public void putString(String str, String str2) {
|
||||
this.settings.put(str, str2);
|
||||
}
|
||||
|
||||
public void setBlocklyTestUrl(String str) {
|
||||
this.mBlocklyTestUrl = str;
|
||||
}
|
||||
|
||||
public void setBoardInfo(BoardInfo boardInfo) {
|
||||
this.mBoardInfo = boardInfo;
|
||||
}
|
||||
|
||||
public void setConnected(boolean z) {
|
||||
this.connected = z;
|
||||
}
|
||||
|
||||
public void setCourseMission(JimuCourseMission jimuCourseMission) {
|
||||
this.courseMission = jimuCourseMission;
|
||||
}
|
||||
|
||||
public void setCourseTaskList(List<JimuCourseTask> list) {
|
||||
this.courseTaskList = list;
|
||||
}
|
||||
|
||||
public void setJimuCourse(JimuCourse jimuCourse) {
|
||||
this.jimuCourse = jimuCourse;
|
||||
}
|
||||
|
||||
public void setJimuCourseTask(JimuCourseTask jimuCourseTask) {
|
||||
this.jimuCourseTask = jimuCourseTask;
|
||||
}
|
||||
|
||||
public void setLastConnectedDevice(BluetoothDevice bluetoothDevice) {
|
||||
this.mLastConnectedDevice = bluetoothDevice;
|
||||
}
|
||||
|
||||
public void setPackageId(long j) {
|
||||
this.packageId = j;
|
||||
this.settings.put(SharePreferenceHelper.SP_KEY_PACKAGE_ID, Long.valueOf(j));
|
||||
}
|
||||
|
||||
public void setPackageImagePath(String str) {
|
||||
this.packageImagePath = str;
|
||||
this.settings.put(SharePreferenceHelper.CURRENT_PACKAGE_IMAGE_PATH, str);
|
||||
}
|
||||
|
||||
public void setPackageName(String str) {
|
||||
this.packageName = str;
|
||||
this.settings.put(SharePreferenceHelper.SP_KEY_PACKAGE_NAME, str);
|
||||
}
|
||||
|
||||
public void setRobot(Robot robot) {
|
||||
Robot robot2;
|
||||
if (robot == null) {
|
||||
return;
|
||||
}
|
||||
if (robot.getModelName() != null && (robot2 = this.robot) != null && robot2.getModelName() != null && !robot.getModelName().equals(this.robot.getModelName())) {
|
||||
JimuApplication.l().f().c();
|
||||
}
|
||||
this.robot = robot;
|
||||
this.settings.put(SharePreferenceHelper.SP_KEY_ROBOT_NAME, robot.getModelNameLanguage());
|
||||
this.settings.put(SharePreferenceHelper.SP_KEY_ROBOT_IMAGE, robot.getFilePath());
|
||||
this.settings.put(SharePreferenceHelper.SP_KEY_ROBOT_ID, Long.valueOf(robot.getModelId()));
|
||||
}
|
||||
|
||||
public void setShowMobileDataTips(boolean z) {
|
||||
this.showMobileDataTips = z;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
}
|
93
sources/com/ubt/jimu/base/cache/Constants.java
vendored
Normal file
93
sources/com/ubt/jimu/base/cache/Constants.java
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
package com.ubt.jimu.base.cache;
|
||||
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
|
||||
import com.ubt.jimu.unity.ModelType;
|
||||
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Constants {
|
||||
public static final String ADV_BEGIN_TIME = "adv_begin";
|
||||
public static final String ADV_END_TIME = "adv_end";
|
||||
public static final String ADV_FLAG = "adv_flag";
|
||||
public static final String ADV_IMG_PATH = "adv_img_path";
|
||||
public static final String ADV_LINK = "adv_link";
|
||||
public static final String ADV_TYPE = "adv_type";
|
||||
public static final String ADV_VERSION = "adv_version";
|
||||
public static final String APP_VERSION = "app_version";
|
||||
public static final String BLOCKLY_GUIDE = "blockly_guide";
|
||||
public static final String BLOCKLY_TYPE = "blockly_type";
|
||||
public static final String BLOCKLY_VERSION = "blockly_version";
|
||||
public static final String BLUETOOTH_AUTO_CONNECT = "bluetooth_auto_connect";
|
||||
public static final String COPY_LOCAL_CACHE_MODEL = "copy_cache_model";
|
||||
public static final String COPY_LOCAL_CACHE_MODEL_IMG = "copy_model_img";
|
||||
public static final String COURSE_RESOURCE_PATH = ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + "data" + File.separator + "blockly" + File.separator + "course_resources" + File.separator;
|
||||
public static final String COURSE_VERSION = "course_version";
|
||||
public static final String CURRENT_LANGUAGE = "current_language";
|
||||
public static final String CUSTOM_MODEL;
|
||||
public static final String CUSTOM_SOUNDS;
|
||||
public static final String DEFAULT_MODEL;
|
||||
public static final String DISABLE_WHILE_CHARGING = "disable_while_charging";
|
||||
public static final String FOO_FILE = "foo";
|
||||
public static final String HOME_BG_FILE_NAME = "home_image.png";
|
||||
public static final String IMAGE_PATH = "images";
|
||||
public static final String INSTRUCTION_CONFIG_FILE = "instruction";
|
||||
public static final String IS_PUSH_REGISTER = "is_push_register";
|
||||
public static final String IS_SHOW_GUIDE = "is_show_guide";
|
||||
public static final String KEY_COURSE_ALERT_LOGIN = "k_c_alert_login";
|
||||
public static final String KEY_COURSE_HAVE_PLAY_VIDEO = "k_c_played_video";
|
||||
public static final String KEY_DOWNLOAD_SERVOS = "key_download_servos";
|
||||
public static final String KEY_IS_ACTIVITY_FIRST_IN = "is_first_in_activity";
|
||||
public static final String KEY_IS_HOME_GUIDE_SHOWN = "is_home_guide_shown";
|
||||
public static final String KEY_MSG_DAILY_TASK = "k_task_daily";
|
||||
public static final String KEY_MSG_MAIN_TASK = "k_task_main";
|
||||
public static final String KEY_PROGRAM_LANGUAGE = "key_program_language";
|
||||
public static final String KEY_SHOULD_SHOW_LOW_END_DIALOG = "should_show_low_end_dialog";
|
||||
public static final String LANGUAGE = "language";
|
||||
public static final String LANGUAGE_SET = "language_set";
|
||||
public static final String LAST_LANGUAGE = "last_language";
|
||||
public static final String LOCAL_CACHE_MODEL_IMG = "local/";
|
||||
public static final String LOGIN = "login";
|
||||
public static final String LOGIN_TIME = "login_time";
|
||||
public static final String MAIN_BOARD_VERSION_CODE = "main_board_version_code";
|
||||
public static final String MAIN_BOARD_VERSION_FILE = "main_board_version_file";
|
||||
public static final long MEMORY_LIMIT = 1800000000;
|
||||
public static final String MERGE_FLAG = "merge_local_flag";
|
||||
public static final String MODEL_CLASS = "model_class";
|
||||
public static final String MODEL_CLASS_LOGO = "model_class_logo";
|
||||
public static final String PARTS = "parts/android/";
|
||||
public static final String PUSH_MSG = "push_msg";
|
||||
public static final String QINIU_TOKEN = "qiniu_token";
|
||||
public static final String REGISTER_DEVICEID = "register_deviceid";
|
||||
public static final String REGISTER_ONLY_EMAIL = "register_only_email";
|
||||
public static final String SENSOR_FILE_PATH = "FilePath";
|
||||
public static final String SENSOR_VERSION = "Version";
|
||||
public static final String STEERING_VERSION_CODE = "Steering_version_code";
|
||||
public static final String STEERING_VERSION_FILE = "Steering_version_file";
|
||||
public static final String UNITY_LANGUAGE_FILE = "LanguageCode";
|
||||
public static final String USER_HOME;
|
||||
public static final String USER_ID = "user_id";
|
||||
public static final String VIDEO_ADV_BEGIN_TIME = "adv_begin";
|
||||
public static final String VIDEO_ADV_END_TIME = "adv_end";
|
||||
public static final String VIDEO_ADV_FLAG = "adv_flag";
|
||||
public static final String VIDEO_ADV_IMG_PATH = "adv_img_path";
|
||||
public static final String VIDEO_ADV_LINK = "adv_link";
|
||||
public static final String VIDEO_ADV_VERSION = "adv_version";
|
||||
public static final String WECHAT_APP_ID = "wx2abcb6ca6e95847d";
|
||||
public static final String WECHAT_APP_SECRET = "d4624c36b6795d1d99dcf0547af5443d";
|
||||
public static final String WIFI_ONLY = "wifi_only";
|
||||
public static final String app_update_notify = "app_update";
|
||||
|
||||
static {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("users");
|
||||
sb.append(File.separator);
|
||||
sb.append("%s");
|
||||
sb.append(File.separator);
|
||||
USER_HOME = sb.toString();
|
||||
DEFAULT_MODEL = USER_HOME + "default" + File.separator;
|
||||
CUSTOM_MODEL = USER_HOME + "playerdata" + File.separator;
|
||||
CUSTOM_SOUNDS = USER_HOME + TransportFileDbHandler2.DIR_SOUNDS + File.separator;
|
||||
}
|
||||
}
|
302
sources/com/ubt/jimu/base/cache/SharePreferenceHelper.java
vendored
Normal file
302
sources/com/ubt/jimu/base/cache/SharePreferenceHelper.java
vendored
Normal file
@@ -0,0 +1,302 @@
|
||||
package com.ubt.jimu.base.cache;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubtech.utils.XLog;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.StreamCorruptedException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class SharePreferenceHelper<T> {
|
||||
public static final String AUTHOR_TOKEN = "author_token";
|
||||
public static final String CURRENT_PACKAGE_IMAGE_PATH = "current_package_image_path";
|
||||
public static final String KEY_SCAN_TIPS_READ = "scan_tips_read";
|
||||
private static final String SP_FILE_NAME_EXTRA = "file_extra";
|
||||
public static final String SP_FILE_NAME_SETTING = "setting";
|
||||
public static final String SP_FILE_NAME_USER = "file_user";
|
||||
public static final String SP_KEY_APP_CHECKED_UPDATE = "sp_key_app_checked_update";
|
||||
public static final String SP_KEY_APP_NEED_UPDATE = "sp_key_app_need_upadte";
|
||||
public static final String SP_KEY_APP_UPDATE_URL = "sp_key_app_update_url";
|
||||
public static final String SP_KEY_APP_VERSION_NAME = "sp_key_app_version_name";
|
||||
public static final String SP_KEY_AUTO_CONNECT = "auto_connect";
|
||||
public static final String SP_KEY_CONNECTION_STATUS = "jimu_robot_connection_status";
|
||||
public static final String SP_KEY_ELECTRICITY_PROTECT = "electricity_protect";
|
||||
public static final String SP_KEY_FLIPPER_PAGE_INDEX = "sp_key_flipper_page_index";
|
||||
public static final String SP_KEY_INFO_TO = "info_to";
|
||||
public static final String SP_KEY_LAST_PARENT_EMAIL = "sp_key_last_parent_email";
|
||||
public static final String SP_KEY_PACKAGE_ID = "sp_key_package_id";
|
||||
public static final String SP_KEY_PACKAGE_NAME = "sp_key_package_name";
|
||||
public static final String SP_KEY_REGISTER_ACCOUNT = "sp_key_register_account";
|
||||
public static final String SP_KEY_REGISTER_BIRTHDAY = "sp_key_register_birthday";
|
||||
public static final String SP_KEY_REGISTER_COUNTRY = "sp_key_register_country";
|
||||
public static final String SP_KEY_ROBOT_ID = "sp_key_robot_id";
|
||||
public static final String SP_KEY_ROBOT_IMAGE = "robot_image_url";
|
||||
public static final String SP_KEY_ROBOT_NAME = "robot_name";
|
||||
public static final String SP_KEY_SEARCH_HISTORY = "search_history";
|
||||
public static final String SP_KEY_START_FINISH_HOME_GUIDE = "sp_key_finish_home_guide";
|
||||
public static final String SP_KEY_START_FROM_SPLASH = "sp_key_start_from_splash";
|
||||
public static final String SP_KEY_USER_ID = "key_user_id";
|
||||
public static final String SP_KEY_UUID = "sp_key_uuid";
|
||||
public static final String SP_KEY_WIFI_VIEW = "wifi_view";
|
||||
private String setting;
|
||||
|
||||
public SharePreferenceHelper() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public Boolean getBoolean(String str, Boolean bool) {
|
||||
return Boolean.valueOf(JimuApplication.l().getSharedPreferences(this.setting, 0).getBoolean(str, bool.booleanValue()));
|
||||
}
|
||||
|
||||
public float getFloat(String str, float f) {
|
||||
return JimuApplication.l().getSharedPreferences(this.setting, 0).getFloat(str, f);
|
||||
}
|
||||
|
||||
public int getInt(String str, int i) {
|
||||
return JimuApplication.l().getSharedPreferences(this.setting, 0).getInt(str, i);
|
||||
}
|
||||
|
||||
public Long getLong(String str, Long l) {
|
||||
return Long.valueOf(JimuApplication.l().getSharedPreferences(this.setting, 0).getLong(str, l.longValue()));
|
||||
}
|
||||
|
||||
public String getString(String str, String str2) {
|
||||
return JimuApplication.l().getSharedPreferences(this.setting, 0).getString(str, str2);
|
||||
}
|
||||
|
||||
public void put(String str, Object obj) {
|
||||
SharedPreferences.Editor edit = JimuApplication.l().getSharedPreferences(this.setting, 4).edit();
|
||||
if (obj instanceof Boolean) {
|
||||
edit.putBoolean(str, ((Boolean) obj).booleanValue());
|
||||
} else if (obj instanceof Float) {
|
||||
edit.putFloat(str, ((Float) obj).floatValue());
|
||||
} else if (obj instanceof Integer) {
|
||||
edit.putInt(str, ((Integer) obj).intValue());
|
||||
} else if (obj instanceof Long) {
|
||||
edit.putLong(str, ((Long) obj).longValue());
|
||||
} else if (obj instanceof String) {
|
||||
edit.putString(str, (String) obj);
|
||||
}
|
||||
if (edit.commit()) {
|
||||
return;
|
||||
}
|
||||
XLog.b("SharePreferenceHelper", "commit SP failed!");
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Type inference failed for: r0v13, types: [T, java.lang.Object] */
|
||||
/* JADX WARN: Type inference failed for: r0v2 */
|
||||
/* JADX WARN: Type inference failed for: r0v3 */
|
||||
/* JADX WARN: Type inference failed for: r0v4, types: [T] */
|
||||
/* JADX WARN: Type inference failed for: r0v6 */
|
||||
/* JADX WARN: Type inference failed for: r0v7, types: [java.io.ObjectInputStream] */
|
||||
/* JADX WARN: Type inference failed for: r5v1, types: [boolean] */
|
||||
/* JADX WARN: Type inference failed for: r5v10, types: [java.io.ByteArrayInputStream] */
|
||||
/* JADX WARN: Type inference failed for: r5v12, types: [java.io.ByteArrayInputStream, java.io.InputStream] */
|
||||
/* JADX WARN: Type inference failed for: r5v2 */
|
||||
/* JADX WARN: Type inference failed for: r5v3 */
|
||||
/* JADX WARN: Type inference failed for: r5v4 */
|
||||
/* JADX WARN: Type inference failed for: r5v5, types: [java.io.ByteArrayInputStream] */
|
||||
/* JADX WARN: Type inference failed for: r5v8, types: [java.io.ByteArrayInputStream] */
|
||||
public T readObject(String str, String str2) {
|
||||
ObjectInputStream objectInputStream;
|
||||
String string = JimuApplication.l().getSharedPreferences(str, 0).getString(str2, "");
|
||||
?? isEmpty = TextUtils.isEmpty(string);
|
||||
?? r0 = (T) null;
|
||||
if (isEmpty != 0) {
|
||||
return null;
|
||||
}
|
||||
byte[] decode = Base64.decode(string.getBytes(), 0);
|
||||
try {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return (T) r0;
|
||||
}
|
||||
try {
|
||||
try {
|
||||
isEmpty = new ByteArrayInputStream(decode);
|
||||
} catch (StreamCorruptedException e2) {
|
||||
e = e2;
|
||||
objectInputStream = null;
|
||||
isEmpty = 0;
|
||||
} catch (IOException e3) {
|
||||
e = e3;
|
||||
objectInputStream = null;
|
||||
isEmpty = 0;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
isEmpty = 0;
|
||||
}
|
||||
try {
|
||||
objectInputStream = new ObjectInputStream(isEmpty);
|
||||
} catch (StreamCorruptedException e4) {
|
||||
e = e4;
|
||||
objectInputStream = null;
|
||||
} catch (IOException e5) {
|
||||
e = e5;
|
||||
objectInputStream = null;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
if (isEmpty != 0) {
|
||||
try {
|
||||
isEmpty.close();
|
||||
} catch (Exception e6) {
|
||||
e6.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (r0 == 0) {
|
||||
throw th;
|
||||
}
|
||||
try {
|
||||
r0.close();
|
||||
throw th;
|
||||
} catch (IOException e7) {
|
||||
e7.printStackTrace();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
try {
|
||||
try {
|
||||
r0 = (T) objectInputStream.readObject();
|
||||
try {
|
||||
isEmpty.close();
|
||||
} catch (Exception e8) {
|
||||
e8.printStackTrace();
|
||||
}
|
||||
try {
|
||||
objectInputStream.close();
|
||||
} catch (IOException e9) {
|
||||
e9.printStackTrace();
|
||||
}
|
||||
return r0;
|
||||
} catch (StreamCorruptedException e10) {
|
||||
e = e10;
|
||||
e.printStackTrace();
|
||||
if (isEmpty != 0) {
|
||||
try {
|
||||
isEmpty.close();
|
||||
} catch (Exception e11) {
|
||||
e11.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (objectInputStream != null) {
|
||||
objectInputStream.close();
|
||||
}
|
||||
return (T) r0;
|
||||
} catch (IOException e12) {
|
||||
e = e12;
|
||||
e.printStackTrace();
|
||||
if (isEmpty != 0) {
|
||||
try {
|
||||
isEmpty.close();
|
||||
} catch (Exception e13) {
|
||||
e13.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (objectInputStream != null) {
|
||||
objectInputStream.close();
|
||||
}
|
||||
return (T) r0;
|
||||
}
|
||||
} catch (ClassNotFoundException e14) {
|
||||
e14.printStackTrace();
|
||||
try {
|
||||
isEmpty.close();
|
||||
} catch (Exception e15) {
|
||||
e15.printStackTrace();
|
||||
}
|
||||
objectInputStream.close();
|
||||
return (T) r0;
|
||||
}
|
||||
} catch (Throwable th3) {
|
||||
r0 = (T) decode;
|
||||
th = th3;
|
||||
}
|
||||
}
|
||||
|
||||
public void saveObject(String str, String str2, Object obj) {
|
||||
ObjectOutputStream objectOutputStream;
|
||||
SharedPreferences sharedPreferences = JimuApplication.l().getSharedPreferences(str, 0);
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
ObjectOutputStream objectOutputStream2 = null;
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
|
||||
try {
|
||||
objectOutputStream.writeObject(obj);
|
||||
String encodeToString = Base64.encodeToString(byteArrayOutputStream.toByteArray(), 0);
|
||||
SharedPreferences.Editor edit = sharedPreferences.edit();
|
||||
edit.putString(str2, encodeToString);
|
||||
if (!edit.commit()) {
|
||||
XLog.b("SharePreferenceHelper", "commit SP failed!");
|
||||
}
|
||||
try {
|
||||
objectOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byteArrayOutputStream.close();
|
||||
} catch (IOException e2) {
|
||||
e = e2;
|
||||
objectOutputStream2 = objectOutputStream;
|
||||
e.printStackTrace();
|
||||
if (objectOutputStream2 != null) {
|
||||
try {
|
||||
objectOutputStream2.close();
|
||||
} catch (IOException e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
}
|
||||
byteArrayOutputStream.close();
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
if (objectOutputStream != null) {
|
||||
try {
|
||||
objectOutputStream.close();
|
||||
} catch (IOException e4) {
|
||||
e4.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
byteArrayOutputStream.close();
|
||||
throw th;
|
||||
} catch (IOException e5) {
|
||||
e5.printStackTrace();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
objectOutputStream = objectOutputStream2;
|
||||
}
|
||||
} catch (IOException e6) {
|
||||
e = e6;
|
||||
}
|
||||
} catch (IOException e7) {
|
||||
e7.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public SharePreferenceHelper(boolean z) {
|
||||
this.setting = z ? SP_FILE_NAME_USER : SP_FILE_NAME_SETTING;
|
||||
}
|
||||
|
||||
private SharePreferenceHelper(String str) {
|
||||
this.setting = str;
|
||||
}
|
||||
|
||||
public void saveObject(String str, Object obj) {
|
||||
saveObject(this.setting, str, obj);
|
||||
}
|
||||
|
||||
public T readObject(String str) {
|
||||
return readObject(this.setting, str);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user