|
@@ -4,7 +4,6 @@ import android.view.MotionEvent
|
|
|
import android.view.View
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
-import com.chad.library.adapter.base.listener.OnItemChildClickListener
|
|
|
import com.chad.library.adapter.base.listener.OnItemClickListener
|
|
|
import com.cooleshow.base.ui.fragment.BaseMVPFragment
|
|
|
import com.cooleshow.base.utils.SizeUtils
|
|
@@ -13,12 +12,13 @@ import com.cooleshow.base.utils.ToastUtils
|
|
|
import com.cooleshow.teacher.R
|
|
|
import com.cooleshow.teacher.adapter.CourseTableListAdapter
|
|
|
import com.cooleshow.teacher.bean.CourseTableListBean
|
|
|
+import com.cooleshow.teacher.contract.CourseTableContract
|
|
|
import com.cooleshow.teacher.contract.HomeContract
|
|
|
import com.cooleshow.teacher.databinding.FragmentCourseTableLayoutBinding
|
|
|
+import com.cooleshow.teacher.presenter.main.CourseTablePresenter
|
|
|
import com.cooleshow.teacher.presenter.main.HomePresenter
|
|
|
import com.cooleshow.teacher.widgets.CalendarExpandDecoration
|
|
|
import com.cooleshow.teacher.widgets.CalendarShrinkDecoration
|
|
|
-import com.cooleshow.teacher.widgets.CourseTableArrowView
|
|
|
import com.haibin.calendarview.CalendarView
|
|
|
import kotlinx.android.synthetic.main.fragment_course_table_layout.*
|
|
|
import java.util.*
|
|
@@ -27,15 +27,17 @@ import java.util.*
|
|
|
/**
|
|
|
* Author by pq, Date on 2022/4/20.
|
|
|
*/
|
|
|
-class CourseTableFragment : BaseMVPFragment<FragmentCourseTableLayoutBinding, HomePresenter>(),
|
|
|
+class CourseTableFragment :
|
|
|
+ BaseMVPFragment<FragmentCourseTableLayoutBinding, CourseTablePresenter>(),
|
|
|
HomeContract.HomeView, CalendarView.OnCalendarSelectListener,
|
|
|
CalendarView.OnCalendarInterceptListener, CalendarView.OnMonthChangeListener,
|
|
|
- CalendarView.OnViewChangeListener {
|
|
|
+ CalendarView.OnViewChangeListener, CourseTableContract.CourseTableView {
|
|
|
private lateinit var date: Date
|
|
|
private lateinit var calendarDate: String
|
|
|
private lateinit var calendarExpandDecoration: CalendarExpandDecoration
|
|
|
private lateinit var calendarShrinkDecoration: CalendarShrinkDecoration
|
|
|
private lateinit var adapter: CourseTableListAdapter
|
|
|
+ private var day: Int = -1;
|
|
|
|
|
|
override fun getLayoutView(): FragmentCourseTableLayoutBinding {
|
|
|
return FragmentCourseTableLayoutBinding.inflate(layoutInflater)
|
|
@@ -65,7 +67,10 @@ class CourseTableFragment : BaseMVPFragment<FragmentCourseTableLayoutBinding, Ho
|
|
|
MotionEvent.ACTION_UP -> {
|
|
|
val right: Int = rv.width / 2 - SizeUtils.dp2px(16f)
|
|
|
val left: Int = rv.width / 2 + SizeUtils.dp2px(16f)
|
|
|
- if (right < e.x && e.x < left && e.y < SizeUtils.dp2px(30f) && y < SizeUtils.dp2px(30f)) {
|
|
|
+ if (right < e.x && e.x < left && e.y < SizeUtils.dp2px(30f) && y < SizeUtils.dp2px(
|
|
|
+ 30f
|
|
|
+ )
|
|
|
+ ) {
|
|
|
if (mViewBinding.calendarLayout.isExpand) {
|
|
|
mViewBinding.calendarLayout.shrink()
|
|
|
} else {
|
|
@@ -80,6 +85,7 @@ class CourseTableFragment : BaseMVPFragment<FragmentCourseTableLayoutBinding, Ho
|
|
|
})
|
|
|
adapter.setOnItemClickListener(OnItemClickListener() { adapter, view, position ->
|
|
|
ToastUtils.showShort("点击position:" + position)
|
|
|
+ presenter.getCourseScheduleDateByMonth(calendarDate)
|
|
|
})
|
|
|
addTestData()
|
|
|
}
|
|
@@ -100,17 +106,16 @@ class CourseTableFragment : BaseMVPFragment<FragmentCourseTableLayoutBinding, Ho
|
|
|
val calendar = Calendar.getInstance()
|
|
|
val year = calendar[Calendar.YEAR]
|
|
|
val month = calendar[Calendar.MONTH] + 1
|
|
|
- val day = calendar[Calendar.DAY_OF_MONTH]
|
|
|
- var mCalendarView = mViewBinding.calendarView;
|
|
|
+ day = calendar[Calendar.DAY_OF_MONTH]
|
|
|
if ((mViewBinding.calendarView.getCurDay() !== day || mViewBinding.calendarView.getCurMonth() !== month || mViewBinding.calendarView.getCurYear() !== year)) {
|
|
|
- mCalendarView.updateCurrentDate()
|
|
|
- mCalendarView.clearSingleSelect()
|
|
|
- setMontAndDay(year, month, day)
|
|
|
- date = TimeUtils.getNowDate()
|
|
|
- calendarDate = TimeUtils.getNowString()
|
|
|
+ mViewBinding.calendarView.updateCurrentDate()
|
|
|
+ mViewBinding.calendarView.clearSingleSelect()
|
|
|
}
|
|
|
-// presenter.getCourseScheduleDateByMonth(calendarDate, false)
|
|
|
-// presenter.getCourseSchedulesWithDate(date, false)
|
|
|
+ setMontAndDay(year, month, day)
|
|
|
+ date = TimeUtils.getNowDate()
|
|
|
+ calendarDate = TimeUtils.getNowString(TimeUtils.getSafeDateFormat("yyyy-MM"))
|
|
|
+ presenter.getCourseScheduleDateByMonth(calendarDate)
|
|
|
+ presenter.getCourseSchedulesWithDate(date)
|
|
|
}
|
|
|
|
|
|
private fun setMontAndDay(year: Int, month: Int, day: Int) {
|
|
@@ -122,14 +127,14 @@ class CourseTableFragment : BaseMVPFragment<FragmentCourseTableLayoutBinding, Ho
|
|
|
mViewBinding.tvCurrentDate.text = span
|
|
|
}
|
|
|
|
|
|
- override fun createPresenter(): HomePresenter {
|
|
|
- return HomePresenter()
|
|
|
- }
|
|
|
-
|
|
|
override fun onCalendarOutOfRange(calendar: com.haibin.calendarview.Calendar?) {
|
|
|
}
|
|
|
|
|
|
override fun onCalendarSelect(calendar: com.haibin.calendarview.Calendar?, isClick: Boolean) {
|
|
|
+ val year = calendar!!.year
|
|
|
+ val month = calendar!!.month
|
|
|
+ val day = calendar!!.day
|
|
|
+ setMontAndDay(year, month, day)
|
|
|
}
|
|
|
|
|
|
override fun onCalendarIntercept(calendar: com.haibin.calendarview.Calendar?): Boolean {
|
|
@@ -143,6 +148,7 @@ class CourseTableFragment : BaseMVPFragment<FragmentCourseTableLayoutBinding, Ho
|
|
|
}
|
|
|
|
|
|
override fun onMonthChange(year: Int, month: Int) {
|
|
|
+ setMontAndDay(year, month, day)
|
|
|
}
|
|
|
|
|
|
override fun onViewChange(isMonthView: Boolean) {
|
|
@@ -159,4 +165,19 @@ class CourseTableFragment : BaseMVPFragment<FragmentCourseTableLayoutBinding, Ho
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ override fun createPresenter(): CourseTablePresenter {
|
|
|
+ return CourseTablePresenter()
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据月份查询当月有课的日期
|
|
|
+ */
|
|
|
+ override fun onGetCourseDateByMonthSuccess(datas: MutableList<String>?) {
|
|
|
+ if (isDetached) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (datas?.size != 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|