|
@@ -37,8 +37,10 @@ import com.sheep.gamegroup.util.DeviceUtil;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.MyDbManager;
|
|
import com.sheep.gamegroup.util.MyDbManager;
|
|
|
import com.sheep.gamegroup.util.MyListview;;
|
|
import com.sheep.gamegroup.util.MyListview;;
|
|
|
|
|
+import com.sheep.gamegroup.util.NetUtil;
|
|
|
import com.sheep.gamegroup.view.adapter.TaskStateAdapter;
|
|
import com.sheep.gamegroup.view.adapter.TaskStateAdapter;
|
|
|
import com.sheep.gamegroup.view.customview.SProgress;
|
|
import com.sheep.gamegroup.view.customview.SProgress;
|
|
|
|
|
+import com.sheep.gamegroup.view.dialog.DialogAccountAbnormal;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.download.DownloadInfo;
|
|
import com.sheep.jiuyan.samllsheep.download.DownloadInfo;
|
|
@@ -50,6 +52,7 @@ import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
import org.wlf.filedownloader.DownloadFileInfo;
|
|
import org.wlf.filedownloader.DownloadFileInfo;
|
|
|
import org.wlf.filedownloader.FileDownloader;
|
|
import org.wlf.filedownloader.FileDownloader;
|
|
|
import org.wlf.filedownloader.listener.OnDetectBigUrlFileListener;
|
|
import org.wlf.filedownloader.listener.OnDetectBigUrlFileListener;
|
|
@@ -139,6 +142,7 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.download_item_dialog);
|
|
setContentView(R.layout.download_item_dialog);
|
|
|
ButterKnife.bind(this);
|
|
ButterKnife.bind(this);
|
|
|
|
|
+ EventBus.getDefault().register(this);
|
|
|
activity = this;
|
|
activity = this;
|
|
|
intentService = new Intent(activity, KFDownloadServices.class);
|
|
intentService = new Intent(activity, KFDownloadServices.class);
|
|
|
initViews();
|
|
initViews();
|
|
@@ -237,6 +241,10 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
|
|
|
case 2://开始下载
|
|
case 2://开始下载
|
|
|
// downLoadApk();
|
|
// downLoadApk();
|
|
|
if(!isStartPause){
|
|
if(!isStartPause){
|
|
|
|
|
+ if(NetUtil.isMobile(activity)){
|
|
|
|
|
+ DialogAccountAbnormal.showDialog(activity,null, "当前网络处于非WIFI状态,确定下载吗?", "取消", "确定" ).show();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
startFiler();
|
|
startFiler();
|
|
|
}else {
|
|
}else {
|
|
|
FileDownloader.pause(task_entity.getDownload_link());
|
|
FileDownloader.pause(task_entity.getDownload_link());
|
|
@@ -284,6 +292,8 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
|
|
|
downloadInfo.setState(DownloadState.FINISHED);
|
|
downloadInfo.setState(DownloadState.FINISHED);
|
|
|
downloadInfo.setPkgName(task_entity.getPackage_names());
|
|
downloadInfo.setPkgName(task_entity.getPackage_names());
|
|
|
MyDbManager.getInstance().saveOrUpdateUser(downloadInfo);//保存到数据库
|
|
MyDbManager.getInstance().saveOrUpdateUser(downloadInfo);//保存到数据库
|
|
|
|
|
+ }else{
|
|
|
|
|
+ downloadInfo.setState(DownloadState.FINISHED);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return downloadInfo;
|
|
return downloadInfo;
|
|
@@ -309,6 +319,10 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
|
|
|
type = 1;
|
|
type = 1;
|
|
|
}if(downloadInfo.getState() ==DownloadState.FINISHED ){
|
|
}if(downloadInfo.getState() ==DownloadState.FINISHED ){
|
|
|
buttonStr = "开始安装";
|
|
buttonStr = "开始安装";
|
|
|
|
|
+ type = 3;
|
|
|
|
|
+ }else if(downloadInfo.getState() ==DownloadState.STOPPED){
|
|
|
|
|
+ buttonStr = "继续下载";
|
|
|
|
|
+ type = 2;
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
buttonStr = "开始下载";
|
|
buttonStr = "开始下载";
|
|
@@ -375,6 +389,7 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
|
|
|
protected void onDestroy() {
|
|
protected void onDestroy() {
|
|
|
super.onDestroy();
|
|
super.onDestroy();
|
|
|
unFiler();
|
|
unFiler();
|
|
|
|
|
+ EventBus.getDefault().unregister(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------*/
|
|
/*----------------------------*/
|
|
@@ -408,6 +423,8 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
|
|
|
public void onFileDownloadStatusPaused(DownloadFileInfo downloadFileInfo) {
|
|
public void onFileDownloadStatusPaused(DownloadFileInfo downloadFileInfo) {
|
|
|
start_task_tv.setText("继续下载");
|
|
start_task_tv.setText("继续下载");
|
|
|
Log.e("DownloadStatusPaused---",downloadFileInfo.getDownloadedSizeLong()+","+downloadFileInfo.getFileSizeLong());
|
|
Log.e("DownloadStatusPaused---",downloadFileInfo.getDownloadedSizeLong()+","+downloadFileInfo.getFileSizeLong());
|
|
|
|
|
+ if(downloadInfo != null)
|
|
|
|
|
+ downloadInfo.setState(DownloadState.STOPPED);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -478,4 +495,13 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Subscribe
|
|
|
|
|
+ public void onEventMainThread(BigEvent event){
|
|
|
|
|
+ switch (event.getEventTypes()){
|
|
|
|
|
+ case DIALOG_ACTIVITY_DOWNLOAD_FILE:
|
|
|
|
|
+ startFiler();
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|