作者 杨谦

1.部分样式调整

2.视频跳转修改等
@@ -9,6 +9,7 @@ package com.br_technology.securitytrain_master.base.common @@ -9,6 +9,7 @@ package com.br_technology.securitytrain_master.base.common
9 object ConstantParamKey { 9 object ConstantParamKey {
10 // 视频/线下培训课节id 10 // 视频/线下培训课节id
11 const val COURSE_BEAN = "course_bean" 11 const val COURSE_BEAN = "course_bean"
  12 + const val COURSE_LESSON = "course_lesson"
12 13
13 // 课程描述 14 // 课程描述
14 const val COURSE_DES = "course_des" 15 const val COURSE_DES = "course_des"
  1 +package com.br_technology.securitytrain_master.expand;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.Bitmap;
  5 +import android.graphics.Canvas;
  6 +import android.graphics.Color;
  7 +import android.graphics.Paint;
  8 +import android.graphics.RectF;
  9 +import android.graphics.drawable.BitmapDrawable;
  10 +import android.graphics.drawable.Drawable;
  11 +import android.text.TextUtils;
  12 +import android.util.DisplayMetrics;
  13 +import android.view.WindowManager;
  14 +
  15 +import androidx.annotation.ColorRes;
  16 +
  17 +import java.util.Collection;
  18 +
  19 +/**
  20 + * 像素,dp.px互转
  21 + */
  22 +public class TranslateUnit {
  23 +
  24 + private static WindowManager windowManager;
  25 +
  26 + private static WindowManager getWindowManager(Context context) {
  27 + if (windowManager == null) {
  28 + windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  29 + }
  30 + return windowManager;
  31 + }
  32 +
  33 + public static float getDensity(Context context) {
  34 + return context.getResources().getDisplayMetrics().density;
  35 + }
  36 +
  37 + public static float getFontDensity(Context context) {
  38 + return context.getResources().getDisplayMetrics().scaledDensity;
  39 + }
  40 +
  41 + public static DisplayMetrics getDisplayMetrics(Context context) {
  42 + DisplayMetrics displayMetrics = new DisplayMetrics();
  43 + getWindowManager(context).getDefaultDisplay().getMetrics(displayMetrics);
  44 + return displayMetrics;
  45 + }
  46 +
  47 + public static int dp2px(Context context, float dp) {
  48 + return (int) (getDensity(context) * dp + 0.5f);
  49 + }
  50 +
  51 + public static int px2dp(Context context, float px) {
  52 + return (int) (px / getDensity(context) + 0.5f);
  53 + }
  54 +
  55 + public static int sp2px(Context context, float sp) {
  56 + return (int) (getFontDensity(context) * sp + 0.5f);
  57 + }
  58 +
  59 + public static int px2sp(Context context, float px) {
  60 + return (int) (px / getFontDensity(context) + 0.5f);
  61 + }
  62 +
  63 + public static int getWindowWidth(Context context) {
  64 + return getDisplayMetrics(context).widthPixels;
  65 + }
  66 +
  67 + public static int getWindowHeight(Context context) {
  68 + return getDisplayMetrics(context).heightPixels;
  69 + }
  70 +
  71 + public static String getPathFormat(String path) {
  72 + if (!TextUtils.isEmpty(path)) {
  73 + int lastPeriodIndex = path.lastIndexOf('.');
  74 + if (lastPeriodIndex > 0 && lastPeriodIndex + 1 < path.length()) {
  75 + String format = path.substring(lastPeriodIndex + 1);
  76 + if (!TextUtils.isEmpty(format)) {
  77 + return format.toLowerCase();
  78 + }
  79 + }
  80 + }
  81 + return "";
  82 + }
  83 +
  84 + public static boolean isGif(String url) {
  85 + return "gif".equals(getPathFormat(url));
  86 + }
  87 +
  88 + public static Bitmap getTextBitmap(Context context, int width, int height, int radius, String text, int textSize, @ColorRes int bgColor) {
  89 + radius = dp2px(context, radius);
  90 + Bitmap bitmap = Bitmap.createBitmap(dp2px(context, width), dp2px(context, height), Bitmap.Config.ARGB_8888);
  91 + Canvas canvas = new Canvas(bitmap);
  92 + RectF rect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
  93 + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
  94 + paint.setColor(context.getResources().getColor(bgColor));
  95 + canvas.drawRoundRect(new RectF(0, 0, rect.width(), rect.height()), radius, radius, paint);
  96 + paint.setColor(Color.WHITE);
  97 + paint.setTextSize(dp2px(context, textSize));
  98 + paint.setTextAlign(Paint.Align.CENTER);
  99 + Paint.FontMetricsInt fontMetrics = paint.getFontMetricsInt();
  100 + float baseline = (rect.bottom + rect.top - fontMetrics.bottom - fontMetrics.top) / 2;
  101 + canvas.drawText(text, rect.centerX(), baseline, paint);
  102 + return bitmap;
  103 + }
  104 +
  105 + public static Drawable getTextDrawable(Context context, int width, int height, int radius, String text, int textSize, @ColorRes int bgColor) {
  106 + return new BitmapDrawable(getTextBitmap(context, width, height, radius, text, textSize, bgColor));
  107 + }
  108 +
  109 + public static boolean isEmpty(Collection<?> collection) {
  110 + return collection == null || collection.isEmpty();
  111 + }
  112 +
  113 + public static int getSize(Collection<?> collection) {
  114 + return collection == null ? 0 : collection.size();
  115 + }
  116 +}
@@ -119,7 +119,7 @@ open class TrainCourseDetailItem(var type: Int) : MultiItemEntity { @@ -119,7 +119,7 @@ open class TrainCourseDetailItem(var type: Int) : MultiItemEntity {
119 var lessonVideo: LessonClazz? = null 119 var lessonVideo: LessonClazz? = null
120 var lessonVideoNormal: LessonClassDetail? = null 120 var lessonVideoNormal: LessonClassDetail? = null
121 var lessonLive: LessonLive? = null 121 var lessonLive: LessonLive? = null
122 - var lessonOff: LessonOfflineClazz? = null 122 + var lessonOff: LessonOfflineDetail? = null
123 123
124 override val itemType: Int 124 override val itemType: Int
125 get() = type 125 get() = type
@@ -40,12 +40,13 @@ class OnlineActivity : @@ -40,12 +40,13 @@ class OnlineActivity :
40 val data = videoLessonList!![position] 40 val data = videoLessonList!![position]
41 course.mLessonId = "${data.id}" 41 course.mLessonId = "${data.id}"
42 course.isTrainClass = false 42 course.isTrainClass = false
43 - course.type = data.type.toInt() 43 + course.type = 1
44 startActivity( 44 startActivity(
45 Intent( 45 Intent(
46 this@OnlineActivity, 46 this@OnlineActivity,
47 CourseDetailActivity::class.java 47 CourseDetailActivity::class.java
48 ).putExtra(ConstantParamKey.COURSE_BEAN, course) 48 ).putExtra(ConstantParamKey.COURSE_BEAN, course)
  49 + .putExtra(ConstantParamKey.COURSE_LESSON, data)
49 ) 50 )
50 } 51 }
51 initLoadMore() 52 initLoadMore()
@@ -9,6 +9,7 @@ import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType. @@ -9,6 +9,7 @@ import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.
9 import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_NORMAL 9 import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_NORMAL
10 import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_OFF 10 import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_OFF
11 import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_VIDEO 11 import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_VIDEO
  12 +import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
12 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean 13 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
13 import com.br_technology.securitytrain_master.ui.view.home.fragment.CourseListFragment 14 import com.br_technology.securitytrain_master.ui.view.home.fragment.CourseListFragment
14 import com.br_technology.securitytrain_master.ui.view.home.fragment.OnlineDetailFragment 15 import com.br_technology.securitytrain_master.ui.view.home.fragment.OnlineDetailFragment
@@ -28,6 +29,7 @@ class CourseDetailActivity @@ -28,6 +29,7 @@ class CourseDetailActivity
28 ) { 29 ) {
29 private var searchResultAdapter: BasePagerAdapter? = null 30 private var searchResultAdapter: BasePagerAdapter? = null
30 private var courseBean: CourseParam? = null 31 private var courseBean: CourseParam? = null
  32 + private var courseLesson: VideoLessonBean.ListBean.DataBean? = null
31 private var mWorkBean: WorkTypeBean? = null 33 private var mWorkBean: WorkTypeBean? = null
32 private var mapWork = mutableMapOf<Int, WorkTypeBean.ListBean>() 34 private var mapWork = mutableMapOf<Int, WorkTypeBean.ListBean>()
33 35
@@ -48,11 +50,11 @@ class CourseDetailActivity @@ -48,11 +50,11 @@ class CourseDetailActivity
48 it.data.detail.name, 50 it.data.detail.name,
49 setPosName(posIds), 51 setPosName(posIds),
50 it.data.detail.content 52 it.data.detail.content
51 - ) 53 + ), TYPE_COURSE_DETAIL_ITEM_VIDEO
52 ), 54 ),
53 CourseListFragment(TrainCourseData(TYPE_COURSE_DETAIL_ITEM_VIDEO).apply { 55 CourseListFragment(TrainCourseData(TYPE_COURSE_DETAIL_ITEM_VIDEO).apply {
54 this.lessonBean = it.data 56 this.lessonBean = it.data
55 - },"${courseBean?.mTrainClassId}") 57 + }, "${courseBean?.mTrainClassId}")
56 ) 58 )
57 val titles = listOf("课程详情", "课程列表") 59 val titles = listOf("课程详情", "课程列表")
58 searchResultAdapter?.addData(list.toMutableList()) 60 searchResultAdapter?.addData(list.toMutableList())
@@ -64,17 +66,22 @@ class CourseDetailActivity @@ -64,17 +66,22 @@ class CourseDetailActivity
64 66
65 mViewModel.mVideoLessonNormal.observe(this, { 67 mViewModel.mVideoLessonNormal.observe(this, {
66 binding.apply { 68 binding.apply {
67 - Glide.with(this@CourseDetailActivity).load(it.data.detail.video).into(ivTop)  
68 searchResultAdapter = BasePagerAdapter( 69 searchResultAdapter = BasePagerAdapter(
69 supportFragmentManager, 70 supportFragmentManager,
70 FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT 71 FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
71 ) 72 )
72 val list = 73 val list =
73 mutableListOf( 74 mutableListOf(
74 - OnlineDetailFragment(TrainClassDes(it.data.detail.name, "", "")), 75 + OnlineDetailFragment(
  76 + TrainClassDes(
  77 + courseLesson?.name ?: "",
  78 + courseLesson?.pos_ids ?: "",
  79 + courseLesson?.content ?: ""
  80 + ), TYPE_COURSE_DETAIL_ITEM_NORMAL
  81 + ),
75 CourseListFragment(TrainCourseData(TYPE_COURSE_DETAIL_ITEM_NORMAL).apply { 82 CourseListFragment(TrainCourseData(TYPE_COURSE_DETAIL_ITEM_NORMAL).apply {
76 this.lessonBeanNormal = it.data.detail 83 this.lessonBeanNormal = it.data.detail
77 - },"${courseBean?.mTrainClassId}") 84 + }, "${courseBean?.mTrainClassId}")
78 ) 85 )
79 val titles = listOf("课程详情", "课程列表") 86 val titles = listOf("课程详情", "课程列表")
80 searchResultAdapter?.addData(list.toMutableList()) 87 searchResultAdapter?.addData(list.toMutableList())
@@ -93,10 +100,13 @@ class CourseDetailActivity @@ -93,10 +100,13 @@ class CourseDetailActivity
93 ) 100 )
94 val list = 101 val list =
95 mutableListOf( 102 mutableListOf(
96 - OnlineDetailFragment(TrainClassDes(it.data.detail.name, "", "")), 103 + OnlineDetailFragment(
  104 + TrainClassDes(it.data.detail.name, "", ""),
  105 + TYPE_COURSE_DETAIL_ITEM_LIVE
  106 + ),
97 CourseListFragment(TrainCourseData(TYPE_COURSE_DETAIL_ITEM_LIVE).apply { 107 CourseListFragment(TrainCourseData(TYPE_COURSE_DETAIL_ITEM_LIVE).apply {
98 this.lessonLive = it.data.detail 108 this.lessonLive = it.data.detail
99 - },"${courseBean?.mTrainClassId}") 109 + }, "${courseBean?.mTrainClassId}")
100 ) 110 )
101 val titles = listOf("课程详情", "课程列表") 111 val titles = listOf("课程详情", "课程列表")
102 searchResultAdapter?.addData(list.toMutableList()) 112 searchResultAdapter?.addData(list.toMutableList())
@@ -121,11 +131,11 @@ class CourseDetailActivity @@ -121,11 +131,11 @@ class CourseDetailActivity
121 it.data.detail.name, 131 it.data.detail.name,
122 setPosName(posIds), 132 setPosName(posIds),
123 it.data.detail.content 133 it.data.detail.content
124 - ) 134 + ), TYPE_COURSE_DETAIL_ITEM_OFF
125 ), 135 ),
126 CourseListFragment(TrainCourseData(TYPE_COURSE_DETAIL_ITEM_OFF).apply { 136 CourseListFragment(TrainCourseData(TYPE_COURSE_DETAIL_ITEM_OFF).apply {
127 this.lessonOff = it.data.detail 137 this.lessonOff = it.data.detail
128 - },"${courseBean?.mTrainClassId}") 138 + }, "${courseBean?.mTrainClassId}")
129 ) 139 )
130 val titles = listOf("课程详情", "课程列表") 140 val titles = listOf("课程详情", "课程列表")
131 searchResultAdapter?.addData(list.toMutableList()) 141 searchResultAdapter?.addData(list.toMutableList())
@@ -151,6 +161,10 @@ class CourseDetailActivity @@ -151,6 +161,10 @@ class CourseDetailActivity
151 override fun initData() { 161 override fun initData() {
152 super.initData() 162 super.initData()
153 courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN) 163 courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN)
  164 + courseLesson = intent.getParcelableExtra(ConstantParamKey.COURSE_LESSON)
  165 + courseLesson?.let {
  166 + Glide.with(this@CourseDetailActivity).load(it.image).into(binding.ivTop)
  167 + }
154 mViewModel.workType() 168 mViewModel.workType()
155 mViewModel.mWorkBean.observe(this, { 169 mViewModel.mWorkBean.observe(this, {
156 mWorkBean = it.data 170 mWorkBean = it.data
@@ -115,10 +115,12 @@ fun transData(data: TrainCourseDetailItem, pos: Int): List<TrainCourseDetailItem @@ -115,10 +115,12 @@ fun transData(data: TrainCourseDetailItem, pos: Int): List<TrainCourseDetailItem
115 } 115 }
116 } 116 }
117 TYPE_COURSE_DETAIL_ITEM_OFF -> { 117 TYPE_COURSE_DETAIL_ITEM_OFF -> {
118 - data.lessonOff?.apply {  
119 - list.add(TrainCourseDetailItemChild(TYPE_COURSE_DETAIL_ITEM_OFF, pos).apply {  
120 - lessonOffChild = data.lessonOff  
121 - }) 118 + data.lessonOff?.let {
  119 + for (p in it.lessonofflineclass) {
  120 + list.add(TrainCourseDetailItemChild(TYPE_COURSE_DETAIL_ITEM_OFF, pos).apply {
  121 + lessonOffChild = p
  122 + })
  123 + }
122 } 124 }
123 } 125 }
124 } 126 }
1 package com.br_technology.securitytrain_master.ui.view.home.bean; 1 package com.br_technology.securitytrain_master.ui.view.home.bean;
2 2
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
3 import java.util.List; 6 import java.util.List;
4 7
5 /** 8 /**
@@ -65,7 +68,7 @@ public class VideoLessonBean { @@ -65,7 +68,7 @@ public class VideoLessonBean {
65 this.data = data; 68 this.data = data;
66 } 69 }
67 70
68 - public static class DataBean { 71 + public static class DataBean implements Parcelable {
69 private Integer id; 72 private Integer id;
70 private String type; 73 private String type;
71 private Integer company_id; 74 private Integer company_id;
@@ -276,6 +279,90 @@ public class VideoLessonBean { @@ -276,6 +279,90 @@ public class VideoLessonBean {
276 this.avatar = avatar; 279 this.avatar = avatar;
277 } 280 }
278 } 281 }
  282 +
  283 + @Override
  284 + public int describeContents() {
  285 + return 0;
  286 + }
  287 +
  288 + @Override
  289 + public void writeToParcel(Parcel dest, int flags) {
  290 + dest.writeValue(this.id);
  291 + dest.writeString(this.type);
  292 + dest.writeValue(this.company_id);
  293 + dest.writeString(this.name);
  294 + dest.writeString(this.des);
  295 + dest.writeString(this.image);
  296 + dest.writeString(this.pos_ids);
  297 + dest.writeValue(this.teacher_id);
  298 + dest.writeValue(this.class_hours);
  299 + dest.writeValue(this.score);
  300 + dest.writeString(this.is_open);
  301 + dest.writeString(this.is_rec);
  302 + dest.writeString(this.content);
  303 + dest.writeString(this.class_json);
  304 + dest.writeValue(this.create_time);
  305 + dest.writeValue(this.update_time);
  306 + dest.writeString(this.pos_name);
  307 + dest.writeString(this.create_time_text);
  308 + }
  309 +
  310 + public void readFromParcel(Parcel source) {
  311 + this.id = (Integer) source.readValue(Integer.class.getClassLoader());
  312 + this.type = source.readString();
  313 + this.company_id = (Integer) source.readValue(Integer.class.getClassLoader());
  314 + this.name = source.readString();
  315 + this.des = source.readString();
  316 + this.image = source.readString();
  317 + this.pos_ids = source.readString();
  318 + this.teacher_id = (Integer) source.readValue(Integer.class.getClassLoader());
  319 + this.class_hours = (Integer) source.readValue(Integer.class.getClassLoader());
  320 + this.score = (Integer) source.readValue(Integer.class.getClassLoader());
  321 + this.is_open = source.readString();
  322 + this.is_rec = source.readString();
  323 + this.content = source.readString();
  324 + this.class_json = source.readString();
  325 + this.create_time = (Integer) source.readValue(Integer.class.getClassLoader());
  326 + this.update_time = (Integer) source.readValue(Integer.class.getClassLoader());
  327 + this.pos_name = source.readString();
  328 + this.create_time_text = source.readString();
  329 + }
  330 +
  331 + public DataBean() {
  332 + }
  333 +
  334 + protected DataBean(Parcel in) {
  335 + this.id = (Integer) in.readValue(Integer.class.getClassLoader());
  336 + this.type = in.readString();
  337 + this.company_id = (Integer) in.readValue(Integer.class.getClassLoader());
  338 + this.name = in.readString();
  339 + this.des = in.readString();
  340 + this.image = in.readString();
  341 + this.pos_ids = in.readString();
  342 + this.teacher_id = (Integer) in.readValue(Integer.class.getClassLoader());
  343 + this.class_hours = (Integer) in.readValue(Integer.class.getClassLoader());
  344 + this.score = (Integer) in.readValue(Integer.class.getClassLoader());
  345 + this.is_open = in.readString();
  346 + this.is_rec = in.readString();
  347 + this.content = in.readString();
  348 + this.class_json = in.readString();
  349 + this.create_time = (Integer) in.readValue(Integer.class.getClassLoader());
  350 + this.update_time = (Integer) in.readValue(Integer.class.getClassLoader());
  351 + this.pos_name = in.readString();
  352 + this.create_time_text = in.readString();
  353 + }
  354 +
  355 + public static final Creator<DataBean> CREATOR = new Creator<DataBean>() {
  356 + @Override
  357 + public DataBean createFromParcel(Parcel source) {
  358 + return new DataBean(source);
  359 + }
  360 +
  361 + @Override
  362 + public DataBean[] newArray(int size) {
  363 + return new DataBean[size];
  364 + }
  365 + };
279 } 366 }
280 } 367 }
281 } 368 }
@@ -58,12 +58,10 @@ class CourseListFragment(var courseData: TrainCourseData,var tranClassId:String) @@ -58,12 +58,10 @@ class CourseListFragment(var courseData: TrainCourseData,var tranClassId:String)
58 }) 58 })
59 } 59 }
60 TYPE_COURSE_DETAIL_ITEM_OFF -> { 60 TYPE_COURSE_DETAIL_ITEM_OFF -> {
61 - courseData.lessonOff?.apply {  
62 - for (p in lessonofflineclass) {  
63 - dataList.add(TrainCourseDetailItem(TYPE_COURSE_DETAIL_ITEM_OFF).apply {  
64 - lessonOff = p  
65 - })  
66 - } 61 + courseData.lessonOff?.let {
  62 + dataList.add(TrainCourseDetailItem(TYPE_COURSE_DETAIL_ITEM_OFF).apply {
  63 + lessonOff = it
  64 + })
67 } 65 }
68 } 66 }
69 } 67 }
@@ -21,7 +21,7 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.NoticeBean @@ -21,7 +21,7 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.NoticeBean
21 import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean 21 import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean
22 import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean 22 import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
23 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.HomeViewModel 23 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.HomeViewModel
24 -import com.br_technology.securitytrain_master.view.DialogNotice 24 +import com.br_technology.securitytrain_master.view.DialogTips
25 import com.br_technology.securitytrain_master.view.listener.OnItemClickListener 25 import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
26 import com.bumptech.glide.Glide 26 import com.bumptech.glide.Glide
27 import com.bumptech.glide.load.resource.bitmap.RoundedCorners 27 import com.bumptech.glide.load.resource.bitmap.RoundedCorners
@@ -50,8 +50,9 @@ class HomeFragment : @@ -50,8 +50,9 @@ class HomeFragment :
50 private var videoCourseAdapter: VideoCourseAdapter? = null 50 private var videoCourseAdapter: VideoCourseAdapter? = null
51 51
52 private val dialogNotice by lazy { 52 private val dialogNotice by lazy {
53 - DialogNotice(requireContext()) 53 + DialogTips(requireContext())
54 } 54 }
  55 +
55 override fun initDataObserver() { 56 override fun initDataObserver() {
56 //获取banner数据 57 //获取banner数据
57 mViewModel.mBannerBean.observe(this, { 58 mViewModel.mBannerBean.observe(this, {
@@ -71,7 +72,23 @@ class HomeFragment : @@ -71,7 +72,23 @@ class HomeFragment :
71 textView.setOnClickListener { 72 textView.setOnClickListener {
72 val position = textView.tag as Int 73 val position = textView.tag as Int
73 // 公告弹框 74 // 公告弹框
74 - dialogNotice.setTitle(data[position].des).show() 75 + dialogNotice.setData(data[position].title, data[position].des).show()
  76 + }
  77 + binding.flipperScan.addView(
  78 + textView, ViewGroup.LayoutParams(
  79 + ViewGroup.LayoutParams.MATCH_PARENT,
  80 + ViewGroup.LayoutParams.WRAP_CONTENT
  81 + )
  82 + )
  83 + }
  84 + for (news in data) {
  85 + val textView = TextView(context)
  86 + textView.maxLines = 1
  87 + textView.text = news.title
  88 + textView.ellipsize = TextUtils.TruncateAt.END
  89 + textView.setOnClickListener {
  90 + // 公告弹框
  91 + ToastUtils.s(requireContext(), "aaa")
75 } 92 }
76 binding.flipperScan.addView( 93 binding.flipperScan.addView(
77 textView, ViewGroup.LayoutParams( 94 textView, ViewGroup.LayoutParams(
@@ -80,22 +97,6 @@ class HomeFragment : @@ -80,22 +97,6 @@ class HomeFragment :
80 ) 97 )
81 ) 98 )
82 } 99 }
83 -// for (news in data) {  
84 -// val textView = TextView(context)  
85 -// textView.maxLines = 1  
86 -// textView.text = news.title  
87 -// textView.ellipsize = TextUtils.TruncateAt.END  
88 -// textView.setOnClickListener {  
89 -// // 公告弹框  
90 -// ToastUtils.s(requireContext(),"aaa")  
91 -// }  
92 -// binding.flipperScan.addView(  
93 -// textView, ViewGroup.LayoutParams(  
94 -// ViewGroup.LayoutParams.MATCH_PARENT,  
95 -// ViewGroup.LayoutParams.WRAP_CONTENT  
96 -// )  
97 -// )  
98 -// }  
99 if (data.size > 1) { 100 if (data.size > 1) {
100 binding.flipperScan.flipInterval = 3000 101 binding.flipperScan.flipInterval = 3000
101 binding.flipperScan.startFlipping() 102 binding.flipperScan.startFlipping()
@@ -223,13 +224,14 @@ class HomeFragment : @@ -223,13 +224,14 @@ class HomeFragment :
223 val data = videoLessonList!![position] 224 val data = videoLessonList!![position]
224 course.mLessonId = "${data.id}" 225 course.mLessonId = "${data.id}"
225 course.isTrainClass = false 226 course.isTrainClass = false
226 - course.type = data.type.toInt() 227 + course.type = 1
227 //视频详情 228 //视频详情
228 startActivity( 229 startActivity(
229 Intent( 230 Intent(
230 requireContext(), 231 requireContext(),
231 CourseDetailActivity::class.java 232 CourseDetailActivity::class.java
232 ).putExtra(ConstantParamKey.COURSE_BEAN, course) 233 ).putExtra(ConstantParamKey.COURSE_BEAN, course)
  234 + .putExtra(ConstantParamKey.COURSE_LESSON, data)
233 ) 235 )
234 } 236 }
235 recommendDataAdapter = RecommendDataAdapter() 237 recommendDataAdapter = RecommendDataAdapter()
1 package com.br_technology.securitytrain_master.ui.view.home.fragment 1 package com.br_technology.securitytrain_master.ui.view.home.fragment
2 2
  3 +import android.view.View
3 import com.br_technology.securitytrain_master.databinding.FragmentOnlineDetailBinding 4 import com.br_technology.securitytrain_master.databinding.FragmentOnlineDetailBinding
4 import com.br_technology.securitytrain_master.ui.bean.TrainClassDes 5 import com.br_technology.securitytrain_master.ui.bean.TrainClassDes
  6 +import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType
5 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.OnlineDetailFragmentViewModel 7 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.OnlineDetailFragmentViewModel
6 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment 8 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
7 9
@@ -10,7 +12,7 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment @@ -10,7 +12,7 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
10 * Author: Captain 12 * Author: Captain
11 * Description: 初见时你很迷人 13 * Description: 初见时你很迷人
12 */ 14 */
13 -class OnlineDetailFragment(val data: TrainClassDes) : 15 +class OnlineDetailFragment(val data: TrainClassDes, var type: Int) :
14 BaseLifeCycleFragment<OnlineDetailFragmentViewModel, FragmentOnlineDetailBinding>( 16 BaseLifeCycleFragment<OnlineDetailFragmentViewModel, FragmentOnlineDetailBinding>(
15 FragmentOnlineDetailBinding::inflate 17 FragmentOnlineDetailBinding::inflate
16 ) { 18 ) {
@@ -19,6 +21,9 @@ class OnlineDetailFragment(val data: TrainClassDes) : @@ -19,6 +21,9 @@ class OnlineDetailFragment(val data: TrainClassDes) :
19 21
20 override fun initData() { 22 override fun initData() {
21 super.initData() 23 super.initData()
  24 + if (TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_NORMAL == type) {
  25 + binding.llContent.visibility = View.GONE
  26 + }
22 binding.tvPos.text = data.pos 27 binding.tvPos.text = data.pos
23 binding.title.text = data.title 28 binding.title.text = data.title
24 binding.webView.loadData(data.content) 29 binding.webView.loadData(data.content)
  1 +package com.br_technology.securitytrain_master.view
  2 +
  3 +import android.app.Dialog
  4 +import android.content.Context
  5 +import android.os.Bundle
  6 +import android.view.LayoutInflater
  7 +import com.br_technology.securitytrain_master.R
  8 +import com.br_technology.securitytrain_master.databinding.DialogTipsBinding
  9 +import com.br_technology.securitytrain_master.expand.dp2px
  10 +import com.br_technology.securitytrain_master.expand.screenWidth
  11 +
  12 +/**
  13 + * Author by YSir
  14 + * Date on 2022/1/25.
  15 + * description
  16 + * PS: Not easy to write code, please indicate.
  17 + */
  18 +class DialogTips(context: Context) : Dialog(context, R.style.UserDefaultDialog) {
  19 + private val binding by lazy {
  20 + DialogTipsBinding.inflate(LayoutInflater.from(context))
  21 + }
  22 +
  23 + override fun onCreate(savedInstanceState: Bundle?) {
  24 + super.onCreate(savedInstanceState)
  25 + setContentView(binding.root)
  26 + val attributes = window?.attributes
  27 + attributes?.width = binding.root.screenWidth() - 80.dp2px()
  28 + // 点击区域外取消
  29 + setCanceledOnTouchOutside(false)
  30 + setCancelable(true)
  31 + binding.apply {
  32 + // 确定
  33 + tvEnsure.setOnClickListener {
  34 + dismiss()
  35 + }
  36 + }
  37 + }
  38 +
  39 + fun setData(title: String, content: String): DialogTips {
  40 + binding.tvTitle.text = title
  41 + binding.tvMention.loadData(content)
  42 + return this
  43 + }
  44 +}
@@ -2,8 +2,10 @@ package com.br_technology.securitytrain_master.view @@ -2,8 +2,10 @@ package com.br_technology.securitytrain_master.view
2 2
3 import android.content.Context 3 import android.content.Context
4 import android.util.AttributeSet 4 import android.util.AttributeSet
  5 +import android.view.View
  6 +import android.webkit.WebSettings
5 import android.webkit.WebView 7 import android.webkit.WebView
6 -import com.br_technology.securitytrain_master.expand.dp2px 8 +import com.br_technology.securitytrain_master.expand.TranslateUnit
7 import com.br_technology.securitytrain_master.util.HtmlConvert 9 import com.br_technology.securitytrain_master.util.HtmlConvert
8 import org.jsoup.Jsoup 10 import org.jsoup.Jsoup
9 11
@@ -16,17 +18,20 @@ class MyWebView(context: Context, attrs: AttributeSet?) : WebView(context, attrs @@ -16,17 +18,20 @@ class MyWebView(context: Context, attrs: AttributeSet?) : WebView(context, attrs
16 18
17 init { 19 init {
18 settings.javaScriptEnabled = true 20 settings.javaScriptEnabled = true
19 - settings.minimumFontSize = 14.dp2px()  
20 - settings.defaultFixedFontSize = 15.dp2px() 21 + settings.minimumFontSize = TranslateUnit.sp2px(context, 14f)
  22 + settings.defaultFixedFontSize = TranslateUnit.sp2px(context, 15f)
21 settings.useWideViewPort = true 23 settings.useWideViewPort = true
22 settings.loadWithOverviewMode = true 24 settings.loadWithOverviewMode = true
23 settings.allowFileAccess = true 25 settings.allowFileAccess = true
24 settings.allowFileAccessFromFileURLs = true 26 settings.allowFileAccessFromFileURLs = true
25 settings.allowUniversalAccessFromFileURLs = true 27 settings.allowUniversalAccessFromFileURLs = true
  28 + settings.layoutAlgorithm = WebSettings.LayoutAlgorithm.NARROW_COLUMNS
  29 + scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY
26 30
27 isScrollContainer = false 31 isScrollContainer = false
28 isVerticalScrollBarEnabled = false 32 isVerticalScrollBarEnabled = false
29 isHorizontalScrollBarEnabled = false 33 isHorizontalScrollBarEnabled = false
  34 + setBackgroundColor(0); // 设置背景色
30 } 35 }
31 36
32 37
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="wrap_content"
  5 + android:layout_gravity="center">
  6 +
  7 + <LinearLayout
  8 + android:layout_width="match_parent"
  9 + android:layout_height="wrap_content"
  10 + android:background="@drawable/solid_96_4"
  11 + android:backgroundTint="@color/white"
  12 + android:gravity="center_vertical"
  13 + android:orientation="vertical">
  14 +
  15 + <TextView
  16 + android:id="@+id/tv_title"
  17 + android:layout_width="match_parent"
  18 + android:layout_height="wrap_content"
  19 + android:layout_marginTop="30dp"
  20 + android:gravity="center"
  21 + android:textStyle="bold"
  22 + android:padding="12dp"
  23 + android:textColor="@color/black"
  24 + android:textSize="20sp" />
  25 +
  26 + <com.br_technology.securitytrain_master.view.MyWebView
  27 + android:id="@+id/tv_mention"
  28 + android:layout_marginStart="@dimen/dp_10"
  29 + android:layout_marginEnd="10dp"
  30 + android:layout_width="match_parent"
  31 + android:layout_height="220dp"/>
  32 +
  33 + <TextView
  34 + android:id="@+id/tv_ensure"
  35 + android:layout_width="130dp"
  36 + android:layout_height="wrap_content"
  37 + android:layout_gravity="center_horizontal"
  38 + android:layout_marginBottom="16dp"
  39 + android:gravity="center"
  40 + android:paddingTop="8dp"
  41 + android:paddingBottom="8dp"
  42 + android:layout_marginTop="10dp"
  43 + android:background="@drawable/solid_25_4"
  44 + android:paddingStart="30dp"
  45 + android:paddingEnd="30dp"
  46 + android:text="确认"
  47 + android:textColor="@color/white"
  48 + android:textSize="16sp" />
  49 + </LinearLayout>
  50 +</FrameLayout>
@@ -7,16 +7,18 @@ @@ -7,16 +7,18 @@
7 7
8 <androidx.core.widget.NestedScrollView 8 <androidx.core.widget.NestedScrollView
9 android:layout_width="match_parent" 9 android:layout_width="match_parent"
10 - android:layout_height="match_parent"> 10 + android:layout_height="match_parent"
  11 + android:paddingStart="16dp"
  12 + android:paddingEnd="16dp">
11 13
12 <LinearLayout 14 <LinearLayout
13 android:layout_width="match_parent" 15 android:layout_width="match_parent"
14 android:layout_height="match_parent" 16 android:layout_height="match_parent"
15 android:orientation="vertical"> 17 android:orientation="vertical">
16 18
17 -  
18 <LinearLayout 19 <LinearLayout
19 - android:layout_width="wrap_content" 20 + android:id="@+id/ll_content"
  21 + android:layout_width="match_parent"
20 android:layout_height="wrap_content" 22 android:layout_height="wrap_content"
21 android:layout_gravity="center_horizontal" 23 android:layout_gravity="center_horizontal"
22 android:layout_marginTop="16dp" 24 android:layout_marginTop="16dp"
@@ -38,15 +40,16 @@ @@ -38,15 +40,16 @@
38 <LinearLayout 40 <LinearLayout
39 android:layout_width="match_parent" 41 android:layout_width="match_parent"
40 android:layout_height="wrap_content" 42 android:layout_height="wrap_content"
41 - android:orientation="horizontal"> 43 + android:orientation="horizontal"
  44 + android:paddingStart="16dp">
42 45
43 <TextView 46 <TextView
44 android:id="@+id/tv_pos" 47 android:id="@+id/tv_pos"
45 android:layout_width="wrap_content" 48 android:layout_width="wrap_content"
46 android:layout_height="wrap_content" 49 android:layout_height="wrap_content"
47 - android:layout_marginStart="16dp"  
48 - android:layout_marginEnd="16dp" 50 + android:layout_marginStart="24dp"
49 android:layout_marginTop="8dp" 51 android:layout_marginTop="8dp"
  52 + android:layout_marginEnd="16dp"
50 android:ellipsize="end" 53 android:ellipsize="end"
51 android:maxLines="1" 54 android:maxLines="1"
52 android:text="@string/shiyong" 55 android:text="@string/shiyong"
@@ -62,20 +65,15 @@ @@ -62,20 +65,15 @@
62 android:layout_width="match_parent" 65 android:layout_width="match_parent"
63 android:layout_height="wrap_content" 66 android:layout_height="wrap_content"
64 android:layout_gravity="center_horizontal" 67 android:layout_gravity="center_horizontal"
65 - android:layout_marginStart="16dp"  
66 android:layout_marginTop="12dp" 68 android:layout_marginTop="12dp"
67 - android:layout_marginEnd="16dp"  
68 android:textColor="@color/color_32" 69 android:textColor="@color/color_32"
69 android:textSize="17sp" 70 android:textSize="17sp"
70 tools:text="话费的回复是单号发大师傅但是感觉还是风格的" /> 71 tools:text="话费的回复是单号发大师傅但是感觉还是风格的" />
71 72
72 <com.br_technology.securitytrain_master.view.MyWebView 73 <com.br_technology.securitytrain_master.view.MyWebView
73 android:id="@+id/web_view" 74 android:id="@+id/web_view"
74 - android:layout_width="match_parent"  
75 - android:layout_height="match_parent"  
76 - android:layout_marginStart="16dp"  
77 - android:layout_marginTop="16dp"  
78 - android:layout_marginEnd="16dp" /> 75 + android:layout_width="fill_parent"
  76 + android:layout_height="match_parent" />
79 </LinearLayout> 77 </LinearLayout>
80 </androidx.core.widget.NestedScrollView> 78 </androidx.core.widget.NestedScrollView>
81 </LinearLayout> 79 </LinearLayout>