| | |
| | | import com.sinata.xqmuse.network.requestByF |
| | | import com.sinata.xqmuse.ui.course.adapter.CourseGridAdapter |
| | | import com.sinata.xqmuse.utils.Const |
| | | import com.sinata.xqmuse.utils.cache.ProxyVideoCacheManager |
| | | import com.sinata.xqmuse.utils.event.EmptyEvent |
| | | import kotlinx.android.synthetic.main.fragment_teacher.* |
| | | import org.greenrobot.eventbus.EventBus |
| | |
| | | webView.webViewClient = object : WebViewClient() {} |
| | | webView.backgroundColor = 0 |
| | | webView.background.alpha = 0 |
| | | rv_course.layoutManager = GridLayoutManager(requireContext(),2) |
| | | rv_course.layoutManager = GridLayoutManager(requireContext(), 2) |
| | | rv_course.adapter = adapter |
| | | getData() |
| | | adapter.setOnItemClickListener { view, position -> |
| | | showDialog() |
| | | HttpManager.getPayCourseInfoById(list[position].id).requestByF(this,success = { _, data-> |
| | | dismissDialog() |
| | | data?.goDetail(requireContext()) |
| | | }){_,_-> |
| | | HttpManager.getPayCourseInfoById(list[position].id).requestByF( |
| | | this, |
| | | success = { _, data -> |
| | | dismissDialog() |
| | | data?.goDetail(requireContext()) |
| | | }){ _, _-> |
| | | dismissDialog() |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | private fun getData(){ |
| | | HttpManager.getCoursePageList().requestByF(this){_,data-> |
| | | HttpManager.getCoursePageList().requestByF(this){ _, data-> |
| | | (requireActivity() as MainActivity).teacherVideoView = mVideoView |
| | | mVideoView.setUrl(data?.videoUrl) |
| | | val cacheServer = ProxyVideoCacheManager.getProxy(context) |
| | | val proxyUrl = cacheServer.getProxyUrl(data?.videoUrl) |
| | | mVideoView.setUrl(proxyUrl) |
| | | iv_cover.setImageURI(data?.coverUrl) |
| | | iv_play_teacher.visible() |
| | | val sHead = |
| | | "<html><head><meta name=\"viewport\" content=\"width=device-width, " + "initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes\" />" + "<style>img{max-width:100% !important;height:auto !important;}</style>" + "<style>body{max-width:100% !important;}</style>" + "</head><body>" |
| | | webView!!.loadDataWithBaseURL(null, sHead + data?.tutorIntroduction, "text/html", "utf-8", null) |
| | | webView!!.loadDataWithBaseURL( |
| | | null, |
| | | sHead + data?.tutorIntroduction, |
| | | "text/html", |
| | | "utf-8", |
| | | null |
| | | ) |
| | | list.clear() |
| | | list.addAll(data?.list?: arrayListOf()) |
| | | list.addAll(data?.list ?: arrayListOf()) |
| | | adapter.notifyDataSetChanged() |
| | | } |
| | | } |
| | | |
| | | @Subscribe |
| | | fun pause(e:EmptyEvent){ |
| | | fun pause(e: EmptyEvent){ |
| | | if (e.code == Const.EventCode.PAUSE_TEACHER_VIDEO) |
| | | mVideoView.pause() |
| | | } |