Commit b1f4adc7 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 56a54c9a
......@@ -80,6 +80,6 @@ public class RingtoneHelper {
}
RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE, newUri);
ToastUtil.show(context,"设置来电铃声成功!");
// ToastUtil.show(context,"设置来电铃声成功!");
}
}
package com.mints.goodmoney.ui.activitys
import android.Manifest
import android.media.MediaPlayer
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import cn.jzvd.Jzvd
import android.widget.VideoView
import com.downloader.Error
import com.downloader.OnDownloadListener
import com.downloader.PRDownloader
......@@ -41,6 +42,7 @@ class KylVedioActivity : BaseActivity(), View.OnClickListener, KylVedioView {
private var downloadId: Int = -1//vedio下载id
private var downloadVedioSucFlag = false// 下载视频成功
private var vedioName = ""
override fun getContentViewLayoutID() = R.layout.activity_kyl_vedio
......@@ -65,41 +67,28 @@ class KylVedioActivity : BaseActivity(), View.OnClickListener, KylVedioView {
}
private fun loadVedio(vedioUrl: String) {
jzvdStd?.setUp(vedioUrl, "")
jzvdStd?.startVideo()
// jzvdStd.setVedioRestart(false)
// jzvdStd.setJzVedioStatusListener(object : JZVideoPlayerStandardLoopVideo.JZVedioStatusListener {
// override fun jzVedioPlaying() {
// }
// })
jzvdStd?.setOnPreparedListener { mp: MediaPlayer ->
mp.start()
mp.isLooping = true
}
override fun onBackPressed() {
if (Jzvd.backPress()) {
return
}
super.onBackPressed()
jzvdStd?.setVideoPath(vedioUrl)
jzvdStd?.start()
}
override fun onResume() {
super.onResume()
if (!isFinishing()) {
Jzvd.goOnPlayOnResume()
}
jzvdStd.resume()
}
override fun onPause() {
super.onPause()
Jzvd.goOnPlayOnPause()
jzvdStd.pause()
}
override fun onDestroy() {
super.onDestroy()
Jzvd.releaseAllVideos()
jzvdStd?.removeAllViews()
if (downloadId != -1) {
PRDownloader.cancel(downloadId)
}
......@@ -123,41 +112,32 @@ class KylVedioActivity : BaseActivity(), View.OnClickListener, KylVedioView {
.subscribe { granted: Boolean ->
if (granted) {
downloadVedioToCacheFile()
awardVedio()
} else {
showMissingPermissionDialog("存储")
}
}
// awardVedio()
}
}
}
private fun downloadVedioToCacheFile() {
showLoading("加载中...")
downloadVedioSucFlag = false
var vedioPath = ""
try {
vedioPath = getExternalFilesDir(null)!!.absolutePath + "/video/"
} catch (e: java.lang.Exception) {
vedioPath = filesDir.absolutePath + "/video/"
}
val vedioName = MD5.GetMD5Code(System.currentTimeMillis().toString() + UserManager.getInstance().userID + vedioUrl) + ".mp4"
vedioName = MD5.GetMD5Code(System.currentTimeMillis().toString() + UserManager.getInstance().userID + vedioUrl) + ".mp4"
downloadId = PRDownloader.download(vedioUrl, vedioPath, vedioName)
.build()
.start(object : OnDownloadListener {
override fun onDownloadComplete() {
runOnUiThread {
hideLoading()
// downloadVedioSucFlag = true
val vedioName = vedioPath + vedioName
DetailActivity.startSelf(this@KylVedioActivity, vedioName)
}
downloadVedioSucFlag = true
}
override fun onError(error: Error) {
runOnUiThread {
showToast("加载失败")
hideLoading()
}
}
})
}
......@@ -219,10 +199,7 @@ class KylVedioActivity : BaseActivity(), View.OnClickListener, KylVedioView {
private fun vedioAdingSuccess(adType: String) {
if (downloadVedioSucFlag) {
try {
} catch (e: Exception) {
e.printStackTrace()
}
DetailActivity.startSelf(this@KylVedioActivity, vedioName)
}
}
}
......@@ -9,7 +9,6 @@
android:layout_height="match_parent" />
<TextView
android:visibility="gone"
android:id="@+id/set_show_tv"
android:layout_width="match_parent"
android:layout_height="40dp"
......
......@@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:background="@color/black">
<com.mints.goodmoney.ui.widgets.JZVideoPlayerStandardLoopVideo
<com.mints.goodmoney.call.widget.CustomVideoView
android:id="@+id/jzvdStd"
android:layout_width="match_parent"
android:layout_height="match_parent" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment