mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-02-20 21:24:44 +01:00
Change login progress bars (#272)
This commit is contained in:
parent
f773310cdb
commit
feb38b97e4
@ -37,4 +37,3 @@ class SemesterRepository @Inject constructor(
|
||||
return getSemesters(student, forceRefresh).map { item -> item.single { it.isCurrent } }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,7 @@ class AttendanceSummaryPresenter @Inject constructor(
|
||||
view?.run {
|
||||
hideRefresh()
|
||||
showProgress(false)
|
||||
enableSwipe(true)
|
||||
}
|
||||
}
|
||||
.subscribe({
|
||||
|
@ -115,7 +115,7 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
loginFormProgressContainer.visibility = if (show) VISIBLE else GONE
|
||||
loginFormProgress.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun showContent(show: Boolean) {
|
||||
|
@ -47,7 +47,7 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
|
||||
override fun initView() {
|
||||
loginAdapter.apply { setOnItemClickListener { presenter.onItemSelected(it) } }
|
||||
|
||||
loginOptionsRecycler.apply {
|
||||
loginStudentSelectRecycler.apply {
|
||||
adapter = loginAdapter
|
||||
layoutManager = SmoothScrollLinearLayoutManager(context)
|
||||
}
|
||||
@ -65,11 +65,11 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
loginOptionsProgressContainer.visibility = if (show) VISIBLE else GONE
|
||||
loginStudentSelectProgress.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun showContent(show: Boolean) {
|
||||
loginOptionsRecycler.visibility = if (show) VISIBLE else GONE
|
||||
loginStudentSelectRecycler.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun showActionBar(show: Boolean) {
|
||||
|
@ -8,11 +8,11 @@ import eu.davidea.viewholders.FlexibleViewHolder
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import kotlinx.android.extensions.LayoutContainer
|
||||
import kotlinx.android.synthetic.main.item_login_options.view.*
|
||||
import kotlinx.android.synthetic.main.item_login_student_select.view.*
|
||||
|
||||
class LoginStudentSelectItem(val student: Student) : AbstractFlexibleItem<LoginStudentSelectItem.ItemViewHolder>() {
|
||||
|
||||
override fun getLayoutRes(): Int = R.layout.item_login_options
|
||||
override fun getLayoutRes(): Int = R.layout.item_login_student_select
|
||||
|
||||
override fun createViewHolder(view: View?, adapter: FlexibleAdapter<IFlexible<*>>?): ItemViewHolder {
|
||||
return ItemViewHolder(view, adapter)
|
||||
|
@ -3,7 +3,6 @@ package io.github.wulkanowy.ui.modules.login.studentselect
|
||||
import com.google.firebase.analytics.FirebaseAnalytics.Param.SUCCESS
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
||||
@ -17,7 +16,6 @@ import javax.inject.Inject
|
||||
class LoginStudentSelectPresenter @Inject constructor(
|
||||
private val errorHandler: LoginErrorHandler,
|
||||
private val studentRepository: StudentRepository,
|
||||
private val semesterRepository: SemesterRepository,
|
||||
private val schedulers: SchedulersProvider,
|
||||
private val analytics: FirebaseAnalyticsHelper
|
||||
) : BasePresenter<LoginStudentSelectView>(errorHandler) {
|
||||
@ -59,7 +57,6 @@ class LoginStudentSelectPresenter @Inject constructor(
|
||||
private fun registerStudent(student: Student) {
|
||||
disposable.add(studentRepository.saveStudent(student)
|
||||
.map { student.apply { id = it } }
|
||||
.flatMap { semesterRepository.getSemesters(student, true) }
|
||||
.onErrorResumeNext { studentRepository.logoutStudent(student).andThen(Single.error(it)) }
|
||||
.flatMapCompletable { studentRepository.switchStudent(student) }
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
|
@ -93,7 +93,7 @@ class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
loginSymbolProgressContainer.visibility = if (show) VISIBLE else GONE
|
||||
loginSymbolProgress.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun showContent(show: Boolean) {
|
||||
|
@ -33,8 +33,6 @@ class LuckyNumberFragment : BaseSessionFragment(), LuckyNumberView, MainView.Tit
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
showContent(false)
|
||||
showProgress(true)
|
||||
luckyNumberSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,12 @@ class LuckyNumberPresenter @Inject constructor(
|
||||
.flatMapMaybe { luckyNumberRepository.getLuckyNumber(it, forceRefresh) }
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.doOnSubscribe {
|
||||
view?.run {
|
||||
showContent(false)
|
||||
enableSwipe(false)
|
||||
}
|
||||
}
|
||||
.doFinally {
|
||||
view?.run {
|
||||
hideRefresh()
|
||||
|
@ -4,31 +4,13 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/loginFormProgressContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:visibility="gone">
|
||||
|
||||
<ProgressBar
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/loginFormProgressTitle"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:indeterminate="true"
|
||||
android:minWidth="220dp"
|
||||
android:minHeight="30dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loginFormProgressTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="@string/login_progress" />
|
||||
</RelativeLayout>
|
||||
<ProgressBar
|
||||
android:id="@+id/loginFormProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nestedScrollView"
|
||||
|
@ -1,40 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/loginOptionsProgressContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:visibility="gone">
|
||||
|
||||
<ProgressBar
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/loginOptionsProgressText"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:indeterminate="true"
|
||||
android:minWidth="220dp"
|
||||
android:minHeight="30dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loginOptionsProgressText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="@string/login_sync" />
|
||||
</RelativeLayout>
|
||||
<ProgressBar
|
||||
android:id="@+id/loginStudentSelectProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/loginOptionsRecycler"
|
||||
android:id="@+id/loginStudentSelectRecycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:itemCount="5"
|
||||
tools:listitem="@layout/item_login_options" />
|
||||
</LinearLayout>
|
||||
tools:listitem="@layout/item_login_student_select" />
|
||||
</FrameLayout>
|
||||
|
@ -4,31 +4,13 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/loginSymbolProgressContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:visibility="gone">
|
||||
|
||||
<ProgressBar
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/loginSymbolProgressText"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:indeterminate="true"
|
||||
android:minWidth="220dp"
|
||||
android:minHeight="30dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loginSymbolProgressText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="@string/login_progress" />
|
||||
</RelativeLayout>
|
||||
<ProgressBar
|
||||
android:id="@+id/loginSymbolProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -11,7 +11,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone" />
|
||||
tools:visibility="invisible" />
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/luckyNumberSwipe"
|
||||
@ -36,8 +36,8 @@
|
||||
android:id="@+id/luckyNumberText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="14"
|
||||
android:textSize="52sp" />
|
||||
android:textSize="52sp"
|
||||
tools:text="14" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -26,11 +26,9 @@
|
||||
<string name="login_host_hint">Dziennik</string>
|
||||
<string name="login_symbol_hint">Symbol</string>
|
||||
<string name="login_sign_in">Zaloguj</string>
|
||||
<string name="login_progress">Logowanie…</string>
|
||||
<string name="login_sync">Synchronizacja</string>
|
||||
<string name="login_invalid_password">To hasło jest za krótkie</string>
|
||||
<string name="login_incorrect_password">Dane logowania są niepoprawne</string>
|
||||
<string name="login_incorrect_symbol">Nie znaleziono ucznia. Sprwadź symbol</string>
|
||||
<string name="login_incorrect_symbol">Nie znaleziono ucznia. Sprawdź symbol</string>
|
||||
<string name="login_field_required">To pole jest wymagane</string>
|
||||
<string name="login_duplicate_student">Ten student jest już zalogowany</string>
|
||||
<string name="login_symbol_helper">Symbol znajduje się na stronie dziennika w zakładce Dostęp Mobilny</string>
|
||||
|
@ -26,8 +26,6 @@
|
||||
<string name="login_host_hint">Register</string>
|
||||
<string name="login_symbol_hint">Symbol</string>
|
||||
<string name="login_sign_in">Sign in</string>
|
||||
<string name="login_progress">Logging in…</string>
|
||||
<string name="login_sync">Synchronization…</string>
|
||||
<string name="login_invalid_password">This password is too short</string>
|
||||
<string name="login_incorrect_password">Login details are incorrect</string>
|
||||
<string name="login_incorrect_symbol">Student not found. Check the symbol</string>
|
||||
|
@ -1,9 +1,7 @@
|
||||
package io.github.wulkanowy.ui.modules.login.studentselect
|
||||
|
||||
import io.github.wulkanowy.TestSchedulersProvider
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
||||
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
@ -29,9 +27,6 @@ class LoginStudentSelectPresenterTest {
|
||||
@Mock
|
||||
lateinit var studentRepository: StudentRepository
|
||||
|
||||
@Mock
|
||||
lateinit var semesterRepository: SemesterRepository
|
||||
|
||||
@Mock
|
||||
lateinit var analytics: FirebaseAnalyticsHelper
|
||||
|
||||
@ -45,8 +40,7 @@ class LoginStudentSelectPresenterTest {
|
||||
fun initPresenter() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
clearInvocations(studentRepository, loginStudentSelectView)
|
||||
clearInvocations(semesterRepository, loginStudentSelectView)
|
||||
presenter = LoginStudentSelectPresenter(errorHandler, studentRepository, semesterRepository, TestSchedulersProvider(), analytics)
|
||||
presenter = LoginStudentSelectPresenter(errorHandler, studentRepository, TestSchedulersProvider(), analytics)
|
||||
presenter.onAttachView(loginStudentSelectView, null)
|
||||
}
|
||||
|
||||
@ -58,7 +52,6 @@ class LoginStudentSelectPresenterTest {
|
||||
@Test
|
||||
fun onSelectedStudentTest() {
|
||||
doReturn(Single.just(1L)).`when`(studentRepository).saveStudent(testStudent)
|
||||
doReturn(Single.just(emptyList<Semester>())).`when`(semesterRepository).getSemesters(testStudent, true)
|
||||
doReturn(Completable.complete()).`when`(studentRepository).switchStudent(testStudent)
|
||||
presenter.onItemSelected(LoginStudentSelectItem(testStudent))
|
||||
verify(loginStudentSelectView).showContent(false)
|
||||
@ -69,7 +62,6 @@ class LoginStudentSelectPresenterTest {
|
||||
@Test
|
||||
fun onSelectedStudentErrorTest() {
|
||||
doReturn(Single.error<Student>(testException)).`when`(studentRepository).saveStudent(testStudent)
|
||||
doReturn(Single.just(emptyList<Semester>())).`when`(semesterRepository).getSemesters(testStudent, true)
|
||||
doReturn(Completable.complete()).`when`(studentRepository).logoutStudent(testStudent)
|
||||
presenter.onItemSelected(LoginStudentSelectItem(testStudent))
|
||||
verify(loginStudentSelectView).showContent(false)
|
||||
|
Loading…
x
Reference in New Issue
Block a user