Browse Source

分片上传

zhaofuxin 4 years ago
parent
commit
7398d45474

+ 19 - 14
app/src/main/java/com/jld/vod/service/PositionAdvertService.kt

@@ -31,21 +31,26 @@ class PositionAdvertService : Service() {
     fun onReceive( positionAdvert :List<PositionAdvertBean>) {
         LogUtils.logD("我收到了消息"+positionAdvert)
 
-        if (mCustom == null && Config.isShowAd)
-        {
-            mCustom = CustomAdDialog(this)
-            mCustom!!.getWindow()!!.setType((WindowManager.LayoutParams.TYPE_SYSTEM_ALERT));
-            mCustom!!.setDataList(positionAdvert)
-            mCustom!!.setCancelable(false)
-            mCustom!!.setCanceledOnTouchOutside(false)
-            mCustom!!.show()
-            mCustom!!.setOnClickBottomListener(object : CustomAdDialog.OnClickBottomListener{
-                override fun onBtnCloseClick() {
-                    mCustom!!.dismiss()
-                    mCustom = null
-                }
-            })
+        try {
+            if (mCustom == null && Config.isShowAd)
+            {
+                mCustom = CustomAdDialog(this)
+                mCustom!!.getWindow()!!.setType((WindowManager.LayoutParams.TYPE_SYSTEM_ALERT));
+                mCustom!!.setDataList(positionAdvert)
+                mCustom!!.setCancelable(false)
+                mCustom!!.setCanceledOnTouchOutside(false)
+                mCustom!!.show()
+                mCustom!!.setOnClickBottomListener(object : CustomAdDialog.OnClickBottomListener{
+                    override fun onBtnCloseClick() {
+                        mCustom!!.dismiss()
+                        mCustom = null
+                    }
+                })
+            }
+        }catch (e:Exception){
+            e.printStackTrace()
         }
+
     }
 
 

+ 18 - 13
app/src/main/java/com/jld/vod/view/SplashActivity.kt

@@ -37,6 +37,7 @@ import com.jld.vod.viewmodel.SplashViewModel
 import com.tbruyelle.rxpermissions2.RxPermissions
 import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog
 import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog.ListCallbackSingleChoice
+import com.xuexiang.xui.widget.toast.XToast
 import io.reactivex.android.schedulers.AndroidSchedulers
 import io.reactivex.functions.Consumer
 import kotlinx.android.synthetic.main.activity_splash.*
@@ -234,17 +235,17 @@ class SplashActivity : BaseActivity(){
                     }
                 })
 
-        if (!MyAccessibilityService.isRunning) {
-            //默认开启全局返回服务
-            Settings.Secure.putString(mContext.getContentResolver(),
-                    Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
-                    "com.jld.vod/com.jld.vod.service.MyAccessibilityService");
-
-            Settings.Secure.putInt(mContext.getContentResolver(),
-                    Settings.Secure.ACCESSIBILITY_ENABLED, 1);
-            val mIntnet = Intent(mContext,MyAccessibilityService::class.java)
-            startService(mIntnet)
-        }
+//        if (!MyAccessibilityService.isRunning) {
+//            //默认开启全局返回服务
+//            Settings.Secure.putString(mContext.getContentResolver(),
+//                    Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
+//                    "com.jld.vod/com.jld.vod.service.MyAccessibilityService");
+//
+//            Settings.Secure.putInt(mContext.getContentResolver(),
+//                    Settings.Secure.ACCESSIBILITY_ENABLED, 1);
+//            val mIntnet = Intent(mContext,MyAccessibilityService::class.java)
+//            startService(mIntnet)
+//        }
     }
     /**
      * 初始apk版本更新
@@ -551,7 +552,7 @@ class SplashActivity : BaseActivity(){
                     //获取包名
                     val packname =  AppUtil.getApkPackName(applicationContext,apkfile.absolutePath)
 
-                    lenitem++
+
                     LogUtils.logD("apk"+apkfile.absolutePath)
                     val msg = Message()
                     msg.what = 2
@@ -561,7 +562,8 @@ class SplashActivity : BaseActivity(){
 
                     InstallGame( apkfile.absolutePath,packname,gid)
 
-                    ajaxInfo(getString(R.string.download_games1)+getString(R.string.sum_total)+totalitem+getString(R.string.download_games2)+"${(totalitem-lenitem)}" + getString(R.string.fail_sum)+failitem,null)
+                   // ajaxInfo(getString(R.string.download_games1)+getString(R.string.sum_total)+totalitem+getString(R.string.download_games2)+"${(totalitem-lenitem)}" + getString(R.string.fail_sum)+failitem,null)
+                    ajaxInfo(getString(R.string.download_games1),null)
 
                   //  val mPm = mContext.packageManager
                     //val isOk = SilentInstall.silentInstall(mPm, apkfile.absolutePath)
@@ -1008,6 +1010,7 @@ class SplashActivity : BaseActivity(){
             LogUtils.logD("GameObserver $packageName 下载完成安装完成.且更新安装状态:$returnCode")
             //是否安装成功
             if (returnCode == 1) {
+                lenitem++
                 try {
                     splashViewmodel.updateGameInstallState(gid.toString(),packageName!!,deviceSN)
                 }catch (e:Exception) {
@@ -1023,6 +1026,8 @@ class SplashActivity : BaseActivity(){
             }else{
                 LogUtils.logD("游戏安装失败?")
                 failitem++
+                lenitem++
+                XToast.error(mContext,getString(R.string.fail_sum))
 
                 if (lenitem == totalitem) {
                     lenitem = 0