作者 杨谦

1.视频播放

2.答题列表适配
... ... @@ -53,9 +53,7 @@ abstract class BaseLifeCycleFragment<VM : BaseViewModel<*>, VB : ViewBinding>(
// showLoading()
mViewModel = ViewModelProvider(this).get(CommonUtil.getClass(this))
mViewModel.loadState.observe(this, observer)
initDataObserver()
}
... ...
package com.br_technology.securitytrain_master.ui.bean
import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr
import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
/**
... ... @@ -123,8 +122,8 @@ open class AnswerRecord(
var count: Int,
var correct: Int,
var is_complete: String, // 是否完成:0=否,1=是
var create_time_text: String, // 日期
var pos: PracticeBean.Pos
var create_time_text: String // 日期
// var pos: PracticeBean.Pos
)
//答题记录详情
... ...
... ... @@ -6,4 +6,7 @@ package com.br_technology.securitytrain_master.ui.view.bank.event
* Description: 初见时你很迷人
*/
class RankListEvent(var type: Int) {
}
class ExcerSize(var type: Int) {
}
\ No newline at end of file
... ...
... ... @@ -46,7 +46,8 @@ class VideoDetailActivity : BaseLifeCycleActivity<VideoDetailViewModel, Activity
super.initData()
val id = intent.getStringExtra(ConstantParamKey.LESSON_ID)?:""
val detailId = intent.getStringExtra(ConstantParamKey.LESSON_DETAIL_ID)?:""
val url = intent.getStringExtra(ConstantParamKey.COURSE_LESSON)?:""
val url = intent.getStringExtra(ConstantParamKey.COMMON_URL)?:""
// val url = "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-uni4934e7b/c4d93960-5643-11eb-a16f-5b3e54966275.m3u8"
val bool = intent.getBooleanExtra(ConstantParamKey.LESSON_COMPLETE,false)
courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN)
courseBean?.mClassId = detailId
... ...
... ... @@ -3,9 +3,12 @@ package com.br_technology.securitytrain_master.ui.view.mine.activity
import androidx.fragment.app.FragmentPagerAdapter
import com.br_technology.securitytrain_master.base.view.BasePagerAdapter
import com.br_technology.securitytrain_master.databinding.ActivityQuestionRecordBinding
import com.br_technology.securitytrain_master.ui.view.bank.event.ExcerSize
import com.br_technology.securitytrain_master.ui.view.mine.fragment.SpecialExercisesFragment
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.QuestionRecordViewModel
import com.google.android.material.tabs.TabLayout
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
import org.greenrobot.eventbus.EventBus
/**
* Time: 7/31/2021 16:44
... ... @@ -16,17 +19,12 @@ class QuestionRecordActivity :
BaseLifeCycleActivity<QuestionRecordViewModel, ActivityQuestionRecordBinding>(
ActivityQuestionRecordBinding::inflate
) {
override fun initDataObserver() {
}
override fun initData() {
super.initData()
override fun initDataObserver() {
binding.apply {
val searchResultAdapter = BasePagerAdapter(
supportFragmentManager,
FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
)
FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT)
val list =
mutableListOf(
SpecialExercisesFragment.newInstance(3),
... ... @@ -40,7 +38,33 @@ class QuestionRecordActivity :
viewPager.adapter = searchResultAdapter
tabLayout.setupWithViewPager(viewPager)
viewPager.offscreenPageLimit = 3
tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab?) {
select(tab?.position ?: 0)
}
override fun onTabUnselected(tab: TabLayout.Tab?) {
}
override fun onTabReselected(tab: TabLayout.Tab?) {
select(tab?.position ?: 0)
}
})
}
}
override fun initData() {
super.initData()
}
fun select(current: Int) {
var type = 0
when (current) {
0 -> type = 3
1 -> type = 4
2 -> type = 5
3 -> type = 6
}
EventBus.getDefault().post(ExcerSize(type))
}
}
\ No newline at end of file
... ...
... ... @@ -13,7 +13,7 @@ import com.chad.library.adapter.base.viewholder.BaseViewHolder
class SpecialExercisesAdapter :
BaseQuickAdapter<AnswerRecord, BaseViewHolder>(R.layout.item_special_exercises) {
override fun convert(holder: BaseViewHolder, item: AnswerRecord) {
holder.setText(R.id.tv_question_title, "${item.title}(${item.pos.name ?: ""})")
holder.setText(R.id.tv_question_title, "${item.title}(${item.title})")
.setText(R.id.tv_timer, item.create_time_text)
.setText(R.id.tv_answer, "答对:${item.correct}/${item.count}")
}
... ...
... ... @@ -7,10 +7,14 @@ import com.br_technology.securitytrain_master.databinding.FragmentSpecialExercis
import com.br_technology.securitytrain_master.expand.addItemDecorationCustom
import com.br_technology.securitytrain_master.ui.bean.AnswerRecord
import com.br_technology.securitytrain_master.ui.view.bank.activity.AnswerRecordDetailsActivity
import com.br_technology.securitytrain_master.ui.view.bank.event.ExcerSize
import com.br_technology.securitytrain_master.ui.view.mine.adapter.SpecialExercisesAdapter
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.SpecialExercisesFragmentViewModel
import com.br_technology.securitytrain_master.util.TranslateUnit
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import kotlin.properties.Delegates
/**
... ... @@ -24,14 +28,22 @@ class SpecialExercisesFragment
FragmentSpecialExercisesBinding::inflate
) {
private var page = 1
private var type by Delegates.notNull<Int>()
private val exercisesAdapter: SpecialExercisesAdapter by lazy {
SpecialExercisesAdapter()
}
private val map = hashMapOf(1 to true, 2 to true, 3 to true, 4 to true)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
EventBus.getDefault().register(this)
}
override fun onDestroy() {
super.onDestroy()
EventBus.getDefault().unregister(this)
}
override fun initDataObserver() {
mViewModel.liveData.observe(this) {
binding.smartRefresh.finishRefresh()
... ... @@ -69,7 +81,7 @@ class SpecialExercisesFragment
loadMore()
}
recyclerview.adapter = exercisesAdapter
exercisesAdapter.setOnItemClickListener { adapter, view, position ->
exercisesAdapter.setOnItemClickListener { _, _, position ->
val intent = Intent(requireContext(), AnswerRecordDetailsActivity::class.java)
intent.putExtra("id", exercisesAdapter.data[position].id)
startActivity(intent)
... ... @@ -85,15 +97,22 @@ class SpecialExercisesFragment
binding.smartRefresh.setEnableLoadMore(false)
}
private fun loadMore(){
++page
@Subscribe(threadMode = ThreadMode.MAIN)
fun onRankListEvent(event: ExcerSize?) {
if (event?.type == type) {
refresh()
}
}
private fun loadMore() {
page += 1
mViewModel.errorSubList(type, page)
binding.smartRefresh.setEnableRefresh(false)
binding.smartRefresh.setEnableLoadMore(false)
}
override fun onResume() {
super.onResume()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
refresh()
}
... ...
... ... @@ -13,8 +13,10 @@ import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.expand.loadPic
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager
import com.shuyu.gsyvideoplayer.utils.OrientationUtils
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
import tv.danmaku.ijk.media.player.IjkMediaPlayer
/**
* createTime:2021/8/2 8:57
... ... @@ -68,9 +70,24 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
showFull()
}
}
initPlayer()
mProgressBar.isEnabled = canTouchProgress
}
private fun initPlayer() {
val iPlayerManager = gsyVideoManager.player
try {
if (iPlayerManager is IjkPlayerManager) {
val mediaPlayer = iPlayerManager.mediaPlayer as IjkMediaPlayer
if (!mediaPlayer.isPlaying) {
mediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_clear", 1)
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
fun setCantTouch(bool: Boolean) {
canTouchProgress = bool
mProgressBar.isEnabled = canTouchProgress
... ...
... ... @@ -18,7 +18,7 @@
android:id="@+id/tab_layout"
style="@style/SearchTab"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:layout_height="40dp"
android:overScrollMode="never"
app:tabMode="auto"
app:tabSelectedTextColor="@color/color_252"
... ...
... ... @@ -10,7 +10,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="83dp"
android:layout_height="wrap_content"
android:background="@drawable/solid_eff2_4"
android:orientation="vertical">
... ... @@ -48,6 +48,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="52dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:background="@drawable/solid_e3f1ff"
android:paddingStart="8dp"
android:paddingTop="2dp"
... ... @@ -55,8 +56,5 @@
android:paddingBottom="2dp"
android:textColor="@color/color_25"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
... ...