diff --git a/app/src/main/java/com/hippo/effect/ripple/RippleSalon.java b/app/src/main/java/com/hippo/effect/ripple/RippleSalon.java index 34cca4667..1fb523cf0 100644 --- a/app/src/main/java/com/hippo/effect/ripple/RippleSalon.java +++ b/app/src/main/java/com/hippo/effect/ripple/RippleSalon.java @@ -15,7 +15,6 @@ package com.hippo.effect.ripple; -import android.annotation.TargetApi; import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.Color; @@ -30,9 +29,6 @@ import com.hippo.widget.HotspotTouchHelper; public final class RippleSalon { - private static final boolean USE_OLD_RIPPLE = - Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP; - private static final Drawable MASK = new ColorDrawable(Color.BLACK); public static void addRipple(View c, boolean dark) { @@ -46,9 +42,8 @@ public final class RippleSalon { addRipple(v, color, v.getBackground()); } - @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void addRipple(View v, ColorStateList color, Drawable content) { - if (USE_OLD_RIPPLE) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { RippleDrawable rippleDrawable = new RippleDrawable(color, content); v.setOnTouchListener(new HotspotTouchHelper(rippleDrawable)); //noinspection deprecation diff --git a/app/src/main/java/com/hippo/network/HttpHelper.java b/app/src/main/java/com/hippo/network/HttpHelper.java index d5f1e2f02..f02ab6cbc 100644 --- a/app/src/main/java/com/hippo/network/HttpHelper.java +++ b/app/src/main/java/com/hippo/network/HttpHelper.java @@ -489,7 +489,7 @@ public class HttpHelper { } public static class PostFormDataHelper extends GetStringHelper { - private static final String BOUNDARY = "------WebKitFormBoundary7eDB0hDQ91s22Tkf"; + private static final String BOUNDARY = "----WebKitFormBoundary7eDB0hDQ91s22Tkf"; private final List mDataList; @@ -507,15 +507,17 @@ public class HttpHelper { conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", - "multipart/form-data; boundary=----WebKitFormBoundary7eDB0hDQ91s22Tkf"); + "multipart/form-data; boundary=" + BOUNDARY); DataOutputStream out = new DataOutputStream(conn.getOutputStream()); for (FormData data : mDataList) { + out.write("--".getBytes()); out.write(BOUNDARY.getBytes()); out.write("\r\n".getBytes()); data.doOutPut(out); } + out.write("--".getBytes()); out.write(BOUNDARY.getBytes()); out.write("--".getBytes()); @@ -549,7 +551,6 @@ public class HttpHelper { // Bitmap bmp = BitmapFactory.decodeStream(conn.getInputStream(), null, Ui.getBitmapOpt()); // bitmap might be incomplete. int size = conn.getContentLength(); - ByteArrayOutputStream a; FastByteArrayOutputStream fbaos = new FastByteArrayOutputStream(size == -1 ? 24 * 1024 : (size + 100)); Utils.copy(conn.getInputStream(), fbaos); Bitmap bmp = BitmapFactory.decodeByteArray(fbaos.getBuffer(), 0, fbaos.size(), null); diff --git a/app/src/main/java/com/hippo/util/Log.java b/app/src/main/java/com/hippo/util/Log.java index 7d23f3268..110916604 100644 --- a/app/src/main/java/com/hippo/util/Log.java +++ b/app/src/main/java/com/hippo/util/Log.java @@ -21,7 +21,7 @@ public class Log { private static final String TAG = Log.class.getSimpleName(); - private static final String avoidNull(String str) { + private static String avoidNull(String str) { return str == null ? TextUtils.STRING_NULL : str; } @@ -47,6 +47,15 @@ public class Log { } } + /** + * Call {@link android.util.Log#v(String, String, Throwable)} with default tag. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int v(String msg, Throwable tr) { + return v(TAG, msg, tr); + } + /** * It is {@link android.util.Log#v(String, String, Throwable)}, only work when debug. * @param tag Used to identify the source of a log message. It usually identifies @@ -84,6 +93,15 @@ public class Log { } } + /** + * Call {@link android.util.Log#d(String, String, Throwable)} with default tag. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int d(String msg, Throwable tr) { + return d(TAG, msg, tr); + } + /** * It is {@link android.util.Log#d(String, String, Throwable)}, only work when debug. * @param tag Used to identify the source of a log message. It usually identifies @@ -121,6 +139,15 @@ public class Log { } } + /** + * Call {@link android.util.Log#i(String, String, Throwable)} with default tag. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int i(String msg, Throwable tr) { + return i(TAG, msg, tr); + } + /** * It is {@link android.util.Log#i(String, String, Throwable)}, only work when debug. * @param tag Used to identify the source of a log message. It usually identifies @@ -158,6 +185,15 @@ public class Log { } } + /** + * Call {@link android.util.Log#w(String, String, Throwable)} with default tag. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int w(String msg, Throwable tr) { + return w(TAG, msg, tr); + } + /** * It is {@link android.util.Log#w(String, String, Throwable)}, only work when debug. * @param tag Used to identify the source of a log message. It usually identifies @@ -173,20 +209,6 @@ public class Log { } } - /** - * It is {@link android.util.Log#w(String, Throwable)}, only work when debug. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param tr An exception to log - */ - public static int w(String tag, Throwable tr) { - if (BuildConfig.DEBUG) { - return android.util.Log.w(tag, tr); - } else { - return 0; - } - } - /** * Call {@link android.util.Log#e(String, String)} with default tag. * @param msg The message you would like logged. @@ -209,6 +231,15 @@ public class Log { } } + /** + * Call {@link android.util.Log#e(String, String, Throwable)} with default tag. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int e(String msg, Throwable tr) { + return e(TAG, msg, tr); + } + /** * It is {@link android.util.Log#e(String, String, Throwable)}, only work when debug. * @param tag Used to identify the source of a log message. It usually identifies