|
|
@ -30,12 +30,15 @@ import com.arialyy.aria.core.command.ICmd; |
|
|
|
import com.arialyy.aria.core.common.QueueMod; |
|
|
|
import com.arialyy.aria.core.common.QueueMod; |
|
|
|
import com.arialyy.aria.core.download.DownloadEntity; |
|
|
|
import com.arialyy.aria.core.download.DownloadEntity; |
|
|
|
import com.arialyy.aria.core.download.DownloadGroupEntity; |
|
|
|
import com.arialyy.aria.core.download.DownloadGroupEntity; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; |
|
|
|
import com.arialyy.aria.core.download.DownloadReceiver; |
|
|
|
import com.arialyy.aria.core.download.DownloadReceiver; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.download.DownloadTaskEntity; |
|
|
|
import com.arialyy.aria.core.inf.AbsReceiver; |
|
|
|
import com.arialyy.aria.core.inf.AbsReceiver; |
|
|
|
import com.arialyy.aria.core.inf.IReceiver; |
|
|
|
import com.arialyy.aria.core.inf.IReceiver; |
|
|
|
import com.arialyy.aria.core.inf.ReceiverType; |
|
|
|
import com.arialyy.aria.core.inf.ReceiverType; |
|
|
|
import com.arialyy.aria.core.upload.UploadEntity; |
|
|
|
import com.arialyy.aria.core.upload.UploadEntity; |
|
|
|
import com.arialyy.aria.core.upload.UploadReceiver; |
|
|
|
import com.arialyy.aria.core.upload.UploadReceiver; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.upload.UploadTaskEntity; |
|
|
|
import com.arialyy.aria.orm.DbEntity; |
|
|
|
import com.arialyy.aria.orm.DbEntity; |
|
|
|
import com.arialyy.aria.orm.DelegateWrapper; |
|
|
|
import com.arialyy.aria.orm.DelegateWrapper; |
|
|
|
import com.arialyy.aria.util.ALog; |
|
|
|
import com.arialyy.aria.util.ALog; |
|
|
@ -82,6 +85,7 @@ import org.xml.sax.SAXException; |
|
|
|
regAppLifeCallback(context); |
|
|
|
regAppLifeCallback(context); |
|
|
|
initConfig(); |
|
|
|
initConfig(); |
|
|
|
initAria(); |
|
|
|
initAria(); |
|
|
|
|
|
|
|
amendTaskState(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static AriaManager getInstance(Context context) { |
|
|
|
public static AriaManager getInstance(Context context) { |
|
|
@ -94,9 +98,6 @@ import org.xml.sax.SAXException; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static AriaManager getInstance() { |
|
|
|
static AriaManager getInstance() { |
|
|
|
//if (INSTANCE == null) {
|
|
|
|
|
|
|
|
// throw new NullPointerException("请在Application或Activity初始化时调用一次Aria.init(context)方法进行初始化操作");
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
return INSTANCE; |
|
|
|
return INSTANCE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -121,6 +122,21 @@ import org.xml.sax.SAXException; |
|
|
|
mAConfig.setLogLevel(mAConfig.getLogLevel()); |
|
|
|
mAConfig.setLogLevel(mAConfig.getLogLevel()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 修正任务状态 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void amendTaskState() { |
|
|
|
|
|
|
|
Class[] clazzs = new Class[] { |
|
|
|
|
|
|
|
DownloadEntity.class, UploadEntity.class, DownloadGroupEntity.class, |
|
|
|
|
|
|
|
DownloadTaskEntity.class, UploadTaskEntity.class, DownloadGroupTaskEntity.class |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
String sql = "UPDATE %s SET state=2 WHERE state=4"; |
|
|
|
|
|
|
|
for (Class clazz : clazzs) { |
|
|
|
|
|
|
|
String temp = String.format(sql, clazz.getSimpleName()); |
|
|
|
|
|
|
|
DbEntity.exeSql(temp); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Map<String, AbsReceiver> getReceiver() { |
|
|
|
public Map<String, AbsReceiver> getReceiver() { |
|
|
|
return mReceivers; |
|
|
|
return mReceivers; |
|
|
|
} |
|
|
|
} |
|
|
@ -136,8 +152,7 @@ import org.xml.sax.SAXException; |
|
|
|
* @param mod {@link QueueMod} |
|
|
|
* @param mod {@link QueueMod} |
|
|
|
* @deprecated 后续版本会删除该api |
|
|
|
* @deprecated 后续版本会删除该api |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Deprecated |
|
|
|
@Deprecated public AriaManager setUploadQueueMod(QueueMod mod) { |
|
|
|
public AriaManager setUploadQueueMod(QueueMod mod) { |
|
|
|
|
|
|
|
mUConfig.setQueueMod(mod.tag); |
|
|
|
mUConfig.setQueueMod(mod.tag); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
@ -153,8 +168,7 @@ import org.xml.sax.SAXException; |
|
|
|
* @param mod {@link QueueMod} |
|
|
|
* @param mod {@link QueueMod} |
|
|
|
* @deprecated 后续版本会删除该api |
|
|
|
* @deprecated 后续版本会删除该api |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Deprecated |
|
|
|
@Deprecated public AriaManager setDownloadQueueMod(QueueMod mod) { |
|
|
|
public AriaManager setDownloadQueueMod(QueueMod mod) { |
|
|
|
|
|
|
|
mDConfig.setQueueMod(mod.tag); |
|
|
|
mDConfig.setQueueMod(mod.tag); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
@ -351,7 +365,8 @@ import org.xml.sax.SAXException; |
|
|
|
* |
|
|
|
* |
|
|
|
* @param type {@link ReceiverType} |
|
|
|
* @param type {@link ReceiverType} |
|
|
|
* @param obj 观察者对象 |
|
|
|
* @param obj 观察者对象 |
|
|
|
* @return key的格式为:{@code String.format("%s_%s_%s", obj.getClass().getName(), type, obj.hashCode());} |
|
|
|
* @return key的格式为:{@code String.format("%s_%s_%s", obj.getClass().getName(), type, |
|
|
|
|
|
|
|
* obj.hashCode());} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private String createKey(@ReceiverType String type, Object obj) { |
|
|
|
private String createKey(@ReceiverType String type, Object obj) { |
|
|
|
return String.format("%s_%s_%s", obj.getClass().getName(), type, obj.hashCode()); |
|
|
|
return String.format("%s_%s_%s", obj.getClass().getName(), type, obj.hashCode()); |
|
|
|