diff --git a/.travis.yml b/.travis.yml
index 8920018ed..b32619317 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,6 +14,7 @@ cache:
branches:
only:
- master
+ - 0.7.x
android:
licenses:
diff --git a/app/build.gradle b/app/build.gradle
index f7fd82c0e..f581ba51a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -77,7 +77,7 @@ play {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
- implementation('com.github.wulkanowy:api:0aea843800') { exclude module: "threetenbp" }
+ implementation('com.github.wulkanowy:api:bc60169383') { exclude module: "threetenbp" }
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.appcompat:appcompat:1.0.2"
diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeFragment.kt
index 8fdecda2d..20d3fad70 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeFragment.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeFragment.kt
@@ -29,6 +29,8 @@ class GradeFragment : BaseSessionFragment(), GradeView, MainView.MainChildView,
@Inject
lateinit var pagerAdapter: BaseFragmentPagerAdapter
+ private var semesterSwitchMenu: MenuItem? = null
+
companion object {
private const val SAVED_SEMESTER_KEY = "CURRENT_SEMESTER"
@@ -57,6 +59,8 @@ class GradeFragment : BaseSessionFragment(), GradeView, MainView.MainChildView,
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
inflater?.inflate(R.menu.action_menu_grade, menu)
+ semesterSwitchMenu = menu?.findItem(R.id.gradeMenuSemester)
+ presenter.onCreateMenu()
}
override fun initView() {
@@ -75,6 +79,7 @@ class GradeFragment : BaseSessionFragment(), GradeView, MainView.MainChildView,
setOnSelectPageListener { presenter.onPageSelected(it) }
}
gradeTabLayout.setupWithViewPager(gradeViewPager)
+ gradeSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
}
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
@@ -95,8 +100,20 @@ class GradeFragment : BaseSessionFragment(), GradeView, MainView.MainChildView,
gradeProgress.visibility = if (show) VISIBLE else INVISIBLE
}
- override fun showEmpty() {
- gradeEmpty.visibility = VISIBLE
+ override fun showEmpty(show: Boolean) {
+ gradeEmpty.visibility = if (show) VISIBLE else INVISIBLE
+ }
+
+ override fun showRefresh(show: Boolean) {
+ gradeSwipe.isRefreshing = show
+ }
+
+ override fun showSemesterSwitch(show: Boolean) {
+ semesterSwitchMenu?.isVisible = show
+ }
+
+ override fun enableSwipe(enable: Boolean) {
+ gradeSwipe.isEnabled = enable
}
override fun showSemesterDialog(selectedIndex: Int) {
diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradePresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradePresenter.kt
index cc127a90f..98eb2a9f4 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradePresenter.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradePresenter.kt
@@ -33,11 +33,18 @@ class GradePresenter @Inject constructor(
disposable.add(Completable.timer(150, MILLISECONDS, schedulers.mainThread)
.subscribe {
selectedIndex = savedIndex ?: 0
- view.initView()
+ view.run {
+ initView()
+ enableSwipe(false)
+ }
loadData()
})
}
+ fun onCreateMenu() {
+ if (semesters.isEmpty()) view?.showSemesterSwitch(false)
+ }
+
fun onViewReselected() {
Timber.i("Grade view is reselected")
view?.run { notifyChildParentReselected(currentPageIndex) }
@@ -69,6 +76,7 @@ class GradePresenter @Inject constructor(
view?.apply {
showContent(true)
showProgress(false)
+ showEmpty(false)
loadedSemesterId[currentPageIndex] = semesterId
}
}
@@ -77,6 +85,10 @@ class GradePresenter @Inject constructor(
loadChild(index)
}
+ fun onSwipeRefresh() {
+ loadData()
+ }
+
private fun loadData() {
Timber.i("Loading grade data started")
disposable.add(studentRepository.getCurrentStudent()
@@ -89,17 +101,21 @@ class GradePresenter @Inject constructor(
}
.subscribeOn(schedulers.backgroundThread)
.observeOn(schedulers.mainThread)
+ .doFinally { view?.showRefresh(false) }
.subscribe({
view?.run {
Timber.i("Loading grade result: Attempt load index $currentPageIndex")
loadChild(currentPageIndex)
+ enableSwipe(false)
+ showSemesterSwitch(true)
}
}) {
Timber.i("Loading grade result: An exception occurred")
errorHandler.dispatch(it)
view?.run {
showProgress(false)
- showEmpty()
+ showEmpty(true)
+ enableSwipe(true)
}
})
}
diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeView.kt
index 3f1a197c4..9fdd46b16 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeView.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeView.kt
@@ -12,10 +12,16 @@ interface GradeView : BaseSessionView {
fun showProgress(show: Boolean)
- fun showEmpty()
+ fun showEmpty(show: Boolean)
+
+ fun showRefresh(show: Boolean)
+
+ fun showSemesterSwitch(show: Boolean)
fun showSemesterDialog(selectedIndex: Int)
+ fun enableSwipe(enable: Boolean)
+
fun notifyChildLoadData(index: Int, semesterId: Int, forceRefresh: Boolean)
fun notifyChildParentReselected(index: Int)
diff --git a/app/src/main/res/layout/fragment_grade.xml b/app/src/main/res/layout/fragment_grade.xml
index 6cd226361..bf8051753 100644
--- a/app/src/main/res/layout/fragment_grade.xml
+++ b/app/src/main/res/layout/fragment_grade.xml
@@ -17,13 +17,19 @@
app:tabTextColor="@android:color/white"
tools:visibility="visible" />
-
+ android:layout_marginTop="48dp">
+
+
+