pull/330/head
e 7 years ago
parent 754e23a2f2
commit 75421b92c4
  1. 17
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java
  2. 16
      Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
  3. 3
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java

@ -63,6 +63,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
*/ */
private static final long SUB_LEN = 1024 * 1024; private static final long SUB_LEN = 1024 * 1024;
private Timer mTimer; private Timer mTimer;
private long mUpdateInterval = 1000;
protected AbsFileer(IEventListener listener, TASK_ENTITY taskEntity) { protected AbsFileer(IEventListener listener, TASK_ENTITY taskEntity) {
mListener = listener; mListener = listener;
@ -145,7 +146,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
mListener.onProgress(mConstance.CURRENT_LOCATION); mListener.onProgress(mConstance.CURRENT_LOCATION);
} }
} }
}, 0, 1000); }, 0, mUpdateInterval);
} }
protected void closeTimer() { protected void closeTimer() {
@ -156,6 +157,20 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
} }
} }
/**
* 设置定时器更新间隔
*
* @param interval 单位毫秒不能小于0
*/
protected long setUpdateInterval(long interval) {
if (interval < 0) {
ALog.w(TAG, "更新间隔不能小于0,默认为1000毫秒");
return 1000;
}
mUpdateInterval = interval;
return interval;
}
@Override public long getFileSize() { @Override public long getFileSize() {
return mEntity.getFileSize(); return mEntity.getFileSize();
} }

@ -200,7 +200,7 @@ final class SqlHelper extends SQLiteOpenHelper {
sql = sql.replace("?", "%s"); sql = sql.replace("?", "%s");
Object[] params = new String[expression.length - 1]; Object[] params = new String[expression.length - 1];
for (int i = 0, len = params.length; i < len; i++) { 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); sql = String.format(sql, params);
print(FIND_DATA, sql); print(FIND_DATA, sql);
@ -223,7 +223,7 @@ final class SqlHelper extends SQLiteOpenHelper {
sql = sql.replace("?", "%s"); sql = sql.replace("?", "%s");
Object[] params = new String[expression.length - 1]; Object[] params = new String[expression.length - 1];
for (int i = 0, len = params.length; i < len; i++) { 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); sql = String.format(sql, params);
print(FIND_DATA, sql); print(FIND_DATA, sql);
@ -265,7 +265,7 @@ final class SqlHelper extends SQLiteOpenHelper {
sb.append("SELECT rowid, * FROM ").append(CommonUtil.getClassName(clazz)).append(" where "); sb.append("SELECT rowid, * FROM ").append(CommonUtil.getClassName(clazz)).append(" where ");
int i = 0; int i = 0;
for (Object where : wheres) { for (Object where : wheres) {
sb.append(where).append("=").append("'").append(values[i]).append("'"); sb.append(where).append("=").append("\"").append(values[i]).append("\"");
sb.append(i >= wheres.length - 1 ? "" : " AND "); sb.append(i >= wheres.length - 1 ? "" : " AND ");
i++; i++;
} }
@ -315,7 +315,7 @@ final class SqlHelper extends SQLiteOpenHelper {
sql = sql.replace("?", "%s"); sql = sql.replace("?", "%s");
Object[] params = new String[expression.length - 1]; Object[] params = new String[expression.length - 1];
for (int i = 0, len = params.length; i < len; i++) { 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); sql = String.format(sql, params);
SqlHelper.print(DEL_DATA, sql); SqlHelper.print(DEL_DATA, sql);
@ -350,7 +350,7 @@ final class SqlHelper extends SQLiteOpenHelper {
//sb.append(field.getName()).append("='"); //sb.append(field.getName()).append("='");
String value; String value;
prams.append(i > 0 ? ", " : ""); prams.append(i > 0 ? ", " : "");
prams.append(field.getName()).append("='"); prams.append(field.getName()).append("=\"");
Type type = field.getType(); Type type = field.getType();
if (type == Map.class) { if (type == Map.class) {
value = SqlUtil.map2Str((Map<String, String>) field.get(dbEntity)); value = SqlUtil.map2Str((Map<String, String>) field.get(dbEntity));
@ -370,7 +370,7 @@ final class SqlHelper extends SQLiteOpenHelper {
//sb.append(value == null ? "" : value); //sb.append(value == null ? "" : value);
//sb.append("'"); //sb.append("'");
prams.append(TextUtils.isEmpty(value) ? "" : value); prams.append(TextUtils.isEmpty(value) ? "" : value);
prams.append("'"); prams.append("\"");
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -415,7 +415,7 @@ final class SqlHelper extends SQLiteOpenHelper {
continue; continue;
} }
sb.append(i > 0 ? ", " : ""); sb.append(i > 0 ? ", " : "");
sb.append("'"); sb.append("\"");
Type type = field.getType(); Type type = field.getType();
if (type == Map.class) { if (type == Map.class) {
sb.append(SqlUtil.map2Str((Map<String, String>) field.get(dbEntity))); sb.append(SqlUtil.map2Str((Map<String, String>) field.get(dbEntity)));
@ -430,7 +430,7 @@ final class SqlHelper extends SQLiteOpenHelper {
} else { } else {
sb.append(field.get(dbEntity)); sb.append(field.get(dbEntity));
} }
sb.append("'"); sb.append("\"");
i++; i++;
} }
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {

@ -62,7 +62,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
//不支持断点的链接 //不支持断点的链接
//"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-"; //"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://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk";
"http://qudao.5535.cn/one/game.html?game=531&cpsuser=xiaoeryu2"; //"http://qudao.5535.cn/one/game.html?game=531&cpsuser=xiaoeryu2";
"https://bogoe-res.mytbz.com/tbzengsong/If You're Happy.mp3";
@Bind(R.id.start) Button mStart; @Bind(R.id.start) Button mStart;
@Bind(R.id.stop) Button mStop; @Bind(R.id.stop) Button mStop;
@Bind(R.id.cancel) Button mCancel; @Bind(R.id.cancel) Button mCancel;

Loading…
Cancel
Save