Skip to content

Commit

Permalink
#32 Fixed umeng empty novel string exception
Browse files Browse the repository at this point in the history
Signed-off-by: MewX <xiayuanzhong@gmail.com>
  • Loading branch information
MewX committed Nov 3, 2018
1 parent 8b7ec6b commit 0642112
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.mewx.wenku8.util;

import android.support.test.filters.SmallTest;

import org.junit.Test;

import static org.junit.Assert.*;

@SmallTest
public class LightToolTest {

@Test
public void isInteger() {
// true cases
assertTrue(LightTool.isInteger("0"));
assertTrue(LightTool.isInteger("1"));

// false cases
assertFalse(LightTool.isInteger(""));
assertFalse(LightTool.isInteger("1.0"));
assertFalse(LightTool.isInteger("1.."));
assertFalse(LightTool.isInteger("a"));
}

@Test
public void isDouble() {
// true
assertTrue(LightTool.isDouble("0.0"));
assertTrue(LightTool.isDouble("1.0"));
assertTrue(LightTool.isDouble("-1.0000009"));

// false
assertFalse(LightTool.isDouble(""));
assertFalse(LightTool.isDouble("0"));
assertFalse(LightTool.isDouble("1"));
assertFalse(LightTool.isDouble("-1..0000009"));
assertFalse(LightTool.isDouble("a"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ else if(mLoader.getCurrentType() == WenkuReaderLoader.ElementType.IMAGE_DEPENDEN
break;
}
mLoader.setCurrentIndex(++ curLineIndex);
continue;
}
WenkuReaderLoader.ElementType type = mLoader.getCurrentType();
String temp = mLoader.getCurrentAsString().charAt(curWordIndex) + "";
int tempWidth = (int) textPaint.measureText(temp);

Expand Down Expand Up @@ -677,14 +677,6 @@ protected Wenku8Error.ErrorCode doInBackground(BitmapInfo... params) {
protected void onPostExecute(Wenku8Error.ErrorCode errorCode) {
super.onPostExecute(errorCode);

// RelativeLayout rl = (RelativeLayout) getParent();
// ImageView imageView = new ImageView(getContext());
// RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(bi_bak.width, bi_bak.height);
// lp.setMargins(bi_bak.x_beg, bi_bak.y_beg, 0, 0);
// if(rl == null || imageView == null) return; // ??
// rl.addView(imageView, lp);
// imageView.setImageBitmap(bi_bak.bm);

if(errorCode == Wenku8Error.ErrorCode.SYSTEM_1_SUCCEEDED)
WenkuReaderPageView.this.postInvalidate();
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.support.annotation.NonNull;
import android.view.Display;
import android.view.WindowManager;

Expand All @@ -16,7 +17,7 @@
public class LightTool {

/* Number related useful functions */
public static boolean isInteger(String value) {
public static boolean isInteger(@NonNull String value) {
try {
Integer.parseInt(value);
return true;
Expand All @@ -25,12 +26,10 @@ public static boolean isInteger(String value) {
}
}

public static boolean isDouble(String value) {
public static boolean isDouble(@NonNull String value) {
try {
Double.parseDouble(value);
if (value.contains("."))
return true;
return false;
return value.contains(".");
} catch (NumberFormatException e) {
return false;
}
Expand Down

0 comments on commit 0642112

Please sign in to comment.