catch some exceptions
MODIFY
bither-android/res/layout/activity_ad.xml
bither-android/res/layout/activity_ad.xml
android:text="@string/ad_go"
android:onClick="btnGoOnClick"
android:textColor="@color/white"
+ android:visibility="gone"
android:textSize="22sp" />
<Button

MODIFY
bither-android/src/net/bither/AdActivity.java
bither-android/src/net/bither/AdActivity.java
@@ -99,12 +99,20 @@ public class AdActivity extends Activity {
}
private void setAdUrl() {
+ try {
File file = FileUtil.getAdFile();
+ if (file == null) {
+ return;
+ }
+ if (FileUtil.deserialize(file) instanceof String) {
String adStr = (String) FileUtil.deserialize(file);
- try {
JSONObject jsonObject = new JSONObject(adStr);
url = jsonObject.getString("url");
- } catch (JSONException e) {
+ if (url != null) {
+ btnGo.setVisibility(View.VISIBLE);
+ }
+ }
+ } catch (Exception e) {
e.printStackTrace();
}
}

MODIFY
bither-android/src/net/bither/model/PriceAlert.java
bither-android/src/net/bither/model/PriceAlert.java
@@ -148,11 +148,20 @@ public class PriceAlert implements Serializable {
}
private static List<PriceAlert> getPriceAlertFromFile() {
+ try {
File file = FileUtil.getPriceAlertFile();
- List<PriceAlert> priceAlertList = (List<PriceAlert>) FileUtil.deserialize(file);
+ List<PriceAlert> priceAlertList = new ArrayList<>();
+ if (file == null) {
+ return priceAlertList;
+ }
+ priceAlertList = (List<PriceAlert>) FileUtil.deserialize(file);
if (priceAlertList == null) {
- priceAlertList = new ArrayList<PriceAlert>();
+ priceAlertList = new ArrayList<>();
}
return priceAlertList;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new ArrayList<>();
+ }
}
}

MODIFY
bither-android/src/net/bither/ui/base/MarketListHeader.java
bither-android/src/net/bither/ui/base/MarketListHeader.java
@@ -385,7 +385,9 @@ public class MarketListHeader extends FrameLayout implements MarketTickerChanged
if (isShowing()) {
imm.hideSoftInputFromWindow(etAlertHigh.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
+ if (this != null) {
ObjectAnimator.ofInt(this, "bottom", 0).setDuration(AnimDuration).start();
+ }
etAlertLow.clearFocus();
etAlertHigh.clearFocus();
}

MODIFY
bither-android/src/net/bither/util/AdUtil.java
bither-android/src/net/bither/util/AdUtil.java
@@ -64,18 +64,15 @@ public class AdUtil {
}
public static JSONObject getCacheAdJSON() {
+ try {
File file = FileUtil.getAdFile();
String adStr = (String) FileUtil.deserialize(file);
- if (adStr != null) {
- try {
JSONObject jsonObject = new JSONObject(adStr);
- if (jsonObject != null) {
return jsonObject;
- }
} catch (JSONException e) {
e.printStackTrace();
- return null;
- }
+ } catch (Exception e) {
+ e.printStackTrace();
}
return null;
}

MODIFY
bither-android/src/net/bither/util/DepthUtil.java
bither-android/src/net/bither/util/DepthUtil.java
@@ -27,13 +27,21 @@ public class DepthUtil {
private static List<Depth> depths = init();
private static List<Depth> init() {
+ try {
File file = FileUtil.getDepthFile();
+ if (file == null) {
+ return new ArrayList<>();
+ }
@SuppressWarnings("unchecked")
List<Depth> depths = (List<Depth>) FileUtil.deserialize(file);
if (depths == null) {
- depths = new ArrayList<Depth>();
+ depths = new ArrayList<>();
}
return depths;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return new ArrayList<>();
}
public static Depth getKDepth(MarketType marketType) {

MODIFY
bither-android/src/net/bither/util/FileUtil.java
bither-android/src/net/bither/util/FileUtil.java
@@ -283,7 +283,6 @@ public class FileUtil {
@SuppressWarnings("resource")
public static Object deserialize(File file) {
- Object object = new Object();
FileInputStream fos = null;
try {
if (!file.exists()) {
@@ -292,25 +291,20 @@ public class FileUtil {
fos = new FileInputStream(file);
ObjectInputStream ois;
ois = new ObjectInputStream(fos);
- object = ois.readObject();
-
+ Object object = ois.readObject();
+ return object;
} catch (Exception e) {
e.printStackTrace();
return null;
-
} finally {
try {
if (fos != null) {
fos.close();
}
-
} catch (IOException e) {
e.printStackTrace();
}
-
}
-
- return object;
}
public static void serializeObject(File file, Object object) {

MODIFY
bither-android/src/net/bither/util/KLineUtil.java
bither-android/src/net/bither/util/KLineUtil.java
@@ -28,13 +28,21 @@ public class KLineUtil {
private static List<KLine> kLines = init();
private static List<KLine> init() {
+ try {
File file = FileUtil.getKlineFile();
+ if (file == null) {
+ return new ArrayList<>();
+ }
@SuppressWarnings("unchecked")
List<KLine> kLines = (List<KLine>) FileUtil.deserialize(file);
if (kLines == null) {
- kLines = new ArrayList<KLine>();
+ kLines = new ArrayList<>();
}
return kLines;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return new ArrayList<>();
}
public static KLine getKLine(MarketType marketType,

MODIFY
bither-android/src/net/bither/util/UpgradeUtil.java
bither-android/src/net/bither/util/UpgradeUtil.java
@@ -248,24 +248,34 @@ public class UpgradeUtil {
}
private static List<String> readPrivateAddressSequence() {
+ try {
File file = getWarmPrivateAddressSequenceFile();
- if (file.exists()) {
+ if (file != null && file.exists()) {
ArrayList<String> addresses = (ArrayList<String>) FileUtil
.deserialize(file);
return addresses;
} else {
return null;
}
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
}
private static List<String> readWatchOnlyAddressSequence() {
+ try {
File file = getWatchOnlyAddressSequenceFile();
- if (file.exists()) {
+ if (file != null && file.exists()) {
ArrayList<String> addresses = (ArrayList<String>) FileUtil
.deserialize(file);
return addresses;
} else {
return null;
}
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
}
}

MODIFY
bitherj
bitherj
-Subproject commit 880df8e5af5a7f040fc6720e4d0534bc37a571e6
+Subproject commit 0d28837e6849d51212c0bd2bfd43db14f9de8b03

catch some exceptions