forked from github/wulkanowy-mirror
Fix elevation overlay on pre-lolipop (#475)
This commit is contained in:
parent
bb9ea7eda1
commit
0aac6459f3
@ -17,11 +17,13 @@ import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.attendance.summary.AttendanceSummaryFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.setOnItemClickListener
|
||||
import kotlinx.android.synthetic.main.fragment_attendance.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildView, MainView.TitledView {
|
||||
class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildView,
|
||||
MainView.TitledView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: AttendancePresenter
|
||||
@ -35,14 +37,11 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
||||
fun newInstance() = AttendanceFragment()
|
||||
}
|
||||
|
||||
override val titleStringId: Int
|
||||
get() = R.string.attendance_title
|
||||
override val titleStringId get() = R.string.attendance_title
|
||||
|
||||
override val isViewEmpty: Boolean
|
||||
get() = attendanceAdapter.isEmpty
|
||||
override val isViewEmpty get() = attendanceAdapter.isEmpty
|
||||
|
||||
override val currentStackSize: Int?
|
||||
get() = (activity as? MainActivity)?.currentStackSize
|
||||
override val currentStackSize get() = (activity as? MainActivity)?.currentStackSize
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -60,19 +59,21 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
attendanceAdapter.setOnItemClickListener { presenter.onAttendanceItemSelected(it) }
|
||||
attendanceAdapter.setOnItemClickListener(presenter::onAttendanceItemSelected)
|
||||
|
||||
attendanceRecycler.run {
|
||||
with(attendanceRecycler) {
|
||||
layoutManager = SmoothScrollLinearLayoutManager(context)
|
||||
adapter = attendanceAdapter
|
||||
addItemDecoration(FlexibleItemDecoration(context)
|
||||
.withDefaultDivider()
|
||||
.withDrawDividerOnLastItem(false)
|
||||
)
|
||||
.withDrawDividerOnLastItem(false))
|
||||
}
|
||||
attendanceSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
|
||||
attendanceSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
attendancePreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||
attendanceNextButton.setOnClickListener { presenter.onNextDay() }
|
||||
|
||||
attendanceNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
|
@ -15,6 +15,7 @@ import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.setOnItemSelectedListener
|
||||
import kotlinx.android.synthetic.main.fragment_attendance_summary.*
|
||||
import javax.inject.Inject
|
||||
@ -35,11 +36,9 @@ class AttendanceSummaryFragment : BaseFragment(), AttendanceSummaryView, MainVie
|
||||
fun newInstance() = AttendanceSummaryFragment()
|
||||
}
|
||||
|
||||
override val titleStringId: Int
|
||||
get() = R.string.attendance_title
|
||||
override val titleStringId get() = R.string.attendance_title
|
||||
|
||||
override val isViewEmpty
|
||||
get() = attendanceSummaryAdapter.isEmpty
|
||||
override val isViewEmpty get() = attendanceSummaryAdapter.isEmpty
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_attendance_summary, container, false)
|
||||
@ -52,25 +51,26 @@ class AttendanceSummaryFragment : BaseFragment(), AttendanceSummaryView, MainVie
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
attendanceSummaryRecycler.run {
|
||||
with(attendanceSummaryRecycler) {
|
||||
layoutManager = SmoothScrollLinearLayoutManager(context)
|
||||
adapter = attendanceSummaryAdapter
|
||||
}
|
||||
attendanceSummarySwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
|
||||
context?.let {
|
||||
subjectsAdapter = ArrayAdapter(it, android.R.layout.simple_spinner_item, ArrayList<String>())
|
||||
subjectsAdapter.setDropDownViewResource(R.layout.item_attendance_summary_subject)
|
||||
}
|
||||
attendanceSummarySwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
|
||||
attendanceSummarySubjects.run {
|
||||
subjectsAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, mutableListOf())
|
||||
subjectsAdapter.setDropDownViewResource(R.layout.item_attendance_summary_subject)
|
||||
|
||||
with(attendanceSummarySubjects) {
|
||||
adapter = subjectsAdapter
|
||||
setOnItemSelectedListener { presenter.onSubjectSelected((it as TextView).text.toString()) }
|
||||
setOnItemSelectedListener<TextView> { presenter.onSubjectSelected(it?.text?.toString()) }
|
||||
}
|
||||
|
||||
attendanceSummarySubjectsContainer.setElevationCompat(requireContext().dpToPx(1f))
|
||||
}
|
||||
|
||||
override fun updateSubjects(data: ArrayList<String>) {
|
||||
subjectsAdapter.run {
|
||||
with(subjectsAdapter) {
|
||||
clear()
|
||||
addAll(data)
|
||||
notifyDataSetChanged()
|
||||
@ -78,9 +78,9 @@ class AttendanceSummaryFragment : BaseFragment(), AttendanceSummaryView, MainVie
|
||||
}
|
||||
|
||||
override fun updateDataSet(data: List<AttendanceSummaryItem>, header: AttendanceSummaryScrollableHeader) {
|
||||
attendanceSummaryAdapter.apply {
|
||||
with(attendanceSummaryAdapter) {
|
||||
updateDataSet(data, true)
|
||||
removeAllScrollableHeaders()
|
||||
removeAllScrollableFooters()
|
||||
addScrollableHeader(header)
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class AttendanceSummaryPresenter @Inject constructor(
|
||||
loadData(currentSubjectId, true)
|
||||
}
|
||||
|
||||
fun onSubjectSelected(name: String) {
|
||||
fun onSubjectSelected(name: String?) {
|
||||
Timber.i("Select attendance summary subject $name")
|
||||
view?.run {
|
||||
showContent(false)
|
||||
|
@ -16,6 +16,7 @@ import io.github.wulkanowy.data.db.entities.Exam
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.setOnItemClickListener
|
||||
import kotlinx.android.synthetic.main.fragment_exam.*
|
||||
import javax.inject.Inject
|
||||
@ -34,11 +35,9 @@ class ExamFragment : BaseFragment(), ExamView, MainView.MainChildView, MainView.
|
||||
fun newInstance() = ExamFragment()
|
||||
}
|
||||
|
||||
override val titleStringId: Int
|
||||
get() = R.string.exam_title
|
||||
override val titleStringId get() = R.string.exam_title
|
||||
|
||||
override val isViewEmpty: Boolean
|
||||
get() = examAdapter.isEmpty
|
||||
override val isViewEmpty get() = examAdapter.isEmpty
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_exam, container, false)
|
||||
@ -51,20 +50,21 @@ class ExamFragment : BaseFragment(), ExamView, MainView.MainChildView, MainView.
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
examAdapter.run {
|
||||
setOnItemClickListener { presenter.onExamItemSelected(it) }
|
||||
}
|
||||
examRecycler.run {
|
||||
examAdapter.setOnItemClickListener(presenter::onExamItemSelected)
|
||||
|
||||
with(examRecycler) {
|
||||
layoutManager = SmoothScrollLinearLayoutManager(context)
|
||||
adapter = examAdapter
|
||||
addItemDecoration(FlexibleItemDecoration(context)
|
||||
.withDefaultDivider(R.layout.item_exam)
|
||||
.withDrawDividerOnLastItem(false)
|
||||
)
|
||||
.withDrawDividerOnLastItem(false))
|
||||
}
|
||||
examSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
|
||||
examSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
examPreviousButton.setOnClickListener { presenter.onPreviousWeek() }
|
||||
examNextButton.setOnClickListener { presenter.onNextWeek() }
|
||||
|
||||
examNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||
}
|
||||
|
||||
override fun hideRefresh() {
|
||||
|
@ -17,6 +17,7 @@ import io.github.wulkanowy.ui.modules.grade.details.GradeDetailsFragment
|
||||
import io.github.wulkanowy.ui.modules.grade.statistics.GradeStatisticsFragment
|
||||
import io.github.wulkanowy.ui.modules.grade.summary.GradeSummaryFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.setOnSelectPageListener
|
||||
import kotlinx.android.synthetic.main.fragment_grade.*
|
||||
import javax.inject.Inject
|
||||
@ -37,11 +38,9 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
||||
fun newInstance() = GradeFragment()
|
||||
}
|
||||
|
||||
override val titleStringId: Int
|
||||
get() = R.string.grade_title
|
||||
override val titleStringId get() = R.string.grade_title
|
||||
|
||||
override val currentPageIndex: Int
|
||||
get() = gradeViewPager.currentItem
|
||||
override val currentPageIndex get() = gradeViewPager.currentItem
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -64,7 +63,7 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
pagerAdapter.apply {
|
||||
with(pagerAdapter) {
|
||||
containerId = gradeViewPager.id
|
||||
addFragmentsWithTitle(mapOf(
|
||||
GradeDetailsFragment.newInstance() to getString(R.string.all_details),
|
||||
@ -73,14 +72,18 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
||||
))
|
||||
}
|
||||
|
||||
gradeViewPager.run {
|
||||
with(gradeViewPager) {
|
||||
adapter = pagerAdapter
|
||||
offscreenPageLimit = 3
|
||||
setOnSelectPageListener { presenter.onPageSelected(it) }
|
||||
setOnSelectPageListener(presenter::onPageSelected)
|
||||
}
|
||||
|
||||
gradeTabLayout.setupWithViewPager(gradeViewPager)
|
||||
gradeSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
with(gradeTabLayout) {
|
||||
setupWithViewPager(gradeViewPager)
|
||||
setElevationCompat(context.dpToPx(4f))
|
||||
}
|
||||
|
||||
gradeSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
@ -118,19 +121,19 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
||||
}
|
||||
|
||||
override fun showSemesterDialog(selectedIndex: Int) {
|
||||
arrayOf(getString(R.string.grade_semester, 1),
|
||||
getString(R.string.grade_semester, 2)).also { array ->
|
||||
context?.let {
|
||||
AlertDialog.Builder(it)
|
||||
.setSingleChoiceItems(array, selectedIndex) { dialog, which ->
|
||||
presenter.onSemesterSelected(which)
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setTitle(R.string.grade_switch_semester)
|
||||
.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
||||
.show()
|
||||
val choices = arrayOf(
|
||||
getString(R.string.grade_semester, 1),
|
||||
getString(R.string.grade_semester, 2)
|
||||
)
|
||||
|
||||
AlertDialog.Builder(requireContext())
|
||||
.setSingleChoiceItems(choices, selectedIndex) { dialog, which ->
|
||||
presenter.onSemesterSelected(which)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
.setTitle(R.string.grade_switch_semester)
|
||||
.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
||||
.show()
|
||||
}
|
||||
|
||||
fun onChildRefresh() {
|
||||
|
@ -19,6 +19,7 @@ import io.github.wulkanowy.data.db.entities.GradeStatistics
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
||||
import io.github.wulkanowy.ui.modules.grade.GradeView
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||
import io.github.wulkanowy.utils.setOnItemSelectedListener
|
||||
import kotlinx.android.synthetic.main.fragment_grade_statistics.*
|
||||
@ -37,8 +38,7 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
||||
fun newInstance() = GradeStatisticsFragment()
|
||||
}
|
||||
|
||||
override val isViewEmpty
|
||||
get() = gradeStatisticsChart.isEmpty
|
||||
override val isViewEmpty get() = gradeStatisticsChart.isEmpty
|
||||
|
||||
private lateinit var gradeColors: List<Pair<Int, Int>>
|
||||
|
||||
@ -75,7 +75,7 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
gradeStatisticsChart.run {
|
||||
with(gradeStatisticsChart) {
|
||||
description.isEnabled = false
|
||||
setHoleColor(context.getThemeAttrColor(android.R.attr.windowBackground))
|
||||
setCenterTextColor(context.getThemeAttrColor(android.R.attr.textColorPrimary))
|
||||
@ -84,21 +84,21 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
||||
legend.textColor = context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
||||
}
|
||||
|
||||
context?.let {
|
||||
subjectsAdapter = ArrayAdapter(it, android.R.layout.simple_spinner_item, ArrayList<String>())
|
||||
subjectsAdapter.setDropDownViewResource(R.layout.item_attendance_summary_subject)
|
||||
}
|
||||
subjectsAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, mutableListOf())
|
||||
subjectsAdapter.setDropDownViewResource(R.layout.item_attendance_summary_subject)
|
||||
|
||||
gradeStatisticsSubjects.run {
|
||||
with(gradeStatisticsSubjects) {
|
||||
adapter = subjectsAdapter
|
||||
setOnItemSelectedListener { presenter.onSubjectSelected((it as TextView).text.toString()) }
|
||||
setOnItemSelectedListener<TextView> { presenter.onSubjectSelected(it?.text?.toString()) }
|
||||
}
|
||||
|
||||
gradeStatisticsSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
gradeStatisticsSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
|
||||
gradeStatisticsSubjectsContainer.setElevationCompat(requireContext().dpToPx(1f))
|
||||
}
|
||||
|
||||
override fun updateSubjects(data: ArrayList<String>) {
|
||||
subjectsAdapter.run {
|
||||
with(subjectsAdapter) {
|
||||
clear()
|
||||
addAll(data)
|
||||
notifyDataSetChanged()
|
||||
@ -202,7 +202,7 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putBoolean(GradeStatisticsFragment.SAVED_CHART_TYPE, presenter.currentIsSemester)
|
||||
outState.putBoolean(SAVED_CHART_TYPE, presenter.currentIsSemester)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -62,7 +62,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
view?.notifyParentRefresh()
|
||||
}
|
||||
|
||||
fun onSubjectSelected(name: String) {
|
||||
fun onSubjectSelected(name: String?) {
|
||||
Timber.i("Select grade stats subject $name")
|
||||
view?.run {
|
||||
showContent(false)
|
||||
@ -71,8 +71,8 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
showEmpty(false)
|
||||
clearView()
|
||||
}
|
||||
(subjects.singleOrNull { it.name == name }?.name).let {
|
||||
if (it != currentSubjectName) loadData(currentSemesterId, name, currentIsSemester)
|
||||
(subjects.singleOrNull { it.name == name }?.name)?.let {
|
||||
if (it != currentSubjectName) loadData(currentSemesterId, it, currentIsSemester)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import io.github.wulkanowy.data.db.entities.Homework
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.setOnItemClickListener
|
||||
import kotlinx.android.synthetic.main.fragment_homework.*
|
||||
import javax.inject.Inject
|
||||
@ -31,8 +32,7 @@ class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
||||
fun newInstance() = HomeworkFragment()
|
||||
}
|
||||
|
||||
override val titleStringId: Int
|
||||
get() = R.string.homework_title
|
||||
override val titleStringId get() = R.string.homework_title
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_homework, container, false)
|
||||
@ -45,21 +45,21 @@ class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
homeworkAdapter.run {
|
||||
setOnItemClickListener { presenter.onHomeworkItemSelected(it) }
|
||||
}
|
||||
homeworkAdapter.setOnItemClickListener(presenter::onHomeworkItemSelected)
|
||||
|
||||
homeworkRecycler.run {
|
||||
with(homeworkRecycler) {
|
||||
layoutManager = SmoothScrollLinearLayoutManager(context)
|
||||
adapter = homeworkAdapter
|
||||
addItemDecoration(FlexibleItemDecoration(context)
|
||||
.withDefaultDivider()
|
||||
.withDrawDividerOnLastItem(false)
|
||||
)
|
||||
.withDrawDividerOnLastItem(false))
|
||||
}
|
||||
homeworkSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
|
||||
homeworkSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
homeworkPreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||
homeworkNextButton.setOnClickListener { presenter.onNextDay() }
|
||||
|
||||
homeworkNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||
}
|
||||
|
||||
override fun updateData(data: List<HomeworkItem>) {
|
||||
@ -110,7 +110,7 @@ class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putLong(HomeworkFragment.SAVED_DATE_KEY, presenter.currentDate.toEpochDay())
|
||||
outState.putLong(SAVED_DATE_KEY, presenter.currentDate.toEpochDay())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -16,6 +16,7 @@ import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.ui.modules.message.send.SendMessageActivity
|
||||
import io.github.wulkanowy.ui.modules.message.tab.MessageTabFragment
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.setOnSelectPageListener
|
||||
import kotlinx.android.synthetic.main.fragment_message.*
|
||||
import javax.inject.Inject
|
||||
@ -32,11 +33,9 @@ class MessageFragment : BaseFragment(), MessageView, MainView.TitledView {
|
||||
fun newInstance() = MessageFragment()
|
||||
}
|
||||
|
||||
override val titleStringId: Int
|
||||
get() = R.string.message_title
|
||||
override val titleStringId get() = R.string.message_title
|
||||
|
||||
override val currentPageIndex: Int
|
||||
get() = messageViewPager.currentItem
|
||||
override val currentPageIndex get() = messageViewPager.currentItem
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_message, container, false)
|
||||
@ -48,7 +47,7 @@ class MessageFragment : BaseFragment(), MessageView, MainView.TitledView {
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
pagerAdapter.apply {
|
||||
with(pagerAdapter) {
|
||||
containerId = messageViewPager.id
|
||||
addFragmentsWithTitle(mapOf(
|
||||
MessageTabFragment.newInstance(RECEIVED) to getString(R.string.message_inbox),
|
||||
@ -57,12 +56,16 @@ class MessageFragment : BaseFragment(), MessageView, MainView.TitledView {
|
||||
))
|
||||
}
|
||||
|
||||
messageViewPager.run {
|
||||
with(messageViewPager) {
|
||||
adapter = pagerAdapter
|
||||
offscreenPageLimit = 2
|
||||
setOnSelectPageListener { presenter.onPageSelected(it) }
|
||||
setOnSelectPageListener(presenter::onPageSelected)
|
||||
}
|
||||
|
||||
with(messageTabLayout) {
|
||||
setupWithViewPager(messageViewPager)
|
||||
setElevationCompat(context.dpToPx(4f))
|
||||
}
|
||||
messageTabLayout.setupWithViewPager(messageViewPager)
|
||||
|
||||
openSendMessageButton.setOnClickListener { presenter.onSendMessageButtonClicked() }
|
||||
}
|
||||
|
@ -17,11 +17,13 @@ import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.ui.modules.timetable.completed.CompletedLessonsFragment
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.setOnItemClickListener
|
||||
import kotlinx.android.synthetic.main.fragment_timetable.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class TimetableFragment : BaseFragment(), TimetableView, MainView.MainChildView, MainView.TitledView {
|
||||
class TimetableFragment : BaseFragment(), TimetableView, MainView.MainChildView,
|
||||
MainView.TitledView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: TimetablePresenter
|
||||
@ -35,17 +37,13 @@ class TimetableFragment : BaseFragment(), TimetableView, MainView.MainChildView,
|
||||
fun newInstance() = TimetableFragment()
|
||||
}
|
||||
|
||||
override val titleStringId: Int
|
||||
get() = R.string.timetable_title
|
||||
override val titleStringId get() = R.string.timetable_title
|
||||
|
||||
override val roomString: String
|
||||
get() = getString(R.string.timetable_room)
|
||||
override val roomString get() = getString(R.string.timetable_room)
|
||||
|
||||
override val isViewEmpty: Boolean
|
||||
get() = timetableAdapter.isEmpty
|
||||
override val isViewEmpty get() = timetableAdapter.isEmpty
|
||||
|
||||
override val currentStackSize: Int?
|
||||
get() = (activity as? MainActivity)?.currentStackSize
|
||||
override val currentStackSize get() = (activity as? MainActivity)?.currentStackSize
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -63,11 +61,9 @@ class TimetableFragment : BaseFragment(), TimetableView, MainView.MainChildView,
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
timetableAdapter.run {
|
||||
setOnItemClickListener { presenter.onTimetableItemSelected(it) }
|
||||
}
|
||||
timetableAdapter.setOnItemClickListener(presenter::onTimetableItemSelected)
|
||||
|
||||
timetableRecycler.run {
|
||||
with(timetableRecycler) {
|
||||
layoutManager = SmoothScrollLinearLayoutManager(context)
|
||||
adapter = timetableAdapter
|
||||
addItemDecoration(FlexibleItemDecoration(context)
|
||||
@ -75,9 +71,12 @@ class TimetableFragment : BaseFragment(), TimetableView, MainView.MainChildView,
|
||||
.withDrawDividerOnLastItem(false)
|
||||
)
|
||||
}
|
||||
timetableSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
|
||||
timetableSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
timetablePreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||
timetableNextButton.setOnClickListener { presenter.onNextDay() }
|
||||
|
||||
timetableNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
|
@ -12,6 +12,7 @@ import io.github.wulkanowy.data.db.entities.CompletedLesson
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.getCompatDrawable
|
||||
import io.github.wulkanowy.utils.setOnItemClickListener
|
||||
import kotlinx.android.synthetic.main.fragment_timetable_completed.*
|
||||
@ -31,11 +32,9 @@ class CompletedLessonsFragment : BaseFragment(), CompletedLessonsView, MainView.
|
||||
fun newInstance() = CompletedLessonsFragment()
|
||||
}
|
||||
|
||||
override val titleStringId: Int
|
||||
get() = R.string.completed_lessons_title
|
||||
override val titleStringId get() = R.string.completed_lessons_title
|
||||
|
||||
override val isViewEmpty
|
||||
get() = completedLessonsAdapter.isEmpty
|
||||
override val isViewEmpty get() = completedLessonsAdapter.isEmpty
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_timetable_completed, container, false)
|
||||
@ -48,17 +47,18 @@ class CompletedLessonsFragment : BaseFragment(), CompletedLessonsView, MainView.
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
completedLessonsAdapter.run {
|
||||
setOnItemClickListener { presenter.onCompletedLessonsItemSelected(it) }
|
||||
}
|
||||
completedLessonsAdapter.setOnItemClickListener(presenter::onCompletedLessonsItemSelected)
|
||||
|
||||
completedLessonsRecycler.run {
|
||||
with(completedLessonsRecycler) {
|
||||
layoutManager = SmoothScrollLinearLayoutManager(context)
|
||||
adapter = completedLessonsAdapter
|
||||
}
|
||||
completedLessonsSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
|
||||
completedLessonsSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
completedLessonsPreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||
completedLessonsNextButton.setOnClickListener { presenter.onNextDay() }
|
||||
|
||||
completedLessonsNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||
}
|
||||
|
||||
override fun updateData(data: List<CompletedLessonItem>) {
|
||||
@ -82,10 +82,8 @@ class CompletedLessonsFragment : BaseFragment(), CompletedLessonsView, MainView.
|
||||
}
|
||||
|
||||
override fun showFeatureDisabled() {
|
||||
context?.let {
|
||||
completedLessonsInfo.text = getString(R.string.error_feature_disabled)
|
||||
completedLessonsInfoImage.setImageDrawable(it.getCompatDrawable(R.drawable.ic_all_close_circle))
|
||||
}
|
||||
completedLessonsInfo.text = getString(R.string.error_feature_disabled)
|
||||
completedLessonsInfoImage.setImageDrawable(requireContext().getCompatDrawable(R.drawable.ic_all_close_circle))
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
@ -114,7 +112,7 @@ class CompletedLessonsFragment : BaseFragment(), CompletedLessonsView, MainView.
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putLong(CompletedLessonsFragment.SAVED_DATE_KEY, presenter.currentDate.toEpochDay())
|
||||
outState.putLong(SAVED_DATE_KEY, presenter.currentDate.toEpochDay())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -1,14 +1,13 @@
|
||||
package io.github.wulkanowy.ui.modules.grade
|
||||
package io.github.wulkanowy.ui.widgets
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
|
||||
/**
|
||||
* @see <a href="https://stackoverflow.com/a/50382854">Tabs don't fit to screen with tabmode=scrollable, Even with a Custom Tab Layout</a>
|
||||
*/
|
||||
class CustomTabLayout : TabLayout {
|
||||
class FittedScrollableTabLayout : MaterialTabLayout {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
@ -1,11 +1,12 @@
|
||||
package io.github.wulkanowy.ui.widgets
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
import android.os.Build.VERSION_CODES.LOLLIPOP
|
||||
import android.util.AttributeSet
|
||||
import android.widget.LinearLayout
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.view.ViewCompat
|
||||
import com.google.android.material.elevation.ElevationOverlayProvider
|
||||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
|
||||
class MaterialLinearLayout : LinearLayout {
|
||||
@ -21,11 +22,18 @@ class MaterialLinearLayout : LinearLayout {
|
||||
ViewCompat.setBackground(this, drawable)
|
||||
}
|
||||
|
||||
@RequiresApi(LOLLIPOP)
|
||||
override fun setElevation(elevation: Float) {
|
||||
super.setElevation(elevation)
|
||||
if (background is MaterialShapeDrawable) {
|
||||
(background as MaterialShapeDrawable).elevation = elevation
|
||||
}
|
||||
}
|
||||
|
||||
fun setElevationCompat(elevation: Float) {
|
||||
if (SDK_INT >= LOLLIPOP) {
|
||||
setElevation(elevation)
|
||||
} else {
|
||||
setBackgroundColor(ElevationOverlayProvider(context).getSurfaceColorWithOverlayIfNeeded(elevation))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package io.github.wulkanowy.ui.widgets
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
import android.os.Build.VERSION_CODES.LOLLIPOP
|
||||
import android.util.AttributeSet
|
||||
import com.google.android.material.elevation.ElevationOverlayProvider
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
|
||||
open class MaterialTabLayout : TabLayout {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attr: AttributeSet) : super(context, attr)
|
||||
|
||||
constructor(context: Context, attr: AttributeSet, defStyleAttr: Int) : super(context, attr, defStyleAttr)
|
||||
|
||||
fun setElevationCompat(elevation: Float) {
|
||||
if (SDK_INT >= LOLLIPOP) {
|
||||
setElevation(elevation)
|
||||
} else {
|
||||
setBackgroundColor(ElevationOverlayProvider(context).getSurfaceColorWithOverlayIfNeeded(elevation))
|
||||
}
|
||||
}
|
||||
}
|
@ -7,14 +7,15 @@ import android.widget.Spinner
|
||||
/**
|
||||
* @see <a href="https://stackoverflow.com/a/29602298">How to keep onItemSelected from firing off on a newly instantiated Spinner?</a>
|
||||
*/
|
||||
inline fun Spinner.setOnItemSelectedListener(crossinline listener: (view: View?) -> Unit) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
inline fun <T : View> Spinner.setOnItemSelectedListener(crossinline listener: (view: T?) -> Unit) {
|
||||
onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
listener(view)
|
||||
listener(view as T?)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:elevation="8dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:windowBackground"
|
||||
android:elevation="1dp"
|
||||
android:padding="5dp"
|
||||
android:visibility="invisible"
|
||||
tools:ignore="UnusedAttribute"
|
||||
|
@ -60,7 +60,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:elevation="8dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
@ -5,12 +5,11 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<io.github.wulkanowy.ui.modules.grade.CustomTabLayout
|
||||
<io.github.wulkanowy.ui.widgets.FittedScrollableTabLayout
|
||||
android:id="@+id/gradeTabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="?colorSurface"
|
||||
android:elevation="4dp"
|
||||
android:visibility="invisible"
|
||||
app:tabMode="scrollable"
|
||||
app:tabSelectedTextColor="?colorPrimary"
|
||||
|
@ -11,7 +11,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:windowBackground"
|
||||
android:elevation="1dp"
|
||||
android:padding="5dp"
|
||||
android:visibility="invisible"
|
||||
tools:ignore="UnusedAttribute"
|
||||
|
@ -60,7 +60,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:elevation="8dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
@ -5,12 +5,11 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
<io.github.wulkanowy.ui.widgets.MaterialTabLayout
|
||||
android:id="@+id/messageTabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="?colorSurface"
|
||||
android:elevation="4dp"
|
||||
android:visibility="invisible"
|
||||
app:tabGravity="fill"
|
||||
app:tabIndicatorColor="?colorPrimary"
|
||||
|
@ -60,7 +60,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:elevation="8dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
@ -64,7 +64,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:elevation="8dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user