Commit 839517aa authored by jyx's avatar jyx

代码优化

parent 748a830d
......@@ -9,4 +9,5 @@
app/build
picture_library/build
ucrop/build
\ No newline at end of file
ucrop/build
videocache/build
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
<bytecodeTargetLevel target="15" />
</component>
</project>
\ No newline at end of file
......@@ -6,9 +6,12 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MotionEvent;
......@@ -41,18 +44,25 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Base
try {
if (TextUtils.equals(getClass().getSimpleName(), "SplashActivity") ||
TextUtils.equals(getClass().getSimpleName(), "GuideActivity") ) {
TextUtils.equals(getClass().getSimpleName(), "GuideActivity")) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else if (TextUtils.equals(getClass().getSimpleName(), "VideoActivity")) {
StatusBarUtil.transparencyBar(this); //设置状态栏全透明
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
getWindow().setNavigationBarColor(Color.BLACK);
}
} else {
StatusBarUtil.transparencyBar(this); //设置状态栏全透明
StatusBarUtil.StatusBarLightMode(this); //设置白底黑字
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
getWindow().setNavigationBarColor(Color.TRANSPARENT);
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (isApplyKitKatTranslucency()) {
setSystemBarTintDrawable(ContextCompat.getDrawable(getContext(), R.drawable.sr_primary));
}
......@@ -256,7 +266,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Base
filter.addAction(Constant.ACTION_EXIT_APP);
filter.addCategory(Intent.CATEGORY_DEFAULT);
MintsApplication.getLocalBroadcastManager().unregisterReceiver(mExitReceiver);
}catch (Exception e){
} catch (Exception e) {
}
......
package com.cwj.updownshortvideo
package com.mints.wisdomclean.video
import android.content.Context
import android.util.AttributeSet
......@@ -6,7 +6,6 @@ import android.util.Log
import android.view.View
import android.widget.ImageView
import android.widget.Toast
import cn.jzvd.JZUtils
import cn.jzvd.Jzvd
import cn.jzvd.JzvdStd
import com.mints.wisdomclean.R
......@@ -126,6 +125,7 @@ class JzvdStdTikTok : JzvdStd {
override fun onCompletion() {
// RxBus.INSTANCE.post(RXCmCWJ(121))
onVideoCompletion?.onVideoCompletion()
}
......@@ -146,4 +146,16 @@ class JzvdStdTikTok : JzvdStd {
replayTextView.visibility = View.GONE
}
}
fun setOnVideoCompletion(onVideoCompletion: OnVideoCompletion?) {
this.onVideoCompletion = onVideoCompletion
}
private var onVideoCompletion: OnVideoCompletion? = null
interface OnVideoCompletion {
fun onVideoCompletion()
}
}
package com.cwj.updownshortvideo
package com.mints.wisdomclean.video
/**
* author : ChenWenJie
......
......@@ -5,6 +5,7 @@ import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import com.mints.wisdomclean.video.OnRecyViewListener
/**
* author : ChenWenJie
......
......@@ -25,7 +25,7 @@ class VideoActivity : BaseActivity() {
override fun isApplyKitKatTranslucency() = false
fun initView() {
var recyViewLayoutManager = RecyViewLayoutManager(
val recyViewLayoutManager = RecyViewLayoutManager(
this, OrientationHelper.VERTICAL
)
recy.layoutManager = recyViewLayoutManager
......@@ -36,11 +36,18 @@ class VideoActivity : BaseActivity() {
//指定位置其他页面跳转过来。直接定位指定posion 这里不需要。
// recy.scrollToPosition(postion);
adapter.setOnVideoCompletion(object : JzvdStdTikTok.OnVideoCompletion {
override fun onVideoCompletion() {
recy.smoothScrollToPosition(mCurrentPosition + 1)
}
})
recyViewLayoutManager.setOnViewPagerListener(object : OnRecyViewListener {
override fun onInitComplete() {
mCurrentPosition = 0
//初始化 自动播放
autoPlayVideo()
}
override fun onPageRelease(isNext: Boolean, position: Int) {
......@@ -155,7 +162,6 @@ class VideoActivity : BaseActivity() {
if (player != null) {
player.startVideoAfterPreloading()
//播放开始,进行倒计时
}
}
......
package com.cwj.updownshortvideo
package com.mints.wisdomclean.video
import android.app.Activity
import android.net.Uri
import android.util.Log
import android.widget.ImageView
import cn.jzvd.JZUtils
import cn.jzvd.Jzvd
import cn.jzvd.JzvdStd
import com.bumptech.glide.Glide
......@@ -33,23 +30,22 @@ class VideoAdapter(var activity: Activity) :
holder.setText(R.id.usertitle_tv, item.video_title)
//缩略图
Glide.with(activity).load(item.video_image)
.into(holder?.getView<JzvdStdTikTok>(R.id.jz_video)!!.posterImageView)
.into(holder.getView<JzvdStdTikTok>(R.id.jz_video).posterImageView)
//声明 代理服务缓存
val proxy = MintsApplication.StaticParams.getProxy()
//这个缓存下一个
if (holder?.layoutPosition!! + 1 < itemCount) {
var item1 = getItem(holder?.layoutPosition!! + 1)
if (holder.layoutPosition + 1 < itemCount) {
var item1 = getItem(holder.layoutPosition + 1)
//缓存下一个 10秒
proxy!!.preLoad(item1!!.video_path, 10)
proxy!!.preLoad(item1.video_path, 10)
}
//缓存当前,播放当前
var proxyUrl =proxy?.getProxyUrl(item.video_path).toString() //设置视
var proxyUrl = proxy?.getProxyUrl(item.video_path).toString() //设置视
setPlay(holder.getView(R.id.jz_video),proxyUrl)
setPlay(holder.getView(R.id.jz_video), proxyUrl)
}
......@@ -61,8 +57,15 @@ class VideoAdapter(var activity: Activity) :
Jzvd.WIFI_TIP_DIALOG_SHOWED = true
// 清除某个URL进度
//JZUtils.clearSavedProgress(activity, path)
jzvdStdTikTok!!.setUp(path, "", JzvdStd.SCREEN_FULLSCREEN)
jzvdStdTikTok.setUp(path, "", JzvdStd.SCREEN_FULLSCREEN)
jzvdStdTikTok.setOnVideoCompletion(onVideoCompletion)
}
private var onVideoCompletion: JzvdStdTikTok.OnVideoCompletion? = null
fun setOnVideoCompletion(onVideoCompletion: JzvdStdTikTok.OnVideoCompletion?) {
this.onVideoCompletion = onVideoCompletion
}
}
......
package com.cwj.updownshortvideo
package com.mints.wisdomclean.video
/**
* author : ChenWenJie
......
......@@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:background="#77090909">
<com.cwj.updownshortvideo.JzvdStdTikTok
<com.mints.wisdomclean.video.JzvdStdTikTok
android:id="@+id/jz_video"
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