From 1cfcfb90b89d16ae4a75fba02816e6439addf6c6 Mon Sep 17 00:00:00 2001 From: e <511455842@qq.com> Date: Fri, 2 Feb 2018 20:10:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E5=8F=8C=E5=BC=95?= =?UTF-8?q?=E5=8F=B7=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aria/build.gradle | 4 +-- .../main/java/com/arialyy/aria/core/Aria.java | 6 ---- .../java/com/arialyy/aria/orm/SqlHelper.java | 34 +++++++++++-------- .../simple/download/SingleTaskActivity.java | 4 +-- .../simple/upload/HttpUploadActivity.java | 11 +++--- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Aria/build.gradle b/Aria/build.gradle index f45db0b2..f95e9d8f 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -22,8 +22,8 @@ dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' -// compile project(':AriaAnnotations') - compile 'com.arialyy.aria:aria-ftp-plug:1.0.3' + compile project(':AriaAnnotations') +// compile 'com.arialyy.aria:aria-ftp-plug:1.0.3' compile project(':AriaFtpPlug') } diff --git a/Aria/src/main/java/com/arialyy/aria/core/Aria.java b/Aria/src/main/java/com/arialyy/aria/core/Aria.java index 011086ad..d6d681b7 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/Aria.java +++ b/Aria/src/main/java/com/arialyy/aria/core/Aria.java @@ -26,14 +26,8 @@ import android.app.Service; import android.content.Context; import android.os.Build; import android.widget.PopupWindow; -import com.arialyy.annotations.Download; -import com.arialyy.annotations.Upload; import com.arialyy.aria.core.download.DownloadReceiver; -import com.arialyy.aria.core.scheduler.IDownloadSchedulerListener; -import com.arialyy.aria.core.scheduler.ISchedulerListener; -import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.upload.UploadReceiver; -import com.arialyy.aria.core.upload.UploadTask; /** * Created by lyy on 2016/12/1. diff --git a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java index 3b75d256..72be07c5 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java @@ -23,20 +23,19 @@ import android.database.sqlite.SQLiteOpenHelper; import android.support.annotation.NonNull; import android.support.v4.util.LruCache; import android.text.TextUtils; -import android.util.Log; import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.CommonUtil; import java.lang.reflect.Field; import java.lang.reflect.Type; +import java.net.URLDecoder; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; /** * Created by lyy on 2015/11/2. @@ -204,7 +203,7 @@ final class SqlHelper extends SQLiteOpenHelper { sql = sql.replace("?", "%s"); Object[] params = new String[expression.length - 1]; for (int i = 0, len = params.length; i < len; i++) { - params[i] = "\"" + expression[i + 1] + "\""; + params[i] = "'" + expression[i + 1] + "'"; } sql = String.format(sql, params); print(FIND_DATA, sql); @@ -227,7 +226,7 @@ final class SqlHelper extends SQLiteOpenHelper { sql = sql.replace("?", "%s"); Object[] params = new String[expression.length - 1]; for (int i = 0, len = params.length; i < len; i++) { - params[i] = "\"" + expression[i + 1] + "\""; + params[i] = "'" + checkValue(expression[i + 1]) + "'"; } sql = String.format(sql, params); print(FIND_DATA, sql); @@ -269,7 +268,7 @@ final class SqlHelper extends SQLiteOpenHelper { sb.append("SELECT rowid, * FROM ").append(CommonUtil.getClassName(clazz)).append(" where "); int i = 0; for (Object where : wheres) { - sb.append(where).append("=").append("\"").append(values[i]).append("\""); + sb.append(where).append("=").append("'").append(checkValue(values[i])).append("'"); sb.append(i >= wheres.length - 1 ? "" : " AND "); i++; } @@ -281,6 +280,13 @@ final class SqlHelper extends SQLiteOpenHelper { return data; } + private static String checkValue(String value) { + if (value.contains("'")) { + return URLEncoder.encode(value); + } + return value; + } + /** * 查找表的所有数据 */ @@ -319,7 +325,7 @@ final class SqlHelper extends SQLiteOpenHelper { sql = sql.replace("?", "%s"); Object[] params = new String[expression.length - 1]; for (int i = 0, len = params.length; i < len; i++) { - params[i] = "\"" + expression[i + 1] + "\""; + params[i] = "'" + expression[i + 1] + "'"; } sql = String.format(sql, params); SqlHelper.print(DEL_DATA, sql); @@ -362,7 +368,7 @@ final class SqlHelper extends SQLiteOpenHelper { //sb.append(field.getName()).append("='"); String value; prams.append(i > 0 ? ", " : ""); - prams.append(field.getName()).append("=\""); + prams.append(field.getName()).append("='"); Type type = field.getType(); if (type == Map.class) { value = SqlUtil.map2Str((Map) field.get(dbEntity)); @@ -376,13 +382,13 @@ final class SqlHelper extends SQLiteOpenHelper { value = SqlUtil.getOneToOneParams(field); } else { Object obj = field.get(dbEntity); - value = obj == null ? "" : obj.toString(); + value = obj == null ? "" : checkValue(obj.toString()); } //sb.append(value == null ? "" : value); //sb.append("'"); prams.append(TextUtils.isEmpty(value) ? "" : value); - prams.append("\""); + prams.append("'"); } catch (IllegalAccessException e) { e.printStackTrace(); } @@ -432,7 +438,7 @@ final class SqlHelper extends SQLiteOpenHelper { continue; } sb.append(i > 0 ? ", " : ""); - sb.append("\""); + sb.append("'"); Type type = field.getType(); if (type == Map.class) { sb.append(SqlUtil.map2Str((Map) field.get(dbEntity))); @@ -445,9 +451,9 @@ final class SqlHelper extends SQLiteOpenHelper { } else if (SqlUtil.isOneToOne(field)) { sb.append(SqlUtil.getOneToOneParams(field)); } else { - sb.append(field.get(dbEntity)); + sb.append(checkValue(field.get(dbEntity).toString())); } - sb.append("\""); + sb.append("'"); i++; } } catch (IllegalAccessException e) { @@ -639,7 +645,7 @@ final class SqlHelper extends SQLiteOpenHelper { int column = cursor.getColumnIndex(field.getName()); if (column == -1) continue; if (type == String.class) { - field.set(entity, cursor.getString(column)); + field.set(entity, URLDecoder.decode(cursor.getString(column))); } else if (type == int.class || type == Integer.class) { field.setInt(entity, cursor.getInt(column)); } else if (type == float.class || type == Float.class) { diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index 275f83c2..18123af9 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -58,8 +58,8 @@ public class SingleTaskActivity extends BaseActivity { //"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-"; //"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk"; //"http://qudao.5535.cn/one/game.html?game=531&cpsuser=xiaoeryu2"; - //"https://bogoe-res.mytbz.com/tbzengsong/If You're Happy.mp3"; - "http://ozr0ucjs5.bkt.clouddn.com/51_box-104_20180131202610.apk"; + "https://bogoe-res.mytbz.com/tbzengsong/If You're Happy.mp3"; + //"http://ozr0ucjs5.bkt.clouddn.com/51_box-104_20180131202610.apk"; @Bind(R.id.start) Button mStart; @Bind(R.id.stop) Button mStop; @Bind(R.id.cancel) Button mCancel; diff --git a/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java b/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java index 9ebb8d56..2cd63cc8 100644 --- a/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java +++ b/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java @@ -17,7 +17,6 @@ package com.arialyy.simple.upload; import android.os.Bundle; -import android.util.Log; import butterknife.Bind; import butterknife.OnClick; import com.arialyy.annotations.Upload; @@ -36,7 +35,7 @@ public class HttpUploadActivity extends BaseActivity { private static final String TAG = "HttpUploadActivity"; @Bind(R.id.pb) HorizontalProgressBarWithNumber mPb; - private static final String FILE_PATH = "/mnt/sdcard/gg.zip"; + private static final String FILE_PATH = "/mnt/sdcard/360sicheck.txt"; @Override protected int setLayoutId() { return R.layout.activity_upload; @@ -51,8 +50,10 @@ public class HttpUploadActivity extends BaseActivity { @OnClick(R.id.upload) void upload() { Aria.upload(HttpUploadActivity.this) .load(FILE_PATH) - .setUploadUrl("http://192.168.1.9:8080/upload/") - .setAttachment("serveFile") + .setUploadUrl( + "http://lib-test.xzxyun.com:8042/Api/upload?data={\"type\":\"1\",\"fileType\":\".txt\"}") + .setAttachment("file") + .addHeader("iplanetdirectorypro", "") .start(); } @@ -64,7 +65,6 @@ public class HttpUploadActivity extends BaseActivity { Aria.upload(this).load(FILE_PATH).cancel(); } - @Upload.onPre public void onPre(UploadTask task) { } @@ -88,6 +88,7 @@ public class HttpUploadActivity extends BaseActivity { @Upload.onTaskRunning public void taskRunning(UploadTask task) { getBinding().setSpeed(task.getConvertSpeed()); getBinding().setProgress(task.getPercent()); + L.d(TAG, "P => " + task.getPercent()); } @Upload.onTaskComplete public void taskComplete(UploadTask task) {