forked from github/wulkanowy-mirror
Use view binding instead of kotlin synthetics (#791)
This commit is contained in:
parent
ec80f939f1
commit
8eb0c0351b
@ -1,3 +1,3 @@
|
|||||||
component_depth: 8
|
component_depth: 10
|
||||||
languages:
|
languages:
|
||||||
- kotlin
|
- kotlin
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlin-kapt'
|
apply plugin: 'kotlin-kapt'
|
||||||
apply plugin: 'kotlin-android-extensions'
|
|
||||||
apply plugin: 'com.google.firebase.crashlytics'
|
apply plugin: 'com.google.firebase.crashlytics'
|
||||||
apply plugin: 'com.github.triplet.play'
|
apply plugin: 'com.github.triplet.play'
|
||||||
apply plugin: 'com.mikepenz.aboutlibraries.plugin'
|
apply plugin: 'com.mikepenz.aboutlibraries.plugin'
|
||||||
@ -103,10 +102,6 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
androidExtensions {
|
|
||||||
experimental = true
|
|
||||||
}
|
|
||||||
|
|
||||||
play {
|
play {
|
||||||
serviceAccountEmail = System.getenv("PLAY_SERVICE_ACCOUNT_EMAIL") ?: "jan@fakelog.cf"
|
serviceAccountEmail = System.getenv("PLAY_SERVICE_ACCOUNT_EMAIL") ?: "jan@fakelog.cf"
|
||||||
serviceAccountCredentials = file('key.p12')
|
serviceAccountCredentials = file('key.p12')
|
||||||
|
@ -11,6 +11,7 @@ import android.widget.Toast
|
|||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.google.android.material.snackbar.Snackbar.LENGTH_LONG
|
import com.google.android.material.snackbar.Snackbar.LENGTH_LONG
|
||||||
import dagger.android.AndroidInjection
|
import dagger.android.AndroidInjection
|
||||||
@ -20,10 +21,13 @@ import io.github.wulkanowy.R
|
|||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
import io.github.wulkanowy.utils.FragmentLifecycleLogger
|
import io.github.wulkanowy.utils.FragmentLifecycleLogger
|
||||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||||
|
import io.github.wulkanowy.utils.lifecycleAwareVariable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
abstract class BaseActivity<T : BasePresenter<out BaseView>> : AppCompatActivity(), BaseView,
|
abstract class BaseActivity<T : BasePresenter<out BaseView>, VB : ViewBinding> :
|
||||||
HasAndroidInjector {
|
AppCompatActivity(), BaseView, HasAndroidInjector {
|
||||||
|
|
||||||
|
protected var binding: VB by lifecycleAwareVariable()
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package io.github.wulkanowy.ui.base
|
package io.github.wulkanowy.ui.base
|
||||||
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
import dagger.android.support.DaggerAppCompatDialogFragment
|
import dagger.android.support.DaggerAppCompatDialogFragment
|
||||||
|
import io.github.wulkanowy.utils.lifecycleAwareVariable
|
||||||
|
|
||||||
abstract class BaseDialogFragment : DaggerAppCompatDialogFragment(), BaseView {
|
abstract class BaseDialogFragment<VB : ViewBinding> : DaggerAppCompatDialogFragment(), BaseView {
|
||||||
|
|
||||||
|
protected var binding: VB by lifecycleAwareVariable()
|
||||||
|
|
||||||
override fun showError(text: String, error: Throwable) {
|
override fun showError(text: String, error: Throwable) {
|
||||||
showMessage(text)
|
showMessage(text)
|
||||||
@ -14,11 +18,11 @@ abstract class BaseDialogFragment : DaggerAppCompatDialogFragment(), BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showExpiredDialog() {
|
override fun showExpiredDialog() {
|
||||||
(activity as? BaseActivity<*>)?.showExpiredDialog()
|
(activity as? BaseActivity<*, *>)?.showExpiredDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openClearLoginView() {
|
override fun openClearLoginView() {
|
||||||
(activity as? BaseActivity<*>)?.openClearLoginView()
|
(activity as? BaseActivity<*, *>)?.openClearLoginView()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorDetailsDialog(error: Throwable) {
|
override fun showErrorDetailsDialog(error: Throwable) {
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
package io.github.wulkanowy.ui.base
|
package io.github.wulkanowy.ui.base
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.annotation.LayoutRes
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.google.android.material.snackbar.Snackbar.LENGTH_LONG
|
import com.google.android.material.snackbar.Snackbar.LENGTH_LONG
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.utils.lifecycleAwareVariable
|
||||||
|
|
||||||
abstract class BaseFragment : DaggerFragment(), BaseView {
|
abstract class BaseFragment<VB : ViewBinding>(@LayoutRes layoutId: Int) : DaggerFragment(layoutId),
|
||||||
|
BaseView {
|
||||||
|
|
||||||
|
protected var binding: VB by lifecycleAwareVariable()
|
||||||
|
|
||||||
protected var messageContainer: View? = null
|
protected var messageContainer: View? = null
|
||||||
|
|
||||||
@ -16,7 +22,7 @@ abstract class BaseFragment : DaggerFragment(), BaseView {
|
|||||||
.setAction(R.string.all_details) { if (isAdded) showErrorDetailsDialog(error) }
|
.setAction(R.string.all_details) { if (isAdded) showErrorDetailsDialog(error) }
|
||||||
.show()
|
.show()
|
||||||
} else {
|
} else {
|
||||||
(activity as? BaseActivity<*>)?.showError(text, error)
|
(activity as? BaseActivity<*, *>)?.showError(text, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,15 +34,15 @@ abstract class BaseFragment : DaggerFragment(), BaseView {
|
|||||||
if (messageContainer != null) {
|
if (messageContainer != null) {
|
||||||
Snackbar.make(messageContainer!!, text, LENGTH_LONG).show()
|
Snackbar.make(messageContainer!!, text, LENGTH_LONG).show()
|
||||||
} else {
|
} else {
|
||||||
(activity as? BaseActivity<*>)?.showMessage(text)
|
(activity as? BaseActivity<*, *>)?.showMessage(text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showExpiredDialog() {
|
override fun showExpiredDialog() {
|
||||||
(activity as? BaseActivity<*>)?.showExpiredDialog()
|
(activity as? BaseActivity<*, *>)?.showExpiredDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openClearLoginView() {
|
override fun openClearLoginView() {
|
||||||
(activity as? BaseActivity<*>)?.openClearLoginView()
|
(activity as? BaseActivity<*, *>)?.openClearLoginView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import android.widget.Toast
|
|||||||
import android.widget.Toast.LENGTH_LONG
|
import android.widget.Toast.LENGTH_LONG
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.databinding.DialogErrorBinding
|
||||||
import io.github.wulkanowy.sdk.exception.FeatureDisabledException
|
import io.github.wulkanowy.sdk.exception.FeatureDisabledException
|
||||||
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
||||||
import io.github.wulkanowy.sdk.exception.ServiceUnavailableException
|
import io.github.wulkanowy.sdk.exception.ServiceUnavailableException
|
||||||
@ -18,7 +19,6 @@ import io.github.wulkanowy.utils.AppInfo
|
|||||||
import io.github.wulkanowy.utils.getString
|
import io.github.wulkanowy.utils.getString
|
||||||
import io.github.wulkanowy.utils.openEmailClient
|
import io.github.wulkanowy.utils.openEmailClient
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import kotlinx.android.synthetic.main.dialog_error.*
|
|
||||||
import java.io.InterruptedIOException
|
import java.io.InterruptedIOException
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
import java.io.StringWriter
|
import java.io.StringWriter
|
||||||
@ -26,7 +26,7 @@ import java.net.SocketTimeoutException
|
|||||||
import java.net.UnknownHostException
|
import java.net.UnknownHostException
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ErrorDialog : BaseDialogFragment() {
|
class ErrorDialog : BaseDialogFragment<DialogErrorBinding>() {
|
||||||
|
|
||||||
private lateinit var error: Throwable
|
private lateinit var error: Throwable
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class ErrorDialog : BaseDialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_error, container, false)
|
return DialogErrorBinding.inflate(inflater).apply { binding = this }.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
@ -62,27 +62,29 @@ class ErrorDialog : BaseDialogFragment() {
|
|||||||
error.printStackTrace(PrintWriter(this))
|
error.printStackTrace(PrintWriter(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
errorDialogContent.text = stringWriter.toString()
|
with(binding) {
|
||||||
with(errorDialogHorizontalScroll) {
|
errorDialogContent.text = stringWriter.toString()
|
||||||
post { fullScroll(HorizontalScrollView.FOCUS_LEFT) }
|
with(errorDialogHorizontalScroll) {
|
||||||
}
|
post { fullScroll(HorizontalScrollView.FOCUS_LEFT) }
|
||||||
errorDialogCopy.setOnClickListener {
|
}
|
||||||
val clip = ClipData.newPlainText("wulkanowy", stringWriter.toString())
|
errorDialogCopy.setOnClickListener {
|
||||||
activity?.getSystemService<ClipboardManager>()?.setPrimaryClip(clip)
|
val clip = ClipData.newPlainText("wulkanowy", stringWriter.toString())
|
||||||
|
activity?.getSystemService<ClipboardManager>()?.setPrimaryClip(clip)
|
||||||
|
|
||||||
Toast.makeText(context, R.string.all_copied, LENGTH_LONG).show()
|
Toast.makeText(context, R.string.all_copied, LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
errorDialogCancel.setOnClickListener { dismiss() }
|
errorDialogCancel.setOnClickListener { dismiss() }
|
||||||
errorDialogReport.setOnClickListener { openEmailClient(stringWriter.toString()) }
|
errorDialogReport.setOnClickListener { openEmailClient(stringWriter.toString()) }
|
||||||
errorDialogMessage.text = resources.getString(error)
|
errorDialogMessage.text = resources.getString(error)
|
||||||
errorDialogReport.isEnabled = when (error) {
|
errorDialogReport.isEnabled = when (error) {
|
||||||
is UnknownHostException,
|
is UnknownHostException,
|
||||||
is InterruptedIOException,
|
is InterruptedIOException,
|
||||||
is SocketTimeoutException,
|
is SocketTimeoutException,
|
||||||
is ServiceUnavailableException,
|
is ServiceUnavailableException,
|
||||||
is FeatureDisabledException,
|
is FeatureDisabledException,
|
||||||
is FeatureNotAvailableException -> false
|
is FeatureNotAvailableException -> false
|
||||||
else -> true
|
else -> true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,11 +2,10 @@ package io.github.wulkanowy.ui.modules.about
|
|||||||
|
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.databinding.FragmentAboutBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.about.contributor.ContributorFragment
|
import io.github.wulkanowy.ui.modules.about.contributor.ContributorFragment
|
||||||
import io.github.wulkanowy.ui.modules.about.license.LicenseFragment
|
import io.github.wulkanowy.ui.modules.about.license.LicenseFragment
|
||||||
@ -17,10 +16,10 @@ import io.github.wulkanowy.utils.AppInfo
|
|||||||
import io.github.wulkanowy.utils.getCompatDrawable
|
import io.github.wulkanowy.utils.getCompatDrawable
|
||||||
import io.github.wulkanowy.utils.openEmailClient
|
import io.github.wulkanowy.utils.openEmailClient
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import kotlinx.android.synthetic.main.fragment_about.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AboutFragment : BaseFragment(), AboutView, MainView.TitledView {
|
class AboutFragment : BaseFragment<FragmentAboutBinding>(R.layout.fragment_about), AboutView,
|
||||||
|
MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: AboutPresenter
|
lateinit var presenter: AboutPresenter
|
||||||
@ -77,19 +76,16 @@ class AboutFragment : BaseFragment(), AboutView, MainView.TitledView {
|
|||||||
fun newInstance() = AboutFragment()
|
fun newInstance() = AboutFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
||||||
return inflater.inflate(R.layout.fragment_about, container, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
binding = FragmentAboutBinding.bind(view)
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
aboutAdapter.onClickListener = presenter::onItemSelected
|
aboutAdapter.onClickListener = presenter::onItemSelected
|
||||||
|
|
||||||
with(aboutRecycler) {
|
with(binding.aboutRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = aboutAdapter
|
adapter = aboutAdapter
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
package io.github.wulkanowy.ui.modules.about.contributor
|
package io.github.wulkanowy.ui.modules.about.contributor
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.pojos.Contributor
|
import io.github.wulkanowy.data.pojos.Contributor
|
||||||
|
import io.github.wulkanowy.databinding.FragmentContributorBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import kotlinx.android.synthetic.main.fragment_creator.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ContributorFragment : BaseFragment(), ContributorView, MainView.TitledView {
|
class ContributorFragment : BaseFragment<FragmentContributorBinding>(R.layout.fragment_contributor),
|
||||||
|
ContributorView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: ContributorPresenter
|
lateinit var presenter: ContributorPresenter
|
||||||
@ -30,23 +29,20 @@ class ContributorFragment : BaseFragment(), ContributorView, MainView.TitledView
|
|||||||
fun newInstance() = ContributorFragment()
|
fun newInstance() = ContributorFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_creator, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentContributorBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(creatorRecycler) {
|
with(binding.creatorRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = creatorsAdapter
|
adapter = creatorsAdapter
|
||||||
addItemDecoration(DividerItemDecoration(context))
|
addItemDecoration(DividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
creatorsAdapter.onClickListener = presenter::onItemSelected
|
creatorsAdapter.onClickListener = presenter::onItemSelected
|
||||||
creatorSeeMore.setOnClickListener { presenter.onSeeMoreClick() }
|
binding.creatorSeeMore.setOnClickListener { presenter.onSeeMoreClick() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(data: List<Contributor>) {
|
override fun updateData(data: List<Contributor>) {
|
||||||
@ -65,7 +61,7 @@ class ContributorFragment : BaseFragment(), ContributorView, MainView.TitledView
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
creatorProgress.visibility = if (show) VISIBLE else GONE
|
binding.creatorProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package io.github.wulkanowy.ui.modules.about.license
|
package io.github.wulkanowy.ui.modules.about.license
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.text.parseAsHtml
|
import androidx.core.text.parseAsHtml
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
@ -13,12 +11,13 @@ import com.mikepenz.aboutlibraries.Libs
|
|||||||
import com.mikepenz.aboutlibraries.entity.Library
|
import com.mikepenz.aboutlibraries.entity.Library
|
||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.databinding.FragmentLicenseBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import kotlinx.android.synthetic.main.fragment_license.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LicenseFragment : BaseFragment(), LicenseView, MainView.TitledView {
|
class LicenseFragment : BaseFragment<FragmentLicenseBinding>(R.layout.fragment_license),
|
||||||
|
LicenseView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: LicensePresenter
|
lateinit var presenter: LicensePresenter
|
||||||
@ -40,19 +39,16 @@ class LicenseFragment : BaseFragment(), LicenseView, MainView.TitledView {
|
|||||||
fun newInstance() = LicenseFragment()
|
fun newInstance() = LicenseFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_license, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentLicenseBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
licenseAdapter.onClickListener = presenter::onItemSelected
|
licenseAdapter.onClickListener = presenter::onItemSelected
|
||||||
|
|
||||||
with(licenseRecycler) {
|
with(binding.licenseRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = licenseAdapter
|
adapter = licenseAdapter
|
||||||
}
|
}
|
||||||
@ -77,7 +73,7 @@ class LicenseFragment : BaseFragment(), LicenseView, MainView.TitledView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
licenseProgress.visibility = if (show) VISIBLE else GONE
|
binding.licenseProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
@ -8,23 +8,22 @@ import android.net.Uri
|
|||||||
import android.os.Build.VERSION.SDK_INT
|
import android.os.Build.VERSION.SDK_INT
|
||||||
import android.os.Build.VERSION_CODES.LOLLIPOP
|
import android.os.Build.VERSION_CODES.LOLLIPOP
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
import android.view.MenuInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.BuildConfig.APPLICATION_ID
|
import io.github.wulkanowy.BuildConfig.APPLICATION_ID
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.databinding.FragmentLogviewerBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import kotlinx.android.synthetic.main.fragment_logviewer.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LogViewerFragment : BaseFragment(), LogViewerView, MainView.TitledView {
|
class LogViewerFragment : BaseFragment<FragmentLogviewerBinding>(R.layout.fragment_logviewer),
|
||||||
|
LogViewerView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: LogViewerPresenter
|
lateinit var presenter: LogViewerPresenter
|
||||||
@ -43,13 +42,10 @@ class LogViewerFragment : BaseFragment(), LogViewerView, MainView.TitledView {
|
|||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_logviewer, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentLogviewerBinding.bind(view)
|
||||||
|
messageContainer = binding.logViewerRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = logViewerRecycler
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,18 +59,18 @@ class LogViewerFragment : BaseFragment(), LogViewerView, MainView.TitledView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(logViewerRecycler) {
|
with(binding.logViewerRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = logAdapter
|
adapter = logAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
logViewRefreshButton.setOnClickListener { presenter.onRefreshClick() }
|
binding.logViewRefreshButton.setOnClickListener { presenter.onRefreshClick() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setLines(lines: List<String>) {
|
override fun setLines(lines: List<String>) {
|
||||||
logAdapter.lines = lines
|
logAdapter.lines = lines
|
||||||
logAdapter.notifyDataSetChanged()
|
logAdapter.notifyDataSetChanged()
|
||||||
logViewerRecycler.scrollToPosition(lines.size - 1)
|
binding.logViewerRecycler.scrollToPosition(lines.size - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shareLogs(files: List<File>) {
|
override fun shareLogs(files: List<File>) {
|
||||||
|
@ -10,12 +10,12 @@ import androidx.appcompat.app.AlertDialog
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
|
import io.github.wulkanowy.databinding.DialogAccountBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseDialogFragment
|
import io.github.wulkanowy.ui.base.BaseDialogFragment
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
import kotlinx.android.synthetic.main.dialog_account.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AccountDialog : BaseDialogFragment(), AccountView {
|
class AccountDialog : BaseDialogFragment<DialogAccountBinding>(), AccountView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: AccountPresenter
|
lateinit var presenter: AccountPresenter
|
||||||
@ -33,7 +33,7 @@ class AccountDialog : BaseDialogFragment(), AccountView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_account, container, false)
|
return DialogAccountBinding.inflate(inflater).apply { binding = this }.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
@ -44,11 +44,13 @@ class AccountDialog : BaseDialogFragment(), AccountView {
|
|||||||
override fun initView() {
|
override fun initView() {
|
||||||
accountAdapter.onClickListener = presenter::onItemSelected
|
accountAdapter.onClickListener = presenter::onItemSelected
|
||||||
|
|
||||||
accountDialogAdd.setOnClickListener { presenter.onAddSelected() }
|
with(binding) {
|
||||||
accountDialogRemove.setOnClickListener { presenter.onRemoveSelected() }
|
accountDialogAdd.setOnClickListener { presenter.onAddSelected() }
|
||||||
accountDialogRecycler.apply {
|
accountDialogRemove.setOnClickListener { presenter.onRemoveSelected() }
|
||||||
layoutManager = LinearLayoutManager(context)
|
accountDialogRecycler.apply {
|
||||||
adapter = accountAdapter
|
layoutManager = LinearLayoutManager(context)
|
||||||
|
adapter = accountAdapter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,15 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import io.github.wulkanowy.R
|
|
||||||
import io.github.wulkanowy.data.db.entities.Attendance
|
import io.github.wulkanowy.data.db.entities.Attendance
|
||||||
|
import io.github.wulkanowy.databinding.DialogAttendanceBinding
|
||||||
|
import io.github.wulkanowy.utils.lifecycleAwareVariable
|
||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
import kotlinx.android.synthetic.main.dialog_attendance.*
|
|
||||||
|
|
||||||
class AttendanceDialog : DialogFragment() {
|
class AttendanceDialog : DialogFragment() {
|
||||||
|
|
||||||
|
private var binding: DialogAttendanceBinding by lifecycleAwareVariable()
|
||||||
|
|
||||||
private lateinit var attendance: Attendance
|
private lateinit var attendance: Attendance
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -33,16 +35,18 @@ class AttendanceDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_attendance, container, false)
|
return DialogAttendanceBinding.inflate(inflater).apply { binding = this }.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
attendanceDialogSubject.text = attendance.subject
|
with(binding) {
|
||||||
attendanceDialogDescription.text = attendance.name
|
attendanceDialogSubject.text = attendance.subject
|
||||||
attendanceDialogDate.text = attendance.date.toFormattedString()
|
attendanceDialogDescription.text = attendance.name
|
||||||
attendanceDialogNumber.text = attendance.number.toString()
|
attendanceDialogDate.text = attendance.date.toFormattedString()
|
||||||
attendanceDialogClose.setOnClickListener { dismiss() }
|
attendanceDialogNumber.text = attendance.number.toString()
|
||||||
|
attendanceDialogClose.setOnClickListener { dismiss() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,14 @@ import android.view.View
|
|||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.INVISIBLE
|
import android.view.View.INVISIBLE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog
|
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Attendance
|
import io.github.wulkanowy.data.db.entities.Attendance
|
||||||
|
import io.github.wulkanowy.databinding.DialogExcuseBinding
|
||||||
|
import io.github.wulkanowy.databinding.FragmentAttendanceBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
||||||
import io.github.wulkanowy.ui.modules.attendance.summary.AttendanceSummaryFragment
|
import io.github.wulkanowy.ui.modules.attendance.summary.AttendanceSummaryFragment
|
||||||
@ -24,12 +25,10 @@ import io.github.wulkanowy.ui.modules.main.MainActivity
|
|||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import io.github.wulkanowy.utils.SchooldaysRangeLimiter
|
import io.github.wulkanowy.utils.SchooldaysRangeLimiter
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import kotlinx.android.synthetic.main.dialog_excuse.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_attendance.*
|
|
||||||
import org.threeten.bp.LocalDate
|
import org.threeten.bp.LocalDate
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildView,
|
class AttendanceFragment : BaseFragment<FragmentAttendanceBinding>(R.layout.fragment_attendance), AttendanceView, MainView.MainChildView,
|
||||||
MainView.TitledView {
|
MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -89,13 +88,10 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
|||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_attendance, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentAttendanceBinding.bind(view)
|
||||||
|
messageContainer = binding.attendanceRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = attendanceRecycler
|
|
||||||
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,23 +101,25 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
|||||||
onExcuseCheckboxSelect = presenter::onExcuseCheckboxSelect
|
onExcuseCheckboxSelect = presenter::onExcuseCheckboxSelect
|
||||||
}
|
}
|
||||||
|
|
||||||
with(attendanceRecycler) {
|
with(binding.attendanceRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = attendanceAdapter
|
adapter = attendanceAdapter
|
||||||
addItemDecoration(DividerItemDecoration(context))
|
addItemDecoration(DividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
attendanceSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
with(binding) {
|
||||||
attendanceErrorRetry.setOnClickListener { presenter.onRetry() }
|
attendanceSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||||
attendanceErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
attendanceErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
attendanceErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
|
||||||
attendancePreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
attendancePreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||||
attendanceNavDate.setOnClickListener { presenter.onPickDate() }
|
attendanceNavDate.setOnClickListener { presenter.onPickDate() }
|
||||||
attendanceNextButton.setOnClickListener { presenter.onNextDay() }
|
attendanceNextButton.setOnClickListener { presenter.onNextDay() }
|
||||||
|
|
||||||
attendanceExcuseButton.setOnClickListener { presenter.onExcuseButtonClick() }
|
attendanceExcuseButton.setOnClickListener { presenter.onExcuseButtonClick() }
|
||||||
|
|
||||||
attendanceNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
attendanceNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
@ -141,7 +139,7 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun updateNavigationDay(date: String) {
|
override fun updateNavigationDay(date: String) {
|
||||||
attendanceNavDate.text = date
|
binding.attendanceNavDate.text = date
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearData() {
|
override fun clearData() {
|
||||||
@ -152,7 +150,7 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun resetView() {
|
override fun resetView() {
|
||||||
attendanceRecycler.smoothScrollToPosition(0)
|
binding.attendanceRecycler.smoothScrollToPosition(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFragmentReselected() {
|
override fun onFragmentReselected() {
|
||||||
@ -168,43 +166,43 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
attendanceEmpty.visibility = if (show) VISIBLE else GONE
|
binding.attendanceEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
attendanceError.visibility = if (show) VISIBLE else GONE
|
binding.attendanceError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
attendanceErrorMessage.text = message
|
binding.attendanceErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
attendanceProgress.visibility = if (show) VISIBLE else GONE
|
binding.attendanceProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
attendanceSwipe.isEnabled = enable
|
binding.attendanceSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
attendanceRecycler.visibility = if (show) VISIBLE else GONE
|
binding. attendanceRecycler.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
attendanceSwipe.isRefreshing = false
|
binding.attendanceSwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showPreButton(show: Boolean) {
|
override fun showPreButton(show: Boolean) {
|
||||||
attendancePreviousButton.visibility = if (show) VISIBLE else INVISIBLE
|
binding.attendancePreviousButton.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showNextButton(show: Boolean) {
|
override fun showNextButton(show: Boolean) {
|
||||||
attendanceNextButton.visibility = if (show) VISIBLE else INVISIBLE
|
binding. attendanceNextButton.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showExcuseButton(show: Boolean) {
|
override fun showExcuseButton(show: Boolean) {
|
||||||
attendanceExcuseButton.visibility = if (show) VISIBLE else GONE
|
binding.attendanceExcuseButton.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showAttendanceDialog(lesson: Attendance) {
|
override fun showAttendanceDialog(lesson: Attendance) {
|
||||||
@ -227,14 +225,15 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showExcuseDialog() {
|
override fun showExcuseDialog() {
|
||||||
|
val dialogBinding = DialogExcuseBinding.inflate(LayoutInflater.from(context))
|
||||||
AlertDialog.Builder(requireContext())
|
AlertDialog.Builder(requireContext())
|
||||||
.setTitle(R.string.attendance_excuse_title)
|
.setTitle(R.string.attendance_excuse_title)
|
||||||
.setView(R.layout.dialog_excuse)
|
.setView(dialogBinding.root)
|
||||||
.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
||||||
.create()
|
.create()
|
||||||
.apply {
|
.apply {
|
||||||
setButton(BUTTON_POSITIVE, getString(R.string.attendance_excuse_dialog_submit)) { _, _ ->
|
setButton(BUTTON_POSITIVE, getString(R.string.attendance_excuse_dialog_submit)) { _, _ ->
|
||||||
presenter.onExcuseDialogSubmit(excuseReason.text?.toString().orEmpty())
|
presenter.onExcuseDialogSubmit(dialogBinding.excuseReason.text?.toString().orEmpty())
|
||||||
}
|
}
|
||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class AttendanceSummaryAdapter @Inject constructor() :
|
|||||||
|
|
||||||
var items = emptyList<AttendanceSummary>()
|
var items = emptyList<AttendanceSummary>()
|
||||||
|
|
||||||
override fun getItemCount() = items.size + 2
|
override fun getItemCount() = if (items.isNotEmpty()) items.size + 2 else 0
|
||||||
|
|
||||||
override fun getItemViewType(position: Int) = when (position) {
|
override fun getItemViewType(position: Int) = when (position) {
|
||||||
0 -> ViewType.HEADER.id
|
0 -> ViewType.HEADER.id
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
package io.github.wulkanowy.ui.modules.attendance.summary
|
package io.github.wulkanowy.ui.modules.attendance.summary
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.INVISIBLE
|
import android.view.View.INVISIBLE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.AttendanceSummary
|
import io.github.wulkanowy.data.db.entities.AttendanceSummary
|
||||||
|
import io.github.wulkanowy.databinding.FragmentAttendanceSummaryBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import io.github.wulkanowy.utils.setOnItemSelectedListener
|
import io.github.wulkanowy.utils.setOnItemSelectedListener
|
||||||
import kotlinx.android.synthetic.main.fragment_attendance_summary.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AttendanceSummaryFragment : BaseFragment(), AttendanceSummaryView, MainView.TitledView {
|
class AttendanceSummaryFragment :
|
||||||
|
BaseFragment<FragmentAttendanceSummaryBinding>(R.layout.fragment_attendance_summary),
|
||||||
|
AttendanceSummaryView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: AttendanceSummaryPresenter
|
lateinit var presenter: AttendanceSummaryPresenter
|
||||||
@ -39,35 +39,34 @@ class AttendanceSummaryFragment : BaseFragment(), AttendanceSummaryView, MainVie
|
|||||||
|
|
||||||
override val isViewEmpty get() = attendanceSummaryAdapter.items.isEmpty()
|
override val isViewEmpty get() = attendanceSummaryAdapter.items.isEmpty()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_attendance_summary, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentAttendanceSummaryBinding.bind(view)
|
||||||
|
messageContainer = binding.attendanceSummaryRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = attendanceSummaryRecycler
|
|
||||||
presenter.onAttachView(this, savedInstanceState?.getInt(SAVED_SUBJECT_KEY))
|
presenter.onAttachView(this, savedInstanceState?.getInt(SAVED_SUBJECT_KEY))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(attendanceSummaryRecycler) {
|
with(binding.attendanceSummaryRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = attendanceSummaryAdapter
|
adapter = attendanceSummaryAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
attendanceSummarySwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
with(binding) {
|
||||||
attendanceSummaryErrorRetry.setOnClickListener { presenter.onRetry() }
|
attendanceSummarySwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||||
attendanceSummaryErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
attendanceSummaryErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
attendanceSummaryErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
}
|
||||||
|
|
||||||
subjectsAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, mutableListOf())
|
subjectsAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, mutableListOf())
|
||||||
subjectsAdapter.setDropDownViewResource(R.layout.item_attendance_summary_subject)
|
subjectsAdapter.setDropDownViewResource(R.layout.item_attendance_summary_subject)
|
||||||
|
|
||||||
with(attendanceSummarySubjects) {
|
with(binding.attendanceSummarySubjects) {
|
||||||
adapter = subjectsAdapter
|
adapter = subjectsAdapter
|
||||||
setOnItemSelectedListener<TextView> { presenter.onSubjectSelected(it?.text?.toString()) }
|
setOnItemSelectedListener<TextView> { presenter.onSubjectSelected(it?.text?.toString()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
attendanceSummarySubjectsContainer.setElevationCompat(requireContext().dpToPx(1f))
|
binding.attendanceSummarySubjectsContainer.setElevationCompat(requireContext().dpToPx(1f))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateSubjects(data: ArrayList<String>) {
|
override fun updateSubjects(data: ArrayList<String>) {
|
||||||
@ -93,35 +92,35 @@ class AttendanceSummaryFragment : BaseFragment(), AttendanceSummaryView, MainVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
attendanceSummaryEmpty.visibility = if (show) VISIBLE else GONE
|
binding.attendanceSummaryEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
attendanceSummaryError.visibility = if (show) VISIBLE else GONE
|
binding.attendanceSummaryError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
attendanceSummaryErrorMessage.text = message
|
binding.attendanceSummaryErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
attendanceSummaryProgress.visibility = if (show) VISIBLE else GONE
|
binding.attendanceSummaryProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
attendanceSummarySwipe.isEnabled = enable
|
binding.attendanceSummarySwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
attendanceSummaryRecycler.visibility = if (show) VISIBLE else GONE
|
binding.attendanceSummaryRecycler.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showSubjects(show: Boolean) {
|
override fun showSubjects(show: Boolean) {
|
||||||
attendanceSummarySubjectsContainer.visibility = if (show) VISIBLE else INVISIBLE
|
binding.attendanceSummarySubjectsContainer.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
attendanceSummarySwipe.isRefreshing = false
|
binding.attendanceSummarySwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
@ -130,7 +129,7 @@ class AttendanceSummaryFragment : BaseFragment(), AttendanceSummaryView, MainVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
|
||||||
presenter.onDetachView()
|
presenter.onDetachView()
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,15 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import io.github.wulkanowy.R
|
|
||||||
import io.github.wulkanowy.data.db.entities.Exam
|
import io.github.wulkanowy.data.db.entities.Exam
|
||||||
|
import io.github.wulkanowy.databinding.DialogExamBinding
|
||||||
|
import io.github.wulkanowy.utils.lifecycleAwareVariable
|
||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
import kotlinx.android.synthetic.main.dialog_exam.*
|
|
||||||
|
|
||||||
class ExamDialog : DialogFragment() {
|
class ExamDialog : DialogFragment() {
|
||||||
|
|
||||||
|
private var binding: DialogExamBinding by lifecycleAwareVariable()
|
||||||
|
|
||||||
private lateinit var exam: Exam
|
private lateinit var exam: Exam
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -33,18 +35,20 @@ class ExamDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_exam, container, false)
|
return DialogExamBinding.inflate(inflater).apply { binding = this }.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
examDialogSubjectValue.text = exam.subject
|
with(binding) {
|
||||||
examDialogTypeValue.text = exam.type
|
examDialogSubjectValue.text = exam.subject
|
||||||
examDialogTeacherValue.text = exam.teacher
|
examDialogTypeValue.text = exam.type
|
||||||
examDialogDateValue.text = exam.entryDate.toFormattedString()
|
examDialogTeacherValue.text = exam.teacher
|
||||||
examDialogDescriptionValue.text = exam.description
|
examDialogDateValue.text = exam.entryDate.toFormattedString()
|
||||||
|
examDialogDescriptionValue.text = exam.description
|
||||||
|
|
||||||
examDialogClose.setOnClickListener { dismiss() }
|
examDialogClose.setOnClickListener { dismiss() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
package io.github.wulkanowy.ui.modules.exam
|
package io.github.wulkanowy.ui.modules.exam
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.INVISIBLE
|
import android.view.View.INVISIBLE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Exam
|
import io.github.wulkanowy.data.db.entities.Exam
|
||||||
|
import io.github.wulkanowy.databinding.FragmentExamBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import kotlinx.android.synthetic.main.fragment_exam.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ExamFragment : BaseFragment(), ExamView, MainView.MainChildView, MainView.TitledView {
|
class ExamFragment : BaseFragment<FragmentExamBinding>(R.layout.fragment_exam), ExamView,
|
||||||
|
MainView.MainChildView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: ExamPresenter
|
lateinit var presenter: ExamPresenter
|
||||||
@ -36,37 +35,36 @@ class ExamFragment : BaseFragment(), ExamView, MainView.MainChildView, MainView.
|
|||||||
|
|
||||||
override val isViewEmpty get() = examAdapter.items.isEmpty()
|
override val isViewEmpty get() = examAdapter.items.isEmpty()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_exam, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentExamBinding.bind(view)
|
||||||
|
messageContainer = binding.examRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = examRecycler
|
|
||||||
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
examAdapter.onClickListener = presenter::onExamItemSelected
|
examAdapter.onClickListener = presenter::onExamItemSelected
|
||||||
|
|
||||||
with(examRecycler) {
|
with(binding.examRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = examAdapter
|
adapter = examAdapter
|
||||||
addItemDecoration(DividerItemDecoration(context))
|
addItemDecoration(DividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
examSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
with(binding) {
|
||||||
examErrorRetry.setOnClickListener { presenter.onRetry() }
|
examSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||||
examErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
examErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
examErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
|
||||||
examPreviousButton.setOnClickListener { presenter.onPreviousWeek() }
|
examPreviousButton.setOnClickListener { presenter.onPreviousWeek() }
|
||||||
examNextButton.setOnClickListener { presenter.onNextWeek() }
|
examNextButton.setOnClickListener { presenter.onNextWeek() }
|
||||||
|
|
||||||
examNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
examNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
examSwipe.isRefreshing = false
|
binding.examSwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(data: List<ExamItem<*>>) {
|
override fun updateData(data: List<ExamItem<*>>) {
|
||||||
@ -77,7 +75,7 @@ class ExamFragment : BaseFragment(), ExamView, MainView.MainChildView, MainView.
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun updateNavigationWeek(date: String) {
|
override fun updateNavigationWeek(date: String) {
|
||||||
examNavDate.text = date
|
binding.examNavDate.text = date
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearData() {
|
override fun clearData() {
|
||||||
@ -88,7 +86,7 @@ class ExamFragment : BaseFragment(), ExamView, MainView.MainChildView, MainView.
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun resetView() {
|
override fun resetView() {
|
||||||
examRecycler.scrollToPosition(0)
|
binding.examRecycler.scrollToPosition(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFragmentReselected() {
|
override fun onFragmentReselected() {
|
||||||
@ -96,35 +94,35 @@ class ExamFragment : BaseFragment(), ExamView, MainView.MainChildView, MainView.
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
examEmpty.visibility = if (show) VISIBLE else GONE
|
binding.examEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
examError.visibility = if (show) VISIBLE else GONE
|
binding.examError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
examErrorMessage.text = message
|
binding.examErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
examProgress.visibility = if (show) VISIBLE else GONE
|
binding.examProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
examSwipe.isEnabled = enable
|
binding.examSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
examRecycler.visibility = if (show) VISIBLE else GONE
|
binding.examRecycler.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showPreButton(show: Boolean) {
|
override fun showPreButton(show: Boolean) {
|
||||||
examPreviousButton.visibility = if (show) VISIBLE else INVISIBLE
|
binding.examPreviousButton.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showNextButton(show: Boolean) {
|
override fun showNextButton(show: Boolean) {
|
||||||
examNextButton.visibility = if (show) VISIBLE else INVISIBLE
|
binding.examNextButton.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showExamDialog(exam: Exam) {
|
override fun showExamDialog(exam: Exam) {
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package io.github.wulkanowy.ui.modules.grade
|
package io.github.wulkanowy.ui.modules.grade
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
import android.view.MenuInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.INVISIBLE
|
import android.view.View.INVISIBLE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.databinding.FragmentGradeBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
||||||
import io.github.wulkanowy.ui.modules.grade.details.GradeDetailsFragment
|
import io.github.wulkanowy.ui.modules.grade.details.GradeDetailsFragment
|
||||||
@ -19,10 +18,9 @@ import io.github.wulkanowy.ui.modules.grade.summary.GradeSummaryFragment
|
|||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import io.github.wulkanowy.utils.setOnSelectPageListener
|
import io.github.wulkanowy.utils.setOnSelectPageListener
|
||||||
import kotlinx.android.synthetic.main.fragment_grade.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainView.TitledView {
|
class GradeFragment : BaseFragment<FragmentGradeBinding>(R.layout.fragment_grade), GradeView, MainView.MainChildView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: GradePresenter
|
lateinit var presenter: GradePresenter
|
||||||
@ -42,19 +40,16 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
|||||||
|
|
||||||
override var subtitleString = ""
|
override var subtitleString = ""
|
||||||
|
|
||||||
override val currentPageIndex get() = gradeViewPager.currentItem
|
override val currentPageIndex get() = binding.gradeViewPager.currentItem
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_grade, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentGradeBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this, savedInstanceState?.getInt(SAVED_SEMESTER_KEY))
|
presenter.onAttachView(this, savedInstanceState?.getInt(SAVED_SEMESTER_KEY))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +61,7 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
|||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(pagerAdapter) {
|
with(pagerAdapter) {
|
||||||
containerId = gradeViewPager.id
|
containerId = binding.gradeViewPager.id
|
||||||
addFragmentsWithTitle(mapOf(
|
addFragmentsWithTitle(mapOf(
|
||||||
GradeDetailsFragment.newInstance() to getString(R.string.all_details),
|
GradeDetailsFragment.newInstance() to getString(R.string.all_details),
|
||||||
GradeSummaryFragment.newInstance() to getString(R.string.grade_menu_summary),
|
GradeSummaryFragment.newInstance() to getString(R.string.grade_menu_summary),
|
||||||
@ -74,19 +69,21 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
with(gradeViewPager) {
|
with(binding.gradeViewPager) {
|
||||||
adapter = pagerAdapter
|
adapter = pagerAdapter
|
||||||
offscreenPageLimit = 3
|
offscreenPageLimit = 3
|
||||||
setOnSelectPageListener(presenter::onPageSelected)
|
setOnSelectPageListener(presenter::onPageSelected)
|
||||||
}
|
}
|
||||||
|
|
||||||
with(gradeTabLayout) {
|
with(binding.gradeTabLayout) {
|
||||||
setupWithViewPager(gradeViewPager)
|
setupWithViewPager(binding.gradeViewPager)
|
||||||
setElevationCompat(context.dpToPx(4f))
|
setElevationCompat(context.dpToPx(4f))
|
||||||
}
|
}
|
||||||
|
|
||||||
gradeErrorRetry.setOnClickListener { presenter.onRetry() }
|
with(binding) {
|
||||||
gradeErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
gradeErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
gradeErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
@ -99,20 +96,22 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
gradeViewPager.visibility = if (show) VISIBLE else INVISIBLE
|
with(binding) {
|
||||||
gradeTabLayout.visibility = if (show) VISIBLE else INVISIBLE
|
gradeViewPager.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
|
gradeTabLayout.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
gradeProgress.visibility = if (show) VISIBLE else INVISIBLE
|
binding.gradeProgress.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
gradeError.visibility = if (show) VISIBLE else INVISIBLE
|
binding.gradeError.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
gradeErrorMessage.text = message
|
binding.gradeErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showSemesterSwitch(show: Boolean) {
|
override fun showSemesterSwitch(show: Boolean) {
|
||||||
@ -166,7 +165,7 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
|
||||||
presenter.onDetachView()
|
presenter.onDetachView()
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,17 @@ import android.view.ViewGroup
|
|||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Grade
|
import io.github.wulkanowy.data.db.entities.Grade
|
||||||
|
import io.github.wulkanowy.databinding.DialogGradeBinding
|
||||||
import io.github.wulkanowy.utils.colorStringId
|
import io.github.wulkanowy.utils.colorStringId
|
||||||
import io.github.wulkanowy.utils.getBackgroundColor
|
import io.github.wulkanowy.utils.getBackgroundColor
|
||||||
import io.github.wulkanowy.utils.getGradeColor
|
import io.github.wulkanowy.utils.getGradeColor
|
||||||
|
import io.github.wulkanowy.utils.lifecycleAwareVariable
|
||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
import kotlinx.android.synthetic.main.dialog_grade.*
|
|
||||||
|
|
||||||
class GradeDetailsDialog : DialogFragment() {
|
class GradeDetailsDialog : DialogFragment() {
|
||||||
|
|
||||||
|
private var binding: DialogGradeBinding by lifecycleAwareVariable()
|
||||||
|
|
||||||
private lateinit var grade: Grade
|
private lateinit var grade: Grade
|
||||||
|
|
||||||
private lateinit var colorScheme: String
|
private lateinit var colorScheme: String
|
||||||
@ -44,47 +47,49 @@ class GradeDetailsDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_grade, container, false)
|
return DialogGradeBinding.inflate(inflater).apply { binding = this }.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
gradeDialogSubject.text = grade.subject
|
with(binding) {
|
||||||
|
gradeDialogSubject.text = grade.subject
|
||||||
|
|
||||||
gradeDialogColorAndWeightValue.run {
|
gradeDialogColorAndWeightValue.run {
|
||||||
text = context.getString(R.string.grade_weight_value, grade.weight)
|
text = context.getString(R.string.grade_weight_value, grade.weight)
|
||||||
setBackgroundResource(grade.getGradeColor())
|
setBackgroundResource(grade.getGradeColor())
|
||||||
}
|
|
||||||
|
|
||||||
gradeDialogDateValue.text = grade.date.toFormattedString()
|
|
||||||
gradeDialogColorValue.text = getString(grade.colorStringId)
|
|
||||||
|
|
||||||
gradeDialogCommentValue.apply {
|
|
||||||
if (grade.comment.isBlank()) {
|
|
||||||
visibility = GONE
|
|
||||||
gradeDialogComment.visibility = GONE
|
|
||||||
} else text = grade.comment
|
|
||||||
}
|
|
||||||
|
|
||||||
gradeDialogValue.run {
|
|
||||||
text = grade.entry
|
|
||||||
setBackgroundResource(grade.getBackgroundColor(colorScheme))
|
|
||||||
}
|
|
||||||
|
|
||||||
gradeDialogTeacherValue.text = if (grade.teacher.isBlank()) {
|
|
||||||
getString(R.string.all_no_data)
|
|
||||||
} else grade.teacher
|
|
||||||
|
|
||||||
gradeDialogDescriptionValue.text = grade.run {
|
|
||||||
when {
|
|
||||||
description.isBlank() && gradeSymbol.isNotBlank() -> gradeSymbol
|
|
||||||
description.isBlank() && gradeSymbol.isBlank() -> getString(R.string.all_no_description)
|
|
||||||
gradeSymbol.isNotBlank() && description.isNotBlank() -> "$gradeSymbol - $description"
|
|
||||||
else -> description
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gradeDialogClose.setOnClickListener { dismiss() }
|
gradeDialogDateValue.text = grade.date.toFormattedString()
|
||||||
|
gradeDialogColorValue.text = getString(grade.colorStringId)
|
||||||
|
|
||||||
|
gradeDialogCommentValue.apply {
|
||||||
|
if (grade.comment.isBlank()) {
|
||||||
|
visibility = GONE
|
||||||
|
gradeDialogComment.visibility = GONE
|
||||||
|
} else text = grade.comment
|
||||||
|
}
|
||||||
|
|
||||||
|
gradeDialogValue.run {
|
||||||
|
text = grade.entry
|
||||||
|
setBackgroundResource(grade.getBackgroundColor(colorScheme))
|
||||||
|
}
|
||||||
|
|
||||||
|
gradeDialogTeacherValue.text = if (grade.teacher.isBlank()) {
|
||||||
|
getString(R.string.all_no_data)
|
||||||
|
} else grade.teacher
|
||||||
|
|
||||||
|
gradeDialogDescriptionValue.text = grade.run {
|
||||||
|
when {
|
||||||
|
description.isBlank() && gradeSymbol.isNotBlank() -> gradeSymbol
|
||||||
|
description.isBlank() && gradeSymbol.isBlank() -> getString(R.string.all_no_description)
|
||||||
|
gradeSymbol.isNotBlank() && description.isNotBlank() -> "$gradeSymbol - $description"
|
||||||
|
else -> description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gradeDialogClose.setOnClickListener { dismiss() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package io.github.wulkanowy.ui.modules.grade.details
|
package io.github.wulkanowy.ui.modules.grade.details
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
import android.view.MenuInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
@ -9,18 +8,19 @@ import android.view.View
|
|||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.INVISIBLE
|
import android.view.View.INVISIBLE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Grade
|
import io.github.wulkanowy.data.db.entities.Grade
|
||||||
|
import io.github.wulkanowy.databinding.FragmentGradeDetailsBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
||||||
import io.github.wulkanowy.ui.modules.grade.GradeView
|
import io.github.wulkanowy.ui.modules.grade.GradeView
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import kotlinx.android.synthetic.main.fragment_grade_details.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class GradeDetailsFragment : BaseFragment(), GradeDetailsView, GradeView.GradeChildView {
|
class GradeDetailsFragment :
|
||||||
|
BaseFragment<FragmentGradeDetailsBinding>(R.layout.fragment_grade_details), GradeDetailsView,
|
||||||
|
GradeView.GradeChildView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: GradeDetailsPresenter
|
lateinit var presenter: GradeDetailsPresenter
|
||||||
@ -42,13 +42,10 @@ class GradeDetailsFragment : BaseFragment(), GradeDetailsView, GradeView.GradeCh
|
|||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_grade_details, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentGradeDetailsBinding.bind(view)
|
||||||
|
messageContainer = binding.gradeDetailsRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = gradeDetailsRecycler
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,13 +58,15 @@ class GradeDetailsFragment : BaseFragment(), GradeDetailsView, GradeView.GradeCh
|
|||||||
override fun initView() {
|
override fun initView() {
|
||||||
gradeDetailsAdapter.onClickListener = presenter::onGradeItemSelected
|
gradeDetailsAdapter.onClickListener = presenter::onGradeItemSelected
|
||||||
|
|
||||||
gradeDetailsRecycler.run {
|
with(binding) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
with(gradeDetailsRecycler) {
|
||||||
adapter = gradeDetailsAdapter
|
layoutManager = LinearLayoutManager(context)
|
||||||
|
adapter = gradeDetailsAdapter
|
||||||
|
}
|
||||||
|
gradeDetailsSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||||
|
gradeDetailsErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
gradeDetailsErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
}
|
}
|
||||||
gradeDetailsSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
|
||||||
gradeDetailsErrorRetry.setOnClickListener { presenter.onRetry() }
|
|
||||||
gradeDetailsErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
@ -99,7 +98,7 @@ class GradeDetailsFragment : BaseFragment(), GradeDetailsView, GradeView.GradeCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun scrollToStart() {
|
override fun scrollToStart() {
|
||||||
gradeDetailsRecycler.smoothScrollToPosition(0)
|
binding.gradeDetailsRecycler.smoothScrollToPosition(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getHeaderOfItem(subject: String): GradeDetailsItem {
|
override fun getHeaderOfItem(subject: String): GradeDetailsItem {
|
||||||
@ -111,31 +110,31 @@ class GradeDetailsFragment : BaseFragment(), GradeDetailsView, GradeView.GradeCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
gradeDetailsProgress.visibility = if (show) VISIBLE else GONE
|
binding.gradeDetailsProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
gradeDetailsSwipe.isEnabled = enable
|
binding.gradeDetailsSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
gradeDetailsRecycler.visibility = if (show) VISIBLE else INVISIBLE
|
binding.gradeDetailsRecycler.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
gradeDetailsEmpty.visibility = if (show) VISIBLE else INVISIBLE
|
binding.gradeDetailsEmpty.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
gradeDetailsError.visibility = if (show) VISIBLE else GONE
|
binding.gradeDetailsError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
gradeDetailsErrorMessage.text = message
|
binding.gradeDetailsErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showRefresh(show: Boolean) {
|
override fun showRefresh(show: Boolean) {
|
||||||
gradeDetailsSwipe.isRefreshing = show
|
binding.gradeDetailsSwipe.isRefreshing = show
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showGradeDialog(grade: Grade, colorScheme: String) {
|
override fun showGradeDialog(grade: Grade, colorScheme: String) {
|
||||||
@ -167,7 +166,7 @@ class GradeDetailsFragment : BaseFragment(), GradeDetailsView, GradeView.GradeCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
|
||||||
presenter.onDetachView()
|
presenter.onDetachView()
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package io.github.wulkanowy.ui.modules.grade.statistics
|
|||||||
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -21,9 +20,9 @@ import io.github.wulkanowy.R
|
|||||||
import io.github.wulkanowy.data.db.entities.GradePointsStatistics
|
import io.github.wulkanowy.data.db.entities.GradePointsStatistics
|
||||||
import io.github.wulkanowy.data.db.entities.GradeStatistics
|
import io.github.wulkanowy.data.db.entities.GradeStatistics
|
||||||
import io.github.wulkanowy.data.pojos.GradeStatisticsItem
|
import io.github.wulkanowy.data.pojos.GradeStatisticsItem
|
||||||
|
import io.github.wulkanowy.databinding.ItemGradeStatisticsBarBinding
|
||||||
|
import io.github.wulkanowy.databinding.ItemGradeStatisticsPieBinding
|
||||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||||
import kotlinx.android.synthetic.main.item_grade_statistics_bar.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_grade_statistics_pie.view.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class GradeStatisticsAdapter @Inject constructor() :
|
class GradeStatisticsAdapter @Inject constructor() :
|
||||||
@ -62,30 +61,26 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
|
|
||||||
override fun getItemCount() = items.size
|
override fun getItemCount() = items.size
|
||||||
|
|
||||||
override fun getItemViewType(position: Int): Int {
|
override fun getItemViewType(position: Int) = items[position].type.id
|
||||||
return when (items[position].type) {
|
|
||||||
ViewType.SEMESTER, ViewType.PARTIAL -> R.layout.item_grade_statistics_pie
|
|
||||||
ViewType.POINTS -> R.layout.item_grade_statistics_bar
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||||
val viewHolder = LayoutInflater.from(parent.context).inflate(viewType, parent, false)
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
return when (viewType) {
|
return when (viewType) {
|
||||||
R.layout.item_grade_statistics_bar -> GradeStatisticsBar(viewHolder)
|
ViewType.PARTIAL.id, ViewType.SEMESTER.id -> PieViewHolder(ItemGradeStatisticsPieBinding.inflate(inflater, parent, false))
|
||||||
else -> GradeStatisticsPie(viewHolder)
|
ViewType.POINTS.id -> BarViewHolder(ItemGradeStatisticsBarBinding.inflate(inflater, parent, false))
|
||||||
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||||
when (holder) {
|
when (holder) {
|
||||||
is GradeStatisticsPie -> bindPieChart(holder, items[position].partial)
|
is PieViewHolder -> bindPieChart(holder, items[position].partial)
|
||||||
is GradeStatisticsBar -> bindBarChart(holder, items[position].points!!)
|
is BarViewHolder -> bindBarChart(holder, items[position].points!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindPieChart(holder: GradeStatisticsPie, partials: List<GradeStatistics>) {
|
private fun bindPieChart(holder: PieViewHolder, partials: List<GradeStatistics>) {
|
||||||
with(holder.view.gradeStatisticsPieTitle) {
|
with(holder.binding.gradeStatisticsPieTitle) {
|
||||||
text = partials.firstOrNull()?.subject
|
text = partials.firstOrNull()?.subject
|
||||||
visibility = if (items.size == 1) GONE else VISIBLE
|
visibility = if (items.size == 1) GONE else VISIBLE
|
||||||
}
|
}
|
||||||
@ -105,10 +100,10 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
valueTextColor = Color.WHITE
|
valueTextColor = Color.WHITE
|
||||||
setColors(partials.map {
|
setColors(partials.map {
|
||||||
gradeColors.single { color -> color.first == it.grade }.second
|
gradeColors.single { color -> color.first == it.grade }.second
|
||||||
}.toIntArray(), holder.view.context)
|
}.toIntArray(), holder.binding.root.context)
|
||||||
}
|
}
|
||||||
|
|
||||||
with(holder.view.gradeStatisticsPie) {
|
with(holder.binding.gradeStatisticsPie) {
|
||||||
setTouchEnabled(false)
|
setTouchEnabled(false)
|
||||||
if (partials.size == 1) animateXY(1000, 1000)
|
if (partials.size == 1) animateXY(1000, 1000)
|
||||||
data = PieData(dataset).apply {
|
data = PieData(dataset).apply {
|
||||||
@ -140,8 +135,8 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindBarChart(holder: GradeStatisticsBar, points: GradePointsStatistics) {
|
private fun bindBarChart(holder: BarViewHolder, points: GradePointsStatistics) {
|
||||||
with(holder.view.gradeStatisticsBarTitle) {
|
with(holder.binding.gradeStatisticsBarTitle) {
|
||||||
text = points.subject
|
text = points.subject
|
||||||
visibility = if (items.size == 1) GONE else VISIBLE
|
visibility = if (items.size == 1) GONE else VISIBLE
|
||||||
}
|
}
|
||||||
@ -153,14 +148,14 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
|
|
||||||
with(dataset) {
|
with(dataset) {
|
||||||
valueTextSize = 12f
|
valueTextSize = 12f
|
||||||
valueTextColor = holder.view.context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
valueTextColor = holder.binding.root.context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
||||||
valueFormatter = object : ValueFormatter() {
|
valueFormatter = object : ValueFormatter() {
|
||||||
override fun getBarLabel(barEntry: BarEntry) = "${barEntry.y}%"
|
override fun getBarLabel(barEntry: BarEntry) = "${barEntry.y}%"
|
||||||
}
|
}
|
||||||
colors = gradePointsColors
|
colors = gradePointsColors
|
||||||
}
|
}
|
||||||
|
|
||||||
with(holder.view.gradeStatisticsBar) {
|
with(holder.binding.gradeStatisticsBar) {
|
||||||
setTouchEnabled(false)
|
setTouchEnabled(false)
|
||||||
if (items.size == 1) animateXY(1000, 1000)
|
if (items.size == 1) animateXY(1000, 1000)
|
||||||
data = BarData(dataset).apply {
|
data = BarData(dataset).apply {
|
||||||
@ -183,7 +178,7 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
|
|
||||||
description.isEnabled = false
|
description.isEnabled = false
|
||||||
|
|
||||||
holder.view.context.getThemeAttrColor(android.R.attr.textColorPrimary).let {
|
holder.binding.root.context.getThemeAttrColor(android.R.attr.textColorPrimary).let {
|
||||||
axisLeft.textColor = it
|
axisLeft.textColor = it
|
||||||
axisRight.textColor = it
|
axisRight.textColor = it
|
||||||
}
|
}
|
||||||
@ -203,7 +198,9 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GradeStatisticsPie(val view: View) : RecyclerView.ViewHolder(view)
|
private class PieViewHolder(val binding: ItemGradeStatisticsPieBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root)
|
||||||
|
|
||||||
class GradeStatisticsBar(val view: View) : RecyclerView.ViewHolder(view)
|
private class BarViewHolder(val binding: ItemGradeStatisticsBarBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root)
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
package io.github.wulkanowy.ui.modules.grade.statistics
|
package io.github.wulkanowy.ui.modules.grade.statistics
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.pojos.GradeStatisticsItem
|
import io.github.wulkanowy.data.pojos.GradeStatisticsItem
|
||||||
|
import io.github.wulkanowy.databinding.FragmentGradeStatisticsBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
||||||
import io.github.wulkanowy.ui.modules.grade.GradeView
|
import io.github.wulkanowy.ui.modules.grade.GradeView
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import io.github.wulkanowy.utils.setOnItemSelectedListener
|
import io.github.wulkanowy.utils.setOnItemSelectedListener
|
||||||
import kotlinx.android.synthetic.main.fragment_grade_statistics.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.GradeChildView {
|
class GradeStatisticsFragment :
|
||||||
|
BaseFragment<FragmentGradeStatisticsBinding>(R.layout.fragment_grade_statistics),
|
||||||
|
GradeStatisticsView, GradeView.GradeChildView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: GradeStatisticsPresenter
|
lateinit var presenter: GradeStatisticsPresenter
|
||||||
@ -36,24 +36,21 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
|||||||
override val isViewEmpty get() = statisticsAdapter.items.isEmpty()
|
override val isViewEmpty get() = statisticsAdapter.items.isEmpty()
|
||||||
|
|
||||||
override val currentType
|
override val currentType
|
||||||
get() = when (gradeStatisticsTypeSwitch.checkedRadioButtonId) {
|
get() = when (binding.gradeStatisticsTypeSwitch.checkedRadioButtonId) {
|
||||||
R.id.gradeStatisticsTypeSemester -> ViewType.SEMESTER
|
R.id.gradeStatisticsTypeSemester -> ViewType.SEMESTER
|
||||||
R.id.gradeStatisticsTypePartial -> ViewType.PARTIAL
|
R.id.gradeStatisticsTypePartial -> ViewType.PARTIAL
|
||||||
else -> ViewType.POINTS
|
else -> ViewType.POINTS
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_grade_statistics, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentGradeStatisticsBinding.bind(view)
|
||||||
|
messageContainer = binding.gradeStatisticsSwipe
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = gradeStatisticsSwipe
|
|
||||||
presenter.onAttachView(this, savedInstanceState?.getSerializable(SAVED_CHART_TYPE) as? ViewType)
|
presenter.onAttachView(this, savedInstanceState?.getSerializable(SAVED_CHART_TYPE) as? ViewType)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(gradeStatisticsRecycler) {
|
with(binding.gradeStatisticsRecycler) {
|
||||||
layoutManager = LinearLayoutManager(requireContext())
|
layoutManager = LinearLayoutManager(requireContext())
|
||||||
adapter = statisticsAdapter
|
adapter = statisticsAdapter
|
||||||
}
|
}
|
||||||
@ -61,16 +58,18 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
|||||||
subjectsAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, mutableListOf())
|
subjectsAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, mutableListOf())
|
||||||
subjectsAdapter.setDropDownViewResource(R.layout.item_attendance_summary_subject)
|
subjectsAdapter.setDropDownViewResource(R.layout.item_attendance_summary_subject)
|
||||||
|
|
||||||
with(gradeStatisticsSubjects) {
|
with(binding.gradeStatisticsSubjects) {
|
||||||
adapter = subjectsAdapter
|
adapter = subjectsAdapter
|
||||||
setOnItemSelectedListener<TextView> { presenter.onSubjectSelected(it?.text?.toString()) }
|
setOnItemSelectedListener<TextView> { presenter.onSubjectSelected(it?.text?.toString()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
gradeStatisticsSubjectsContainer.setElevationCompat(requireContext().dpToPx(1f))
|
with(binding) {
|
||||||
|
gradeStatisticsSubjectsContainer.setElevationCompat(requireContext().dpToPx(1f))
|
||||||
|
|
||||||
gradeStatisticsSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
gradeStatisticsSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||||
gradeStatisticsErrorRetry.setOnClickListener { presenter.onRetry() }
|
gradeStatisticsErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
gradeStatisticsErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
gradeStatisticsErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateSubjects(data: ArrayList<String>) {
|
override fun updateSubjects(data: ArrayList<String>) {
|
||||||
@ -88,8 +87,10 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showSubjects(show: Boolean) {
|
override fun showSubjects(show: Boolean) {
|
||||||
gradeStatisticsSubjectsContainer.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
with(binding) {
|
||||||
gradeStatisticsTypeSwitch.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
gradeStatisticsSubjectsContainer.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
||||||
|
gradeStatisticsTypeSwitch.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearView() {
|
override fun clearView() {
|
||||||
@ -97,35 +98,35 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun resetView() {
|
override fun resetView() {
|
||||||
gradeStatisticsScroll.scrollTo(0, 0)
|
binding.gradeStatisticsScroll.scrollTo(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
gradeStatisticsRecycler.visibility = if (show) View.VISIBLE else View.GONE
|
binding.gradeStatisticsRecycler.visibility = if (show) View.VISIBLE else View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
gradeStatisticsEmpty.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
binding.gradeStatisticsEmpty.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
gradeStatisticsError.visibility = if (show) View.VISIBLE else View.GONE
|
binding.gradeStatisticsError.visibility = if (show) View.VISIBLE else View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
gradeStatisticsErrorMessage.text = message
|
binding.gradeStatisticsErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
gradeStatisticsProgress.visibility = if (show) View.VISIBLE else View.GONE
|
binding.gradeStatisticsProgress.visibility = if (show) View.VISIBLE else View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
gradeStatisticsSwipe.isEnabled = enable
|
binding.gradeStatisticsSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showRefresh(show: Boolean) {
|
override fun showRefresh(show: Boolean) {
|
||||||
gradeStatisticsSwipe.isRefreshing = show
|
binding.gradeStatisticsSwipe.isRefreshing = show
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onParentLoadData(semesterId: Int, forceRefresh: Boolean) {
|
override fun onParentLoadData(semesterId: Int, forceRefresh: Boolean) {
|
||||||
@ -150,7 +151,7 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
gradeStatisticsTypeSwitch.setOnCheckedChangeListener { _, _ -> presenter.onTypeChange() }
|
binding.gradeStatisticsTypeSwitch.setOnCheckedChangeListener { _, _ -> presenter.onTypeChange() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
@ -159,7 +160,7 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
|
||||||
presenter.onDetachView()
|
presenter.onDetachView()
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.github.wulkanowy.ui.modules.grade.statistics
|
package io.github.wulkanowy.ui.modules.grade.statistics
|
||||||
|
|
||||||
enum class ViewType {
|
enum class ViewType(val id: Int) {
|
||||||
SEMESTER,
|
SEMESTER(1),
|
||||||
PARTIAL,
|
PARTIAL(2),
|
||||||
POINTS
|
POINTS(3)
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
package io.github.wulkanowy.ui.modules.grade.summary
|
package io.github.wulkanowy.ui.modules.grade.summary
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.INVISIBLE
|
import android.view.View.INVISIBLE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.GradeSummary
|
import io.github.wulkanowy.data.db.entities.GradeSummary
|
||||||
|
import io.github.wulkanowy.databinding.FragmentGradeSummaryBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
||||||
import io.github.wulkanowy.ui.modules.grade.GradeView
|
import io.github.wulkanowy.ui.modules.grade.GradeView
|
||||||
import kotlinx.android.synthetic.main.fragment_grade_summary.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class GradeSummaryFragment : BaseFragment(), GradeSummaryView, GradeView.GradeChildView {
|
class GradeSummaryFragment :
|
||||||
|
BaseFragment<FragmentGradeSummaryBinding>(R.layout.fragment_grade_summary), GradeSummaryView,
|
||||||
|
GradeView.GradeChildView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: GradeSummaryPresenter
|
lateinit var presenter: GradeSummaryPresenter
|
||||||
@ -37,24 +37,23 @@ class GradeSummaryFragment : BaseFragment(), GradeSummaryView, GradeView.GradeCh
|
|||||||
override val finalString
|
override val finalString
|
||||||
get() = getString(R.string.grade_summary_final_grade)
|
get() = getString(R.string.grade_summary_final_grade)
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_grade_summary, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentGradeSummaryBinding.bind(view)
|
||||||
|
messageContainer = binding.gradeSummaryRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = gradeSummaryRecycler
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
gradeSummaryRecycler.run {
|
with(binding.gradeSummaryRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = gradeSummaryAdapter
|
adapter = gradeSummaryAdapter
|
||||||
}
|
}
|
||||||
gradeSummarySwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
with(binding) {
|
||||||
gradeSummaryErrorRetry.setOnClickListener { presenter.onRetry() }
|
gradeSummarySwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||||
gradeSummaryErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
gradeSummaryErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
gradeSummaryErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(data: List<GradeSummary>) {
|
override fun updateData(data: List<GradeSummary>) {
|
||||||
@ -72,35 +71,35 @@ class GradeSummaryFragment : BaseFragment(), GradeSummaryView, GradeView.GradeCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun resetView() {
|
override fun resetView() {
|
||||||
gradeSummaryRecycler.scrollToPosition(0)
|
binding.gradeSummaryRecycler.scrollToPosition(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
gradeSummaryRecycler.visibility = if (show) VISIBLE else INVISIBLE
|
binding.gradeSummaryRecycler.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
gradeSummaryEmpty.visibility = if (show) VISIBLE else INVISIBLE
|
binding.gradeSummaryEmpty.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
gradeSummaryError.visibility = if (show) VISIBLE else INVISIBLE
|
binding.gradeSummaryError.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
gradeSummaryErrorMessage.text = message
|
binding.gradeSummaryErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
gradeSummaryProgress.visibility = if (show) VISIBLE else GONE
|
binding.gradeSummaryProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
gradeSummarySwipe.isEnabled = enable
|
binding.gradeSummarySwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showRefresh(show: Boolean) {
|
override fun showRefresh(show: Boolean) {
|
||||||
gradeSummarySwipe.isRefreshing = show
|
binding.gradeSummarySwipe.isRefreshing = show
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onParentLoadData(semesterId: Int, forceRefresh: Boolean) {
|
override fun onParentLoadData(semesterId: Int, forceRefresh: Boolean) {
|
||||||
@ -124,7 +123,7 @@ class GradeSummaryFragment : BaseFragment(), GradeSummaryView, GradeView.GradeCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
|
||||||
presenter.onDetachView()
|
presenter.onDetachView()
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
package io.github.wulkanowy.ui.modules.homework
|
package io.github.wulkanowy.ui.modules.homework
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Homework
|
import io.github.wulkanowy.data.db.entities.Homework
|
||||||
|
import io.github.wulkanowy.databinding.FragmentHomeworkBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
|
||||||
import io.github.wulkanowy.ui.modules.homework.details.HomeworkDetailsDialog
|
import io.github.wulkanowy.ui.modules.homework.details.HomeworkDetailsDialog
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import kotlinx.android.synthetic.main.fragment_homework.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
class HomeworkFragment : BaseFragment<FragmentHomeworkBinding>(R.layout.fragment_homework),
|
||||||
|
HomeworkView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: HomeworkPresenter
|
lateinit var presenter: HomeworkPresenter
|
||||||
@ -36,33 +35,32 @@ class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
|||||||
|
|
||||||
override val isViewEmpty get() = homeworkAdapter.items.isEmpty()
|
override val isViewEmpty get() = homeworkAdapter.items.isEmpty()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_homework, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentHomeworkBinding.bind(view)
|
||||||
|
messageContainer = binding.homeworkRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = homeworkRecycler
|
|
||||||
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
homeworkAdapter.onClickListener = presenter::onHomeworkItemSelected
|
homeworkAdapter.onClickListener = presenter::onHomeworkItemSelected
|
||||||
|
|
||||||
with(homeworkRecycler) {
|
with(binding.homeworkRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = homeworkAdapter
|
adapter = homeworkAdapter
|
||||||
addItemDecoration(DividerItemDecoration(context))
|
addItemDecoration(DividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
homeworkSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
with(binding) {
|
||||||
homeworkErrorRetry.setOnClickListener { presenter.onRetry() }
|
homeworkSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||||
homeworkErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
homeworkErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
homeworkErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
|
||||||
homeworkPreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
homeworkPreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||||
homeworkNextButton.setOnClickListener { presenter.onNextDay() }
|
homeworkNextButton.setOnClickListener { presenter.onNextDay() }
|
||||||
|
|
||||||
homeworkNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
homeworkNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(data: List<HomeworkItem<*>>) {
|
override fun updateData(data: List<HomeworkItem<*>>) {
|
||||||
@ -84,43 +82,43 @@ class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun updateNavigationWeek(date: String) {
|
override fun updateNavigationWeek(date: String) {
|
||||||
homeworkNavDate.text = date
|
binding.homeworkNavDate.text = date
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
homeworkSwipe.isRefreshing = false
|
binding.homeworkSwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
homeworkEmpty.visibility = if (show) VISIBLE else GONE
|
binding.homeworkEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
homeworkError.visibility = if (show) VISIBLE else GONE
|
binding.homeworkError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
homeworkErrorMessage.text = message
|
binding.homeworkErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
homeworkProgress.visibility = if (show) VISIBLE else GONE
|
binding.homeworkProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
homeworkSwipe.isEnabled = enable
|
binding.homeworkSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
homeworkRecycler.visibility = if (show) VISIBLE else GONE
|
binding.homeworkRecycler.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showPreButton(show: Boolean) {
|
override fun showPreButton(show: Boolean) {
|
||||||
homeworkPreviousButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
binding.homeworkPreviousButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showNextButton(show: Boolean) {
|
override fun showNextButton(show: Boolean) {
|
||||||
homeworkNextButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
binding.homeworkNextButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showTimetableDialog(homework: Homework) {
|
override fun showTimetableDialog(homework: Homework) {
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package io.github.wulkanowy.ui.modules.homework.details
|
package io.github.wulkanowy.ui.modules.homework.details
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import io.github.wulkanowy.R
|
|
||||||
import io.github.wulkanowy.data.db.entities.Homework
|
import io.github.wulkanowy.data.db.entities.Homework
|
||||||
|
import io.github.wulkanowy.databinding.ItemHomeworkDialogAttachmentBinding
|
||||||
|
import io.github.wulkanowy.databinding.ItemHomeworkDialogAttachmentsHeaderBinding
|
||||||
|
import io.github.wulkanowy.databinding.ItemHomeworkDialogDetailsBinding
|
||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
import kotlinx.android.synthetic.main.item_homework_dialog_attachment.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_homework_dialog_details.view.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class HomeworkDetailsAdapter @Inject constructor() :
|
class HomeworkDetailsAdapter @Inject constructor() :
|
||||||
@ -42,9 +41,9 @@ class HomeworkDetailsAdapter @Inject constructor() :
|
|||||||
val inflater = LayoutInflater.from(parent.context)
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
|
|
||||||
return when (viewType) {
|
return when (viewType) {
|
||||||
ViewType.ATTACHMENTS_HEADER.id -> AttachmentsHeaderViewHolder(inflater.inflate(R.layout.item_homework_dialog_attachments_header, parent, false))
|
ViewType.ATTACHMENTS_HEADER.id -> AttachmentsHeaderViewHolder(ItemHomeworkDialogAttachmentsHeaderBinding.inflate(inflater, parent, false))
|
||||||
ViewType.ATTACHMENT.id -> AttachmentViewHolder(inflater.inflate(R.layout.item_homework_dialog_attachment, parent, false))
|
ViewType.ATTACHMENT.id -> AttachmentViewHolder(ItemHomeworkDialogAttachmentBinding.inflate(inflater, parent, false))
|
||||||
else -> DetailsViewHolder(inflater.inflate(R.layout.item_homework_dialog_details, parent, false))
|
else -> DetailsViewHolder(ItemHomeworkDialogDetailsBinding.inflate(inflater, parent, false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +55,7 @@ class HomeworkDetailsAdapter @Inject constructor() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun bindDetailsViewHolder(holder: DetailsViewHolder) {
|
private fun bindDetailsViewHolder(holder: DetailsViewHolder) {
|
||||||
with(holder.view) {
|
with(holder.binding) {
|
||||||
homeworkDialogDate.text = homework?.date?.toFormattedString()
|
homeworkDialogDate.text = homework?.date?.toFormattedString()
|
||||||
homeworkDialogEntryDate.text = homework?.entryDate?.toFormattedString()
|
homeworkDialogEntryDate.text = homework?.entryDate?.toFormattedString()
|
||||||
homeworkDialogSubject.text = homework?.subject
|
homeworkDialogSubject.text = homework?.subject
|
||||||
@ -68,17 +67,20 @@ class HomeworkDetailsAdapter @Inject constructor() :
|
|||||||
private fun bindAttachmentViewHolder(holder: AttachmentViewHolder, position: Int) {
|
private fun bindAttachmentViewHolder(holder: AttachmentViewHolder, position: Int) {
|
||||||
val item = attachments[position]
|
val item = attachments[position]
|
||||||
|
|
||||||
with(holder.view) {
|
with(holder.binding) {
|
||||||
homeworkDialogAttachment.text = item.second
|
homeworkDialogAttachment.text = item.second
|
||||||
setOnClickListener {
|
root.setOnClickListener {
|
||||||
onAttachmentClickListener(item.first)
|
onAttachmentClickListener(item.first)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DetailsViewHolder(val view: View) : RecyclerView.ViewHolder(view)
|
class DetailsViewHolder(val binding: ItemHomeworkDialogDetailsBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root)
|
||||||
|
|
||||||
class AttachmentsHeaderViewHolder(val view: View) : RecyclerView.ViewHolder(view)
|
class AttachmentsHeaderViewHolder(val binding: ItemHomeworkDialogAttachmentsHeaderBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root)
|
||||||
|
|
||||||
class AttachmentViewHolder(val view: View) : RecyclerView.ViewHolder(view)
|
class AttachmentViewHolder(val binding: ItemHomeworkDialogAttachmentBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root)
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,13 @@ import android.view.ViewGroup
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Homework
|
import io.github.wulkanowy.data.db.entities.Homework
|
||||||
|
import io.github.wulkanowy.databinding.DialogHomeworkBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseDialogFragment
|
import io.github.wulkanowy.ui.base.BaseDialogFragment
|
||||||
import io.github.wulkanowy.ui.modules.homework.HomeworkFragment
|
import io.github.wulkanowy.ui.modules.homework.HomeworkFragment
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import kotlinx.android.synthetic.main.dialog_homework.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class HomeworkDetailsDialog : BaseDialogFragment(), HomeworkDetailsView {
|
class HomeworkDetailsDialog : BaseDialogFragment<DialogHomeworkBinding>(), HomeworkDetailsView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: HomeworkDetailsPresenter
|
lateinit var presenter: HomeworkDetailsPresenter
|
||||||
@ -43,7 +43,7 @@ class HomeworkDetailsDialog : BaseDialogFragment(), HomeworkDetailsView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_homework, container, false)
|
return DialogHomeworkBinding.inflate(inflater).apply { binding = this }.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
@ -53,11 +53,13 @@ class HomeworkDetailsDialog : BaseDialogFragment(), HomeworkDetailsView {
|
|||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
homeworkDialogRead.text = view?.context?.getString(if (homework.isDone) R.string.homework_mark_as_undone else R.string.homework_mark_as_done)
|
with(binding) {
|
||||||
homeworkDialogRead.setOnClickListener { presenter.toggleDone(homework) }
|
homeworkDialogRead.text = view?.context?.getString(if (homework.isDone) R.string.homework_mark_as_undone else R.string.homework_mark_as_done)
|
||||||
homeworkDialogClose.setOnClickListener { dismiss() }
|
homeworkDialogRead.setOnClickListener { presenter.toggleDone(homework) }
|
||||||
|
homeworkDialogClose.setOnClickListener { dismiss() }
|
||||||
|
}
|
||||||
|
|
||||||
with(homeworkDialogRecycler) {
|
with(binding.homeworkDialogRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = detailsAdapter.apply {
|
adapter = detailsAdapter.apply {
|
||||||
onAttachmentClickListener = { context.openInternetBrowser(it, ::showMessage) }
|
onAttachmentClickListener = { context.openInternetBrowser(it, ::showMessage) }
|
||||||
@ -68,7 +70,7 @@ class HomeworkDetailsDialog : BaseDialogFragment(), HomeworkDetailsView {
|
|||||||
|
|
||||||
override fun updateMarkAsDoneLabel(isDone: Boolean) {
|
override fun updateMarkAsDoneLabel(isDone: Boolean) {
|
||||||
(parentFragment as? HomeworkFragment)?.onReloadList()
|
(parentFragment as? HomeworkFragment)?.onReloadList()
|
||||||
homeworkDialogRead.text = view?.context?.getString(if (isDone) R.string.homework_mark_as_undone else R.string.homework_mark_as_done)
|
binding.homeworkDialogRead.text = view?.context?.getString(if (isDone) R.string.homework_mark_as_undone else R.string.homework_mark_as_done)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
@ -4,8 +4,8 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import io.github.wulkanowy.R
|
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
|
import io.github.wulkanowy.databinding.ActivityLoginBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseActivity
|
import io.github.wulkanowy.ui.base.BaseActivity
|
||||||
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
||||||
import io.github.wulkanowy.ui.modules.login.advanced.LoginAdvancedFragment
|
import io.github.wulkanowy.ui.modules.login.advanced.LoginAdvancedFragment
|
||||||
@ -14,10 +14,9 @@ import io.github.wulkanowy.ui.modules.login.recover.LoginRecoverFragment
|
|||||||
import io.github.wulkanowy.ui.modules.login.studentselect.LoginStudentSelectFragment
|
import io.github.wulkanowy.ui.modules.login.studentselect.LoginStudentSelectFragment
|
||||||
import io.github.wulkanowy.ui.modules.login.symbol.LoginSymbolFragment
|
import io.github.wulkanowy.ui.modules.login.symbol.LoginSymbolFragment
|
||||||
import io.github.wulkanowy.utils.setOnSelectPageListener
|
import io.github.wulkanowy.utils.setOnSelectPageListener
|
||||||
import kotlinx.android.synthetic.main.activity_login.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
|
class LoginActivity : BaseActivity<LoginPresenter, ActivityLoginBinding>(), LoginView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
override lateinit var presenter: LoginPresenter
|
override lateinit var presenter: LoginPresenter
|
||||||
@ -30,13 +29,13 @@ class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
|
|||||||
fun getStartIntent(context: Context) = Intent(context, LoginActivity::class.java)
|
fun getStartIntent(context: Context) = Intent(context, LoginActivity::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val currentViewIndex get() = loginViewpager.currentItem
|
override val currentViewIndex get() = binding.loginViewpager.currentItem
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_login)
|
setContentView(ActivityLoginBinding.inflate(layoutInflater).apply { binding = this }.root)
|
||||||
setSupportActionBar(loginToolbar)
|
setSupportActionBar(binding.loginToolbar)
|
||||||
messageContainer = loginContainer
|
messageContainer = binding.loginContainer
|
||||||
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
@ -48,7 +47,7 @@ class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
with(loginAdapter) {
|
with(loginAdapter) {
|
||||||
containerId = loginViewpager.id
|
containerId = binding.loginViewpager.id
|
||||||
addFragments(listOf(
|
addFragments(listOf(
|
||||||
LoginFormFragment.newInstance(),
|
LoginFormFragment.newInstance(),
|
||||||
LoginSymbolFragment.newInstance(),
|
LoginSymbolFragment.newInstance(),
|
||||||
@ -58,7 +57,7 @@ class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
with(loginViewpager) {
|
with(binding.loginViewpager) {
|
||||||
offscreenPageLimit = 2
|
offscreenPageLimit = 2
|
||||||
adapter = loginAdapter
|
adapter = loginAdapter
|
||||||
setOnSelectPageListener(presenter::onViewSelected)
|
setOnSelectPageListener(presenter::onViewSelected)
|
||||||
@ -71,7 +70,7 @@ class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun switchView(index: Int) {
|
override fun switchView(index: Int) {
|
||||||
loginViewpager.setCurrentItem(index, false)
|
binding.loginViewpager.setCurrentItem(index, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showActionBar(show: Boolean) {
|
override fun showActionBar(show: Boolean) {
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package io.github.wulkanowy.ui.modules.login.advanced
|
package io.github.wulkanowy.ui.modules.login.advanced
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
|
import io.github.wulkanowy.databinding.FragmentLoginAdvancedBinding
|
||||||
import io.github.wulkanowy.sdk.Sdk
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
@ -17,10 +16,11 @@ import io.github.wulkanowy.ui.modules.login.form.LoginSymbolAdapter
|
|||||||
import io.github.wulkanowy.utils.hideSoftInput
|
import io.github.wulkanowy.utils.hideSoftInput
|
||||||
import io.github.wulkanowy.utils.setOnEditorDoneSignIn
|
import io.github.wulkanowy.utils.setOnEditorDoneSignIn
|
||||||
import io.github.wulkanowy.utils.showSoftInput
|
import io.github.wulkanowy.utils.showSoftInput
|
||||||
import kotlinx.android.synthetic.main.fragment_login_advanced.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LoginAdvancedFragment : BaseFragment(), LoginAdvancedView {
|
class LoginAdvancedFragment :
|
||||||
|
BaseFragment<FragmentLoginAdvancedBinding>(R.layout.fragment_login_advanced),
|
||||||
|
LoginAdvancedView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: LoginAdvancedPresenter
|
lateinit var presenter: LoginAdvancedPresenter
|
||||||
@ -30,17 +30,17 @@ class LoginAdvancedFragment : BaseFragment(), LoginAdvancedView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val formLoginType: String
|
override val formLoginType: String
|
||||||
get() = when (loginTypeSwitch.checkedRadioButtonId) {
|
get() = when (binding.loginTypeSwitch.checkedRadioButtonId) {
|
||||||
R.id.loginTypeApi -> "API"
|
R.id.loginTypeApi -> "API"
|
||||||
R.id.loginTypeScrapper -> "SCRAPPER"
|
R.id.loginTypeScrapper -> "SCRAPPER"
|
||||||
else -> "HYBRID"
|
else -> "HYBRID"
|
||||||
}
|
}
|
||||||
|
|
||||||
override val formUsernameValue: String
|
override val formUsernameValue: String
|
||||||
get() = loginFormUsername.text.toString().trim()
|
get() = binding.loginFormUsername.text.toString().trim()
|
||||||
|
|
||||||
override val formPassValue: String
|
override val formPassValue: String
|
||||||
get() = loginFormPass.text.toString().trim()
|
get() = binding.loginFormPass.text.toString().trim()
|
||||||
|
|
||||||
private lateinit var hostKeys: Array<String>
|
private lateinit var hostKeys: Array<String>
|
||||||
|
|
||||||
@ -49,19 +49,19 @@ class LoginAdvancedFragment : BaseFragment(), LoginAdvancedView {
|
|||||||
private lateinit var hostSymbols: Array<String>
|
private lateinit var hostSymbols: Array<String>
|
||||||
|
|
||||||
override val formHostValue: String
|
override val formHostValue: String
|
||||||
get() = hostValues.getOrNull(hostKeys.indexOf(loginFormHost.text.toString())).orEmpty()
|
get() = hostValues.getOrNull(hostKeys.indexOf(binding.loginFormHost.text.toString())).orEmpty()
|
||||||
|
|
||||||
override val formHostSymbol: String
|
override val formHostSymbol: String
|
||||||
get() = hostSymbols.getOrNull(hostKeys.indexOf(loginFormHost.text.toString())).orEmpty()
|
get() = hostSymbols.getOrNull(hostKeys.indexOf(binding.loginFormHost.text.toString())).orEmpty()
|
||||||
|
|
||||||
override val formPinValue: String
|
override val formPinValue: String
|
||||||
get() = loginFormPin.text.toString().trim()
|
get() = binding.loginFormPin.text.toString().trim()
|
||||||
|
|
||||||
override val formSymbolValue: String
|
override val formSymbolValue: String
|
||||||
get() = loginFormSymbol.text.toString().trim()
|
get() = binding.loginFormSymbol.text.toString().trim()
|
||||||
|
|
||||||
override val formTokenValue: String
|
override val formTokenValue: String
|
||||||
get() = loginFormToken.text.toString().trim()
|
get() = binding.loginFormToken.text.toString().trim()
|
||||||
|
|
||||||
override val nicknameLabel: String
|
override val nicknameLabel: String
|
||||||
get() = getString(R.string.login_nickname_hint)
|
get() = getString(R.string.login_nickname_hint)
|
||||||
@ -69,12 +69,9 @@ class LoginAdvancedFragment : BaseFragment(), LoginAdvancedView {
|
|||||||
override val emailLabel: String
|
override val emailLabel: String
|
||||||
get() = getString(R.string.login_email_hint)
|
get() = getString(R.string.login_email_hint)
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_login_advanced, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentLoginAdvancedBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,191 +80,201 @@ class LoginAdvancedFragment : BaseFragment(), LoginAdvancedView {
|
|||||||
hostValues = resources.getStringArray(R.array.hosts_values)
|
hostValues = resources.getStringArray(R.array.hosts_values)
|
||||||
hostSymbols = resources.getStringArray(R.array.hosts_symbols)
|
hostSymbols = resources.getStringArray(R.array.hosts_symbols)
|
||||||
|
|
||||||
loginFormUsername.doOnTextChanged { _, _, _, _ -> presenter.onUsernameTextChanged() }
|
with(binding) {
|
||||||
loginFormPass.doOnTextChanged { _, _, _, _ -> presenter.onPassTextChanged() }
|
loginFormUsername.doOnTextChanged { _, _, _, _ -> presenter.onUsernameTextChanged() }
|
||||||
loginFormPin.doOnTextChanged { _, _, _, _ -> presenter.onPinTextChanged() }
|
loginFormPass.doOnTextChanged { _, _, _, _ -> presenter.onPassTextChanged() }
|
||||||
loginFormSymbol.doOnTextChanged { _, _, _, _ -> presenter.onSymbolTextChanged() }
|
loginFormPin.doOnTextChanged { _, _, _, _ -> presenter.onPinTextChanged() }
|
||||||
loginFormToken.doOnTextChanged { _, _, _, _ -> presenter.onTokenTextChanged() }
|
loginFormSymbol.doOnTextChanged { _, _, _, _ -> presenter.onSymbolTextChanged() }
|
||||||
loginFormHost.setOnItemClickListener { _, _, _, _ -> presenter.onHostSelected() }
|
loginFormToken.doOnTextChanged { _, _, _, _ -> presenter.onTokenTextChanged() }
|
||||||
loginFormSignIn.setOnClickListener { presenter.onSignInClick() }
|
loginFormHost.setOnItemClickListener { _, _, _, _ -> presenter.onHostSelected() }
|
||||||
|
loginFormSignIn.setOnClickListener { presenter.onSignInClick() }
|
||||||
|
|
||||||
loginTypeSwitch.setOnCheckedChangeListener { _, checkedId ->
|
loginTypeSwitch.setOnCheckedChangeListener { _, checkedId ->
|
||||||
presenter.onLoginModeSelected(when (checkedId) {
|
presenter.onLoginModeSelected(when (checkedId) {
|
||||||
R.id.loginTypeApi -> Sdk.Mode.API
|
R.id.loginTypeApi -> Sdk.Mode.API
|
||||||
R.id.loginTypeScrapper -> Sdk.Mode.SCRAPPER
|
R.id.loginTypeScrapper -> Sdk.Mode.SCRAPPER
|
||||||
else -> Sdk.Mode.HYBRID
|
else -> Sdk.Mode.HYBRID
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
loginFormPin.setOnEditorDoneSignIn { loginFormSignIn.callOnClick() }
|
||||||
|
loginFormPass.setOnEditorDoneSignIn { loginFormSignIn.callOnClick() }
|
||||||
|
|
||||||
|
loginFormSymbol.setAdapter(ArrayAdapter(requireContext(), android.R.layout.simple_list_item_1, resources.getStringArray(R.array.symbols_values)))
|
||||||
}
|
}
|
||||||
|
|
||||||
loginFormPin.setOnEditorDoneSignIn { loginFormSignIn.callOnClick() }
|
with(binding.loginFormHost) {
|
||||||
loginFormPass.setOnEditorDoneSignIn { loginFormSignIn.callOnClick() }
|
|
||||||
|
|
||||||
loginFormSymbol.setAdapter(ArrayAdapter(requireContext(), android.R.layout.simple_list_item_1, resources.getStringArray(R.array.symbols_values)))
|
|
||||||
|
|
||||||
with(loginFormHost) {
|
|
||||||
setText(hostKeys.getOrNull(0).orEmpty())
|
setText(hostKeys.getOrNull(0).orEmpty())
|
||||||
setAdapter(LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
|
setAdapter(LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
|
||||||
setOnClickListener { if (loginFormContainer.visibility == GONE) dismissDropDown() }
|
setOnClickListener { if (binding.loginFormContainer.visibility == GONE) dismissDropDown() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showMobileApiWarningMessage() {
|
override fun showMobileApiWarningMessage() {
|
||||||
loginFormAdvancedWarningInfo.text = getString(R.string.login_advanced_warning_mobile_api)
|
binding.loginFormAdvancedWarningInfo.text = getString(R.string.login_advanced_warning_mobile_api)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showScraperWarningMessage() {
|
override fun showScraperWarningMessage() {
|
||||||
loginFormAdvancedWarningInfo.text = getString(R.string.login_advanced_warning_scraper)
|
binding.loginFormAdvancedWarningInfo.text = getString(R.string.login_advanced_warning_scraper)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showHybridWarningMessage() {
|
override fun showHybridWarningMessage() {
|
||||||
loginFormAdvancedWarningInfo.text = getString(R.string.login_advanced_warning_hybrid)
|
binding.loginFormAdvancedWarningInfo.text = getString(R.string.login_advanced_warning_hybrid)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setDefaultCredentials(username: String, pass: String, symbol: String, token: String, pin: String) {
|
override fun setDefaultCredentials(username: String, pass: String, symbol: String, token: String, pin: String) {
|
||||||
loginFormUsername.setText(username)
|
with(binding) {
|
||||||
loginFormPass.setText(pass)
|
loginFormUsername.setText(username)
|
||||||
loginFormToken.setText(token)
|
loginFormPass.setText(pass)
|
||||||
loginFormSymbol.setText(symbol)
|
loginFormToken.setText(token)
|
||||||
loginFormPin.setText(pin)
|
loginFormSymbol.setText(symbol)
|
||||||
|
loginFormPin.setText(pin)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setUsernameLabel(label: String) {
|
override fun setUsernameLabel(label: String) {
|
||||||
loginFormUsernameLayout.hint = label
|
binding.loginFormUsernameLayout.hint = label
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setSymbol(symbol: String) {
|
override fun setSymbol(symbol: String) {
|
||||||
loginFormSymbol.setText(symbol)
|
binding.loginFormSymbol.setText(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorUsernameRequired() {
|
override fun setErrorUsernameRequired() {
|
||||||
with(loginFormUsernameLayout) {
|
with(binding.loginFormUsernameLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_field_required)
|
error = getString(R.string.login_field_required)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorLoginRequired() {
|
override fun setErrorLoginRequired() {
|
||||||
with(loginFormUsernameLayout) {
|
with(binding.loginFormUsernameLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_invalid_login)
|
error = getString(R.string.login_invalid_login)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorEmailRequired() {
|
override fun setErrorEmailRequired() {
|
||||||
with(loginFormUsernameLayout) {
|
with(binding.loginFormUsernameLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_invalid_email)
|
error = getString(R.string.login_invalid_email)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorPassRequired(focus: Boolean) {
|
override fun setErrorPassRequired(focus: Boolean) {
|
||||||
with(loginFormPassLayout) {
|
with(binding.loginFormPassLayout) {
|
||||||
if (focus) requestFocus()
|
if (focus) requestFocus()
|
||||||
error = getString(R.string.login_field_required)
|
error = getString(R.string.login_field_required)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorPassInvalid(focus: Boolean) {
|
override fun setErrorPassInvalid(focus: Boolean) {
|
||||||
with(loginFormPassLayout) {
|
with(binding.loginFormPassLayout) {
|
||||||
if (focus) requestFocus()
|
if (focus) requestFocus()
|
||||||
error = getString(R.string.login_invalid_password)
|
error = getString(R.string.login_invalid_password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorPassIncorrect() {
|
override fun setErrorPassIncorrect() {
|
||||||
with(loginFormPassLayout) {
|
with(binding.loginFormPassLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_incorrect_password)
|
error = getString(R.string.login_incorrect_password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorPinRequired() {
|
override fun setErrorPinRequired() {
|
||||||
with(loginFormPinLayout) {
|
with(binding.loginFormPinLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_field_required)
|
error = getString(R.string.login_field_required)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorPinInvalid(message: String) {
|
override fun setErrorPinInvalid(message: String) {
|
||||||
with(loginFormPinLayout) {
|
with(binding.loginFormPinLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = message
|
error = message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorSymbolRequired() {
|
override fun setErrorSymbolRequired() {
|
||||||
with(loginFormSymbolLayout) {
|
with(binding.loginFormSymbolLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_field_required)
|
error = getString(R.string.login_field_required)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorSymbolInvalid(message: String) {
|
override fun setErrorSymbolInvalid(message: String) {
|
||||||
with(loginFormSymbolLayout) {
|
with(binding.loginFormSymbolLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = message
|
error = message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorTokenRequired() {
|
override fun setErrorTokenRequired() {
|
||||||
with(loginFormTokenLayout) {
|
with(binding.loginFormTokenLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_field_required)
|
error = getString(R.string.login_field_required)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorTokenInvalid(message: String) {
|
override fun setErrorTokenInvalid(message: String) {
|
||||||
with(loginFormTokenLayout) {
|
with(binding.loginFormTokenLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = message
|
error = message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearUsernameError() {
|
override fun clearUsernameError() {
|
||||||
loginFormUsernameLayout.error = null
|
binding.loginFormUsernameLayout.error = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearPassError() {
|
override fun clearPassError() {
|
||||||
loginFormPassLayout.error = null
|
binding.loginFormPassLayout.error = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearPinKeyError() {
|
override fun clearPinKeyError() {
|
||||||
loginFormPinLayout.error = null
|
binding.loginFormPinLayout.error = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearSymbolError() {
|
override fun clearSymbolError() {
|
||||||
loginFormSymbolLayout.error = null
|
binding.loginFormSymbolLayout.error = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearTokenError() {
|
override fun clearTokenError() {
|
||||||
loginFormTokenLayout.error = null
|
binding.loginFormTokenLayout.error = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showOnlyHybridModeInputs() {
|
override fun showOnlyHybridModeInputs() {
|
||||||
loginFormUsernameLayout.visibility = VISIBLE
|
with(binding) {
|
||||||
loginFormPassLayout.visibility = VISIBLE
|
loginFormUsernameLayout.visibility = VISIBLE
|
||||||
loginFormHostLayout.visibility = VISIBLE
|
loginFormPassLayout.visibility = VISIBLE
|
||||||
loginFormPinLayout.visibility = GONE
|
loginFormHostLayout.visibility = VISIBLE
|
||||||
loginFormSymbolLayout.visibility = VISIBLE
|
loginFormPinLayout.visibility = GONE
|
||||||
loginFormTokenLayout.visibility = GONE
|
loginFormSymbolLayout.visibility = VISIBLE
|
||||||
|
loginFormTokenLayout.visibility = GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showOnlyScrapperModeInputs() {
|
override fun showOnlyScrapperModeInputs() {
|
||||||
loginFormUsernameLayout.visibility = VISIBLE
|
with(binding) {
|
||||||
loginFormPassLayout.visibility = VISIBLE
|
loginFormUsernameLayout.visibility = VISIBLE
|
||||||
loginFormHostLayout.visibility = VISIBLE
|
loginFormPassLayout.visibility = VISIBLE
|
||||||
loginFormPinLayout.visibility = GONE
|
loginFormHostLayout.visibility = VISIBLE
|
||||||
loginFormSymbolLayout.visibility = VISIBLE
|
loginFormPinLayout.visibility = GONE
|
||||||
loginFormTokenLayout.visibility = GONE
|
loginFormSymbolLayout.visibility = VISIBLE
|
||||||
|
loginFormTokenLayout.visibility = GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showOnlyMobileApiModeInputs() {
|
override fun showOnlyMobileApiModeInputs() {
|
||||||
loginFormUsernameLayout.visibility = GONE
|
with(binding) {
|
||||||
loginFormPassLayout.visibility = GONE
|
loginFormUsernameLayout.visibility = GONE
|
||||||
loginFormHostLayout.visibility = GONE
|
loginFormPassLayout.visibility = GONE
|
||||||
loginFormPinLayout.visibility = VISIBLE
|
loginFormHostLayout.visibility = GONE
|
||||||
loginFormSymbolLayout.visibility = VISIBLE
|
loginFormPinLayout.visibility = VISIBLE
|
||||||
loginFormTokenLayout.visibility = VISIBLE
|
loginFormSymbolLayout.visibility = VISIBLE
|
||||||
|
loginFormTokenLayout.visibility = VISIBLE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showSoftKeyboard() {
|
override fun showSoftKeyboard() {
|
||||||
@ -279,17 +286,17 @@ class LoginAdvancedFragment : BaseFragment(), LoginAdvancedView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
loginFormProgress.visibility = if (show) VISIBLE else GONE
|
binding.loginFormProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
loginFormContainer.visibility = if (show) VISIBLE else GONE
|
binding.loginFormContainer.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyParentAccountLogged(students: List<Student>) {
|
override fun notifyParentAccountLogged(students: List<Student>) {
|
||||||
(activity as? LoginActivity)?.onFormFragmentAccountLogged(students, Triple(
|
(activity as? LoginActivity)?.onFormFragmentAccountLogged(students, Triple(
|
||||||
loginFormUsername.text.toString(),
|
binding.loginFormUsername.text.toString(),
|
||||||
loginFormPass.text.toString(),
|
binding.loginFormPass.text.toString(),
|
||||||
resources.getStringArray(R.array.hosts_values)[1]
|
resources.getStringArray(R.array.hosts_values)[1]
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -300,7 +307,7 @@ class LoginAdvancedFragment : BaseFragment(), LoginAdvancedView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
|
||||||
presenter.onDetachView()
|
presenter.onDetachView()
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,13 @@ package io.github.wulkanowy.ui.modules.login.form
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
|
import io.github.wulkanowy.databinding.FragmentLoginFormBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
@ -18,10 +17,10 @@ import io.github.wulkanowy.utils.openEmailClient
|
|||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import io.github.wulkanowy.utils.setOnEditorDoneSignIn
|
import io.github.wulkanowy.utils.setOnEditorDoneSignIn
|
||||||
import io.github.wulkanowy.utils.showSoftInput
|
import io.github.wulkanowy.utils.showSoftInput
|
||||||
import kotlinx.android.synthetic.main.fragment_login_form.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LoginFormFragment : BaseFragment(), LoginFormView {
|
class LoginFormFragment : BaseFragment<FragmentLoginFormBinding>(R.layout.fragment_login_form),
|
||||||
|
LoginFormView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: LoginFormPresenter
|
lateinit var presenter: LoginFormPresenter
|
||||||
@ -34,16 +33,16 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val formUsernameValue: String
|
override val formUsernameValue: String
|
||||||
get() = loginFormUsername.text.toString()
|
get() = binding.loginFormUsername.text.toString()
|
||||||
|
|
||||||
override val formPassValue: String
|
override val formPassValue: String
|
||||||
get() = loginFormPass.text.toString()
|
get() = binding.loginFormPass.text.toString()
|
||||||
|
|
||||||
override val formHostValue: String
|
override val formHostValue: String
|
||||||
get() = hostValues.getOrNull(hostKeys.indexOf(loginFormHost.text.toString())).orEmpty()
|
get() = hostValues.getOrNull(hostKeys.indexOf(binding.loginFormHost.text.toString())).orEmpty()
|
||||||
|
|
||||||
override val formHostSymbol: String
|
override val formHostSymbol: String
|
||||||
get() = hostSymbols.getOrNull(hostKeys.indexOf(loginFormHost.text.toString())).orEmpty()
|
get() = hostSymbols.getOrNull(hostKeys.indexOf(binding.loginFormHost.text.toString())).orEmpty()
|
||||||
|
|
||||||
override val nicknameLabel: String
|
override val nicknameLabel: String
|
||||||
get() = getString(R.string.login_nickname_hint)
|
get() = getString(R.string.login_nickname_hint)
|
||||||
@ -57,12 +56,9 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
|||||||
|
|
||||||
private lateinit var hostSymbols: Array<String>
|
private lateinit var hostSymbols: Array<String>
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_login_form, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentLoginFormBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,81 +67,85 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
|||||||
hostValues = resources.getStringArray(R.array.hosts_values)
|
hostValues = resources.getStringArray(R.array.hosts_values)
|
||||||
hostSymbols = resources.getStringArray(R.array.hosts_symbols)
|
hostSymbols = resources.getStringArray(R.array.hosts_symbols)
|
||||||
|
|
||||||
loginFormUsername.doOnTextChanged { _, _, _, _ -> presenter.onUsernameTextChanged() }
|
with(binding) {
|
||||||
loginFormPass.doOnTextChanged { _, _, _, _ -> presenter.onPassTextChanged() }
|
loginFormUsername.doOnTextChanged { _, _, _, _ -> presenter.onUsernameTextChanged() }
|
||||||
loginFormHost.setOnItemClickListener { _, _, _, _ -> presenter.onHostSelected() }
|
loginFormPass.doOnTextChanged { _, _, _, _ -> presenter.onPassTextChanged() }
|
||||||
loginFormSignIn.setOnClickListener { presenter.onSignInClick() }
|
loginFormHost.setOnItemClickListener { _, _, _, _ -> presenter.onHostSelected() }
|
||||||
loginFormAdvancedButton.setOnClickListener { presenter.onAdvancedLoginClick() }
|
loginFormSignIn.setOnClickListener { presenter.onSignInClick() }
|
||||||
loginFormPrivacyLink.setOnClickListener { presenter.onPrivacyLinkClick() }
|
loginFormAdvancedButton.setOnClickListener { presenter.onAdvancedLoginClick() }
|
||||||
loginFormFaq.setOnClickListener { presenter.onFaqClick() }
|
loginFormPrivacyLink.setOnClickListener { presenter.onPrivacyLinkClick() }
|
||||||
loginFormContactEmail.setOnClickListener { presenter.onEmailClick() }
|
loginFormFaq.setOnClickListener { presenter.onFaqClick() }
|
||||||
loginFormRecoverLink.setOnClickListener { presenter.onRecoverClick() }
|
loginFormContactEmail.setOnClickListener { presenter.onEmailClick() }
|
||||||
loginFormPass.setOnEditorDoneSignIn { loginFormSignIn.callOnClick() }
|
loginFormRecoverLink.setOnClickListener { presenter.onRecoverClick() }
|
||||||
|
loginFormPass.setOnEditorDoneSignIn { loginFormSignIn.callOnClick() }
|
||||||
|
}
|
||||||
|
|
||||||
with(loginFormHost) {
|
with(binding.loginFormHost) {
|
||||||
setText(hostKeys.getOrNull(0).orEmpty())
|
setText(hostKeys.getOrNull(0).orEmpty())
|
||||||
setAdapter(LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
|
setAdapter(LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
|
||||||
setOnClickListener { if (loginFormContainer.visibility == GONE) dismissDropDown() }
|
setOnClickListener { if (binding.loginFormContainer.visibility == GONE) dismissDropDown() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setCredentials(username: String, pass: String) {
|
override fun setCredentials(username: String, pass: String) {
|
||||||
loginFormUsername.setText(username)
|
with(binding) {
|
||||||
loginFormPass.setText(pass)
|
loginFormUsername.setText(username)
|
||||||
|
loginFormPass.setText(pass)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setUsernameLabel(label: String) {
|
override fun setUsernameLabel(label: String) {
|
||||||
loginFormUsernameLayout.hint = label
|
binding.loginFormUsernameLayout.hint = label
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorUsernameRequired() {
|
override fun setErrorUsernameRequired() {
|
||||||
with(loginFormUsernameLayout) {
|
with(binding.loginFormUsernameLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_field_required)
|
error = getString(R.string.login_field_required)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorLoginRequired() {
|
override fun setErrorLoginRequired() {
|
||||||
with(loginFormUsernameLayout) {
|
with(binding.loginFormUsernameLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_invalid_login)
|
error = getString(R.string.login_invalid_login)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorEmailRequired() {
|
override fun setErrorEmailRequired() {
|
||||||
with(loginFormUsernameLayout) {
|
with(binding.loginFormUsernameLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_invalid_email)
|
error = getString(R.string.login_invalid_email)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorPassRequired(focus: Boolean) {
|
override fun setErrorPassRequired(focus: Boolean) {
|
||||||
with(loginFormPassLayout) {
|
with(binding.loginFormPassLayout) {
|
||||||
if (focus) requestFocus()
|
if (focus) requestFocus()
|
||||||
error = getString(R.string.login_field_required)
|
error = getString(R.string.login_field_required)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorPassInvalid(focus: Boolean) {
|
override fun setErrorPassInvalid(focus: Boolean) {
|
||||||
with(loginFormPassLayout) {
|
with(binding.loginFormPassLayout) {
|
||||||
if (focus) requestFocus()
|
if (focus) requestFocus()
|
||||||
error = getString(R.string.login_invalid_password)
|
error = getString(R.string.login_invalid_password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorPassIncorrect() {
|
override fun setErrorPassIncorrect() {
|
||||||
with(loginFormPassLayout) {
|
with(binding.loginFormPassLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_incorrect_password)
|
error = getString(R.string.login_incorrect_password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearUsernameError() {
|
override fun clearUsernameError() {
|
||||||
loginFormUsernameLayout.error = null
|
binding.loginFormUsernameLayout.error = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearPassError() {
|
override fun clearPassError() {
|
||||||
loginFormPassLayout.error = null
|
binding.loginFormPassLayout.error = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showSoftKeyboard() {
|
override fun showSoftKeyboard() {
|
||||||
@ -157,16 +157,16 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
loginFormProgress.visibility = if (show) VISIBLE else GONE
|
binding.loginFormProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
loginFormContainer.visibility = if (show) VISIBLE else GONE
|
binding.loginFormContainer.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun showVersion() {
|
override fun showVersion() {
|
||||||
loginFormVersion.text = "v${appInfo.versionName}"
|
binding.loginFormVersion.text = "v${appInfo.versionName}"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyParentAccountLogged(students: List<Student>, loginData: Triple<String, String, String>) {
|
override fun notifyParentAccountLogged(students: List<Student>, loginData: Triple<String, String, String>) {
|
||||||
@ -178,7 +178,7 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showContact(show: Boolean) {
|
override fun showContact(show: Boolean) {
|
||||||
loginFormContact.visibility = if (show) VISIBLE else GONE
|
binding.loginFormContact.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openAdvancedLogin() {
|
override fun openAdvancedLogin() {
|
||||||
@ -190,8 +190,8 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
|
||||||
presenter.onDetachView()
|
presenter.onDetachView()
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openFaqPage() {
|
override fun openFaqPage() {
|
||||||
|
@ -3,25 +3,24 @@ package io.github.wulkanowy.ui.modules.login.recover
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.webkit.JavascriptInterface
|
import android.webkit.JavascriptInterface
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.webkit.WebViewClient
|
import android.webkit.WebViewClient
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.databinding.FragmentLoginRecoverBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
import io.github.wulkanowy.ui.modules.login.form.LoginSymbolAdapter
|
import io.github.wulkanowy.ui.modules.login.form.LoginSymbolAdapter
|
||||||
import io.github.wulkanowy.utils.hideSoftInput
|
import io.github.wulkanowy.utils.hideSoftInput
|
||||||
import io.github.wulkanowy.utils.showSoftInput
|
import io.github.wulkanowy.utils.showSoftInput
|
||||||
import kotlinx.android.synthetic.main.fragment_login_recover.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LoginRecoverFragment : BaseFragment(), LoginRecoverView {
|
class LoginRecoverFragment :
|
||||||
|
BaseFragment<FragmentLoginRecoverBinding>(R.layout.fragment_login_recover), LoginRecoverView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: LoginRecoverPresenter
|
lateinit var presenter: LoginRecoverPresenter
|
||||||
@ -37,13 +36,13 @@ class LoginRecoverFragment : BaseFragment(), LoginRecoverView {
|
|||||||
private lateinit var hostSymbols: Array<String>
|
private lateinit var hostSymbols: Array<String>
|
||||||
|
|
||||||
override val recoverHostValue: String
|
override val recoverHostValue: String
|
||||||
get() = hostValues.getOrNull(hostKeys.indexOf(loginRecoverHost.text.toString())).orEmpty()
|
get() = hostValues.getOrNull(hostKeys.indexOf(binding.loginRecoverHost.text.toString())).orEmpty()
|
||||||
|
|
||||||
override val formHostSymbol: String
|
override val formHostSymbol: String
|
||||||
get() = hostSymbols.getOrNull(hostKeys.indexOf(loginRecoverHost.text.toString())).orEmpty()
|
get() = hostSymbols.getOrNull(hostKeys.indexOf(binding.loginRecoverHost.text.toString())).orEmpty()
|
||||||
|
|
||||||
override val recoverNameValue: String
|
override val recoverNameValue: String
|
||||||
get() = loginRecoverName.text.toString().trim()
|
get() = binding.loginRecoverName.text.toString().trim()
|
||||||
|
|
||||||
override val emailHintString: String
|
override val emailHintString: String
|
||||||
get() = getString(R.string.login_email_hint)
|
get() = getString(R.string.login_email_hint)
|
||||||
@ -54,91 +53,90 @@ class LoginRecoverFragment : BaseFragment(), LoginRecoverView {
|
|||||||
override val invalidEmailString: String
|
override val invalidEmailString: String
|
||||||
get() = getString(R.string.login_invalid_email)
|
get() = getString(R.string.login_invalid_email)
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_login_recover, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentLoginRecoverBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
loginRecoverWebView.setBackgroundColor(Color.TRANSPARENT)
|
|
||||||
hostKeys = resources.getStringArray(R.array.hosts_keys)
|
hostKeys = resources.getStringArray(R.array.hosts_keys)
|
||||||
hostValues = resources.getStringArray(R.array.hosts_values)
|
hostValues = resources.getStringArray(R.array.hosts_values)
|
||||||
hostSymbols = resources.getStringArray(R.array.hosts_symbols)
|
hostSymbols = resources.getStringArray(R.array.hosts_symbols)
|
||||||
|
|
||||||
loginRecoverName.doOnTextChanged { _, _, _, _ -> presenter.onNameTextChanged() }
|
with(binding) {
|
||||||
loginRecoverHost.setOnItemClickListener { _, _, _, _ -> presenter.onHostSelected() }
|
loginRecoverWebView.setBackgroundColor(Color.TRANSPARENT)
|
||||||
loginRecoverButton.setOnClickListener { presenter.onRecoverClick() }
|
loginRecoverName.doOnTextChanged { _, _, _, _ -> presenter.onNameTextChanged() }
|
||||||
loginRecoverErrorRetry.setOnClickListener { presenter.onRecoverClick() }
|
loginRecoverHost.setOnItemClickListener { _, _, _, _ -> presenter.onHostSelected() }
|
||||||
loginRecoverErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
loginRecoverButton.setOnClickListener { presenter.onRecoverClick() }
|
||||||
loginRecoverLogin.setOnClickListener { (activity as LoginActivity).switchView(0) }
|
loginRecoverErrorRetry.setOnClickListener { presenter.onRecoverClick() }
|
||||||
|
loginRecoverErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
loginRecoverLogin.setOnClickListener { (activity as LoginActivity).switchView(0) }
|
||||||
|
}
|
||||||
|
|
||||||
with(loginRecoverHost) {
|
with(binding.loginRecoverHost) {
|
||||||
setText(hostKeys.getOrNull(0).orEmpty())
|
setText(hostKeys.getOrNull(0).orEmpty())
|
||||||
setAdapter(LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
|
setAdapter(LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
|
||||||
setOnClickListener { if (loginRecoverFormContainer.visibility == GONE) dismissDropDown() }
|
setOnClickListener { if (binding.loginRecoverFormContainer.visibility == GONE) dismissDropDown() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setDefaultCredentials(username: String) {
|
override fun setDefaultCredentials(username: String) {
|
||||||
loginRecoverName.setText(username)
|
binding.loginRecoverName.setText(username)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorNameRequired() {
|
override fun setErrorNameRequired() {
|
||||||
with(loginRecoverNameLayout) {
|
with(binding.loginRecoverNameLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_field_required)
|
error = getString(R.string.login_field_required)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setUsernameHint(hint: String) {
|
override fun setUsernameHint(hint: String) {
|
||||||
loginRecoverNameLayout.hint = hint
|
binding.loginRecoverNameLayout.hint = hint
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setUsernameError(message: String) {
|
override fun setUsernameError(message: String) {
|
||||||
with(loginRecoverNameLayout) {
|
with(binding.loginRecoverNameLayout) {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = message
|
error = message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearUsernameError() {
|
override fun clearUsernameError() {
|
||||||
loginRecoverNameLayout.error = null
|
binding.loginRecoverNameLayout.error = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
loginRecoverProgress.visibility = if (show) VISIBLE else GONE
|
binding.loginRecoverProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showRecoverForm(show: Boolean) {
|
override fun showRecoverForm(show: Boolean) {
|
||||||
loginRecoverFormContainer.visibility = if (show) VISIBLE else GONE
|
binding.loginRecoverFormContainer.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showCaptcha(show: Boolean) {
|
override fun showCaptcha(show: Boolean) {
|
||||||
loginRecoverCaptchaContainer.visibility = if (show) VISIBLE else GONE
|
binding.loginRecoverCaptchaContainer.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
loginRecoverError.visibility = if (show) VISIBLE else GONE
|
binding.loginRecoverError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
loginRecoverErrorMessage.text = message
|
binding.loginRecoverErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showSuccessView(show: Boolean) {
|
override fun showSuccessView(show: Boolean) {
|
||||||
loginRecoverSuccess.visibility = if (show) VISIBLE else GONE
|
binding.loginRecoverSuccess.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setSuccessTitle(title: String) {
|
override fun setSuccessTitle(title: String) {
|
||||||
loginRecoverSuccessTitle.text = title
|
binding.loginRecoverSuccessTitle.text = title
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setSuccessMessage(message: String) {
|
override fun setSuccessMessage(message: String) {
|
||||||
loginRecoverSuccessMessage.text = message
|
binding.loginRecoverSuccessMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showSoftKeyboard() {
|
override fun showSoftKeyboard() {
|
||||||
@ -159,7 +157,7 @@ class LoginRecoverFragment : BaseFragment(), LoginRecoverView {
|
|||||||
callback:e =>Android.captchaCallback(e)})</script>
|
callback:e =>Android.captchaCallback(e)})</script>
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
with(loginRecoverWebView) {
|
with(binding.loginRecoverWebView) {
|
||||||
settings.javaScriptEnabled = true
|
settings.javaScriptEnabled = true
|
||||||
webViewClient = object : WebViewClient() {
|
webViewClient = object : WebViewClient() {
|
||||||
private var recoverWebViewSuccess: Boolean = true
|
private var recoverWebViewSuccess: Boolean = true
|
||||||
@ -197,8 +195,9 @@ class LoginRecoverFragment : BaseFragment(), LoginRecoverView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
binding.loginRecoverWebView.destroy()
|
||||||
loginRecoverWebView.destroy()
|
|
||||||
presenter.onDetachView()
|
presenter.onDetachView()
|
||||||
|
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
package io.github.wulkanowy.ui.modules.login.studentselect
|
package io.github.wulkanowy.ui.modules.login.studentselect
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
|
import io.github.wulkanowy.databinding.FragmentLoginStudentSelectBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.openEmailClient
|
import io.github.wulkanowy.utils.openEmailClient
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import kotlinx.android.synthetic.main.fragment_login_student_select.*
|
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
|
class LoginStudentSelectFragment :
|
||||||
|
BaseFragment<FragmentLoginStudentSelectBinding>(R.layout.fragment_login_student_select),
|
||||||
|
LoginStudentSelectView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: LoginStudentSelectPresenter
|
lateinit var presenter: LoginStudentSelectPresenter
|
||||||
@ -35,24 +35,24 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
|
|||||||
fun newInstance() = LoginStudentSelectFragment()
|
fun newInstance() = LoginStudentSelectFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_login_student_select, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentLoginStudentSelectBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this, savedInstanceState?.getSerializable(SAVED_STUDENTS))
|
presenter.onAttachView(this, savedInstanceState?.getSerializable(SAVED_STUDENTS))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
loginAdapter.onClickListener = presenter::onItemSelected
|
loginAdapter.onClickListener = presenter::onItemSelected
|
||||||
loginStudentSelectSignIn.setOnClickListener { presenter.onSignIn() }
|
|
||||||
loginStudentSelectContactDiscord.setOnClickListener { presenter.onDiscordClick() }
|
|
||||||
loginStudentSelectContactEmail.setOnClickListener { presenter.onEmailClick() }
|
|
||||||
|
|
||||||
loginStudentSelectRecycler.apply {
|
with(binding) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
loginStudentSelectSignIn.setOnClickListener { presenter.onSignIn() }
|
||||||
adapter = loginAdapter
|
loginStudentSelectContactDiscord.setOnClickListener { presenter.onDiscordClick() }
|
||||||
|
loginStudentSelectContactEmail.setOnClickListener { presenter.onEmailClick() }
|
||||||
|
|
||||||
|
with(loginStudentSelectRecycler) {
|
||||||
|
layoutManager = LinearLayoutManager(context)
|
||||||
|
adapter = loginAdapter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,15 +68,15 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
loginStudentSelectProgress.visibility = if (show) VISIBLE else GONE
|
binding.loginStudentSelectProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
loginStudentSelectContent.visibility = if (show) VISIBLE else GONE
|
binding.loginStudentSelectContent.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSignIn(enable: Boolean) {
|
override fun enableSignIn(enable: Boolean) {
|
||||||
loginStudentSelectSignIn.isEnabled = enable
|
binding.loginStudentSelectSignIn.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onParentInitStudentSelectFragment(students: List<Student>) {
|
fun onParentInitStudentSelectFragment(students: List<Student>) {
|
||||||
@ -89,7 +89,7 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showContact(show: Boolean) {
|
override fun showContact(show: Boolean) {
|
||||||
loginStudentSelectContact.visibility = if (show) VISIBLE else GONE
|
binding.loginStudentSelectContact.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package io.github.wulkanowy.ui.modules.login.symbol
|
package io.github.wulkanowy.ui.modules.login.symbol
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.view.inputmethod.EditorInfo.IME_ACTION_DONE
|
import android.view.inputmethod.EditorInfo.IME_ACTION_DONE
|
||||||
import android.view.inputmethod.EditorInfo.IME_NULL
|
import android.view.inputmethod.EditorInfo.IME_NULL
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
|
import io.github.wulkanowy.databinding.FragmentLoginSymbolBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
@ -19,10 +18,10 @@ import io.github.wulkanowy.utils.hideSoftInput
|
|||||||
import io.github.wulkanowy.utils.openEmailClient
|
import io.github.wulkanowy.utils.openEmailClient
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import io.github.wulkanowy.utils.showSoftInput
|
import io.github.wulkanowy.utils.showSoftInput
|
||||||
import kotlinx.android.synthetic.main.fragment_login_symbol.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
class LoginSymbolFragment :
|
||||||
|
BaseFragment<FragmentLoginSymbolBinding>(R.layout.fragment_login_symbol), LoginSymbolView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: LoginSymbolPresenter
|
lateinit var presenter: LoginSymbolPresenter
|
||||||
@ -37,29 +36,28 @@ class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val symbolNameError: CharSequence?
|
override val symbolNameError: CharSequence?
|
||||||
get() = loginSymbolNameLayout.error
|
get() = binding.loginSymbolNameLayout.error
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_login_symbol, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentLoginSymbolBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this, savedInstanceState?.getSerializable(SAVED_LOGIN_DATA))
|
presenter.onAttachView(this, savedInstanceState?.getSerializable(SAVED_LOGIN_DATA))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
loginSymbolSignIn.setOnClickListener { presenter.attemptLogin(loginSymbolName.text.toString()) }
|
with(binding) {
|
||||||
loginSymbolFaq.setOnClickListener { presenter.onFaqClick() }
|
loginSymbolSignIn.setOnClickListener { presenter.attemptLogin(loginSymbolName.text.toString()) }
|
||||||
loginSymbolContactEmail.setOnClickListener { presenter.onEmailClick() }
|
loginSymbolFaq.setOnClickListener { presenter.onFaqClick() }
|
||||||
|
loginSymbolContactEmail.setOnClickListener { presenter.onEmailClick() }
|
||||||
|
|
||||||
loginSymbolName.doOnTextChanged { _, _, _, _ -> presenter.onSymbolTextChanged() }
|
loginSymbolName.doOnTextChanged { _, _, _, _ -> presenter.onSymbolTextChanged() }
|
||||||
|
|
||||||
loginSymbolName.apply {
|
loginSymbolName.apply {
|
||||||
setOnEditorActionListener { _, id, _ ->
|
setOnEditorActionListener { _, id, _ ->
|
||||||
if (id == IME_ACTION_DONE || id == IME_NULL) loginSymbolSignIn.callOnClick() else false
|
if (id == IME_ACTION_DONE || id == IME_NULL) loginSymbolSignIn.callOnClick() else false
|
||||||
|
}
|
||||||
|
setAdapter(ArrayAdapter(context, android.R.layout.simple_list_item_1, resources.getStringArray(R.array.symbols_values)))
|
||||||
}
|
}
|
||||||
setAdapter(ArrayAdapter(context, android.R.layout.simple_list_item_1, resources.getStringArray(R.array.symbols_values)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,25 +66,25 @@ class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorSymbolIncorrect() {
|
override fun setErrorSymbolIncorrect() {
|
||||||
loginSymbolNameLayout.apply {
|
binding.loginSymbolNameLayout.apply {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_incorrect_symbol)
|
error = getString(R.string.login_incorrect_symbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorSymbolRequire() {
|
override fun setErrorSymbolRequire() {
|
||||||
loginSymbolNameLayout.apply {
|
binding.loginSymbolNameLayout.apply {
|
||||||
requestFocus()
|
requestFocus()
|
||||||
error = getString(R.string.login_field_required)
|
error = getString(R.string.login_field_required)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearSymbolError() {
|
override fun clearSymbolError() {
|
||||||
loginSymbolNameLayout.error = null
|
binding.loginSymbolNameLayout.error = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearAndFocusSymbol() {
|
override fun clearAndFocusSymbol() {
|
||||||
loginSymbolNameLayout.apply {
|
binding.loginSymbolNameLayout.apply {
|
||||||
editText?.text = null
|
editText?.text = null
|
||||||
requestFocus()
|
requestFocus()
|
||||||
}
|
}
|
||||||
@ -101,11 +99,11 @@ class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
loginSymbolProgress.visibility = if (show) VISIBLE else GONE
|
binding.loginSymbolProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
loginSymbolContainer.visibility = if (show) VISIBLE else GONE
|
binding.loginSymbolContainer.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyParentAccountLogged(students: List<Student>) {
|
override fun notifyParentAccountLogged(students: List<Student>) {
|
||||||
@ -118,12 +116,12 @@ class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showContact(show: Boolean) {
|
override fun showContact(show: Boolean) {
|
||||||
loginSymbolContact.visibility = if (show) VISIBLE else GONE
|
binding.loginSymbolContact.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
|
||||||
presenter.onDetachView()
|
presenter.onDetachView()
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openFaqPage() {
|
override fun openFaqPage() {
|
||||||
@ -139,7 +137,7 @@ class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
|||||||
"${appInfo.systemManufacturer} ${appInfo.systemModel}",
|
"${appInfo.systemManufacturer} ${appInfo.systemModel}",
|
||||||
appInfo.systemVersion.toString(),
|
appInfo.systemVersion.toString(),
|
||||||
appInfo.versionName,
|
appInfo.versionName,
|
||||||
"$host/${loginSymbolName.text}",
|
"$host/${binding.loginSymbolName.text}",
|
||||||
lastError
|
lastError
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
package io.github.wulkanowy.ui.modules.luckynumber
|
package io.github.wulkanowy.ui.modules.luckynumber
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||||
|
import io.github.wulkanowy.databinding.FragmentLuckyNumberBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import kotlinx.android.synthetic.main.fragment_lucky_number.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LuckyNumberFragment : BaseFragment(), LuckyNumberView, MainView.TitledView {
|
class LuckyNumberFragment :
|
||||||
|
BaseFragment<FragmentLuckyNumberBinding>(R.layout.fragment_lucky_number), LuckyNumberView,
|
||||||
|
MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: LuckyNumberPresenter
|
lateinit var presenter: LuckyNumberPresenter
|
||||||
@ -25,58 +25,57 @@ class LuckyNumberFragment : BaseFragment(), LuckyNumberView, MainView.TitledView
|
|||||||
override val titleStringId: Int
|
override val titleStringId: Int
|
||||||
get() = R.string.lucky_number_title
|
get() = R.string.lucky_number_title
|
||||||
|
|
||||||
override val isViewEmpty get() = luckyNumberText.text.isBlank()
|
override val isViewEmpty get() = binding.luckyNumberText.text.isBlank()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_lucky_number, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentLuckyNumberBinding.bind(view)
|
||||||
|
messageContainer = binding.luckyNumberSwipe
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = luckyNumberSwipe
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
luckyNumberSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
with(binding) {
|
||||||
luckyNumberErrorRetry.setOnClickListener { presenter.onRetry() }
|
luckyNumberSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||||
luckyNumberErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
luckyNumberErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
luckyNumberErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(data: LuckyNumber) {
|
override fun updateData(data: LuckyNumber) {
|
||||||
luckyNumberText.text = data.luckyNumber.toString()
|
binding.luckyNumberText.text = data.luckyNumber.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
luckyNumberSwipe.isRefreshing = false
|
binding.luckyNumberSwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
luckyNumberEmpty.visibility = if (show) VISIBLE else GONE
|
binding.luckyNumberEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
luckyNumberError.visibility = if (show) VISIBLE else GONE
|
binding.luckyNumberError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
luckyNumberErrorMessage.text = message
|
binding.luckyNumberErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
luckyNumberProgress.visibility = if (show) VISIBLE else GONE
|
binding.luckyNumberProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
luckyNumberSwipe.isEnabled = enable
|
binding.luckyNumberSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
luckyNumberContent.visibility = if (show) VISIBLE else GONE
|
binding.luckyNumberContent.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
|
||||||
presenter.onDetachView()
|
presenter.onDetachView()
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,14 @@ import androidx.appcompat.app.AlertDialog
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
|
import io.github.wulkanowy.databinding.ActivityWidgetConfigureBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseActivity
|
import io.github.wulkanowy.ui.base.BaseActivity
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
|
||||||
import io.github.wulkanowy.ui.base.WidgetConfigureAdapter
|
import io.github.wulkanowy.ui.base.WidgetConfigureAdapter
|
||||||
import kotlinx.android.synthetic.main.activity_widget_configure.*
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LuckyNumberWidgetConfigureActivity : BaseActivity<LuckyNumberWidgetConfigurePresenter>(),
|
class LuckyNumberWidgetConfigureActivity :
|
||||||
|
BaseActivity<LuckyNumberWidgetConfigurePresenter, ActivityWidgetConfigureBinding>(),
|
||||||
LuckyNumberWidgetConfigureView {
|
LuckyNumberWidgetConfigureView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -30,7 +31,7 @@ class LuckyNumberWidgetConfigureActivity : BaseActivity<LuckyNumberWidgetConfigu
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setResult(RESULT_CANCELED)
|
setResult(RESULT_CANCELED)
|
||||||
setContentView(R.layout.activity_widget_configure)
|
setContentView(ActivityWidgetConfigureBinding.inflate(layoutInflater).apply { binding = this }.root)
|
||||||
|
|
||||||
intent.extras.let {
|
intent.extras.let {
|
||||||
presenter.onAttachView(this, it?.getInt(EXTRA_APPWIDGET_ID))
|
presenter.onAttachView(this, it?.getInt(EXTRA_APPWIDGET_ID))
|
||||||
@ -38,7 +39,7 @@ class LuckyNumberWidgetConfigureActivity : BaseActivity<LuckyNumberWidgetConfigu
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(widgetConfigureRecycler) {
|
with(binding.widgetConfigureRecycler) {
|
||||||
adapter = configureAdapter
|
adapter = configureAdapter
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import com.ncapdevi.fragnav.FragNavController
|
|||||||
import com.ncapdevi.fragnav.FragNavController.Companion.HIDE
|
import com.ncapdevi.fragnav.FragNavController.Companion.HIDE
|
||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.databinding.ActivityMainBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseActivity
|
import io.github.wulkanowy.ui.base.BaseActivity
|
||||||
import io.github.wulkanowy.ui.modules.account.AccountDialog
|
import io.github.wulkanowy.ui.modules.account.AccountDialog
|
||||||
import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment
|
import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment
|
||||||
@ -34,11 +35,10 @@ import io.github.wulkanowy.utils.dpToPx
|
|||||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||||
import io.github.wulkanowy.utils.safelyPopFragments
|
import io.github.wulkanowy.utils.safelyPopFragments
|
||||||
import io.github.wulkanowy.utils.setOnViewChangeListener
|
import io.github.wulkanowy.utils.setOnViewChangeListener
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MainActivity : BaseActivity<MainPresenter>(), MainView {
|
class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
override lateinit var presenter: MainPresenter
|
override lateinit var presenter: MainPresenter
|
||||||
@ -82,9 +82,9 @@ class MainActivity : BaseActivity<MainPresenter>(), MainView {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(ActivityMainBinding.inflate(layoutInflater).apply { binding = this }.root)
|
||||||
setSupportActionBar(mainToolbar)
|
setSupportActionBar(binding.mainToolbar)
|
||||||
messageContainer = mainFragmentContainer
|
messageContainer = binding.mainFragmentContainer
|
||||||
|
|
||||||
presenter.onAttachView(this, intent.getSerializableExtra(EXTRA_START_MENU) as? MainView.Section)
|
presenter.onAttachView(this, intent.getSerializableExtra(EXTRA_START_MENU) as? MainView.Section)
|
||||||
|
|
||||||
@ -100,12 +100,12 @@ class MainActivity : BaseActivity<MainPresenter>(), MainView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(mainToolbar) {
|
with(binding.mainToolbar) {
|
||||||
if (SDK_INT >= LOLLIPOP) stateListAnimator = null
|
if (SDK_INT >= LOLLIPOP) stateListAnimator = null
|
||||||
setBackgroundColor(overlayProvider.get().compositeOverlayWithThemeSurfaceColorIfNeeded(dpToPx(4f)))
|
setBackgroundColor(overlayProvider.get().compositeOverlayWithThemeSurfaceColorIfNeeded(dpToPx(4f)))
|
||||||
}
|
}
|
||||||
|
|
||||||
with(mainBottomNav) {
|
with(binding.mainBottomNav) {
|
||||||
addItems(listOf(
|
addItems(listOf(
|
||||||
AHBottomNavigationItem(R.string.grade_title, R.drawable.ic_main_grade, 0),
|
AHBottomNavigationItem(R.string.grade_title, R.drawable.ic_main_grade, 0),
|
||||||
AHBottomNavigationItem(R.string.attendance_title, R.drawable.ic_main_attendance, 0),
|
AHBottomNavigationItem(R.string.attendance_title, R.drawable.ic_main_attendance, 0),
|
||||||
@ -166,7 +166,7 @@ class MainActivity : BaseActivity<MainPresenter>(), MainView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showActionBarElevation(show: Boolean) {
|
override fun showActionBarElevation(show: Boolean) {
|
||||||
ViewCompat.setElevation(mainToolbar, if (show) dpToPx(4f) else 0f)
|
ViewCompat.setElevation(binding.mainToolbar, if (show) dpToPx(4f) else 0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyMenuViewReselected() {
|
override fun notifyMenuViewReselected() {
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package io.github.wulkanowy.ui.modules.message
|
package io.github.wulkanowy.ui.modules.message
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.INVISIBLE
|
import android.view.View.INVISIBLE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Message
|
import io.github.wulkanowy.data.db.entities.Message
|
||||||
import io.github.wulkanowy.data.repositories.message.MessageFolder.RECEIVED
|
import io.github.wulkanowy.data.repositories.message.MessageFolder.RECEIVED
|
||||||
import io.github.wulkanowy.data.repositories.message.MessageFolder.SENT
|
import io.github.wulkanowy.data.repositories.message.MessageFolder.SENT
|
||||||
import io.github.wulkanowy.data.repositories.message.MessageFolder.TRASHED
|
import io.github.wulkanowy.data.repositories.message.MessageFolder.TRASHED
|
||||||
|
import io.github.wulkanowy.databinding.FragmentMessageBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
@ -18,10 +17,10 @@ import io.github.wulkanowy.ui.modules.message.send.SendMessageActivity
|
|||||||
import io.github.wulkanowy.ui.modules.message.tab.MessageTabFragment
|
import io.github.wulkanowy.ui.modules.message.tab.MessageTabFragment
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import io.github.wulkanowy.utils.setOnSelectPageListener
|
import io.github.wulkanowy.utils.setOnSelectPageListener
|
||||||
import kotlinx.android.synthetic.main.fragment_message.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MessageFragment : BaseFragment(), MessageView, MainView.TitledView {
|
class MessageFragment : BaseFragment<FragmentMessageBinding>(R.layout.fragment_message),
|
||||||
|
MessageView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: MessagePresenter
|
lateinit var presenter: MessagePresenter
|
||||||
@ -35,20 +34,17 @@ class MessageFragment : BaseFragment(), MessageView, MainView.TitledView {
|
|||||||
|
|
||||||
override val titleStringId get() = R.string.message_title
|
override val titleStringId get() = R.string.message_title
|
||||||
|
|
||||||
override val currentPageIndex get() = messageViewPager.currentItem
|
override val currentPageIndex get() = binding.messageViewPager.currentItem
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_message, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentMessageBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(pagerAdapter) {
|
with(pagerAdapter) {
|
||||||
containerId = messageViewPager.id
|
containerId = binding.messageViewPager.id
|
||||||
addFragmentsWithTitle(mapOf(
|
addFragmentsWithTitle(mapOf(
|
||||||
MessageTabFragment.newInstance(RECEIVED) to getString(R.string.message_inbox),
|
MessageTabFragment.newInstance(RECEIVED) to getString(R.string.message_inbox),
|
||||||
MessageTabFragment.newInstance(SENT) to getString(R.string.message_sent),
|
MessageTabFragment.newInstance(SENT) to getString(R.string.message_sent),
|
||||||
@ -56,27 +52,29 @@ class MessageFragment : BaseFragment(), MessageView, MainView.TitledView {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
with(messageViewPager) {
|
with(binding.messageViewPager) {
|
||||||
adapter = pagerAdapter
|
adapter = pagerAdapter
|
||||||
offscreenPageLimit = 2
|
offscreenPageLimit = 2
|
||||||
setOnSelectPageListener(presenter::onPageSelected)
|
setOnSelectPageListener(presenter::onPageSelected)
|
||||||
}
|
}
|
||||||
|
|
||||||
with(messageTabLayout) {
|
with(binding.messageTabLayout) {
|
||||||
setupWithViewPager(messageViewPager)
|
setupWithViewPager(binding.messageViewPager)
|
||||||
setElevationCompat(context.dpToPx(4f))
|
setElevationCompat(context.dpToPx(4f))
|
||||||
}
|
}
|
||||||
|
|
||||||
openSendMessageButton.setOnClickListener { presenter.onSendMessageButtonClicked() }
|
binding.openSendMessageButton.setOnClickListener { presenter.onSendMessageButtonClicked() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
messageViewPager.visibility = if (show) VISIBLE else INVISIBLE
|
with(binding) {
|
||||||
messageTabLayout.visibility = if (show) VISIBLE else INVISIBLE
|
messageViewPager.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
|
messageTabLayout.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
messageProgress.visibility = if (show) VISIBLE else INVISIBLE
|
binding.messageProgress.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onDeleteMessage(message: Message) {
|
fun onDeleteMessage(message: Message) {
|
||||||
|
@ -10,10 +10,11 @@ import io.github.wulkanowy.data.db.entities.Message
|
|||||||
import io.github.wulkanowy.data.db.entities.MessageAttachment
|
import io.github.wulkanowy.data.db.entities.MessageAttachment
|
||||||
import io.github.wulkanowy.data.db.entities.MessageWithAttachment
|
import io.github.wulkanowy.data.db.entities.MessageWithAttachment
|
||||||
import io.github.wulkanowy.data.repositories.message.MessageFolder
|
import io.github.wulkanowy.data.repositories.message.MessageFolder
|
||||||
|
import io.github.wulkanowy.databinding.ItemMessageAttachmentBinding
|
||||||
|
import io.github.wulkanowy.databinding.ItemMessageDividerBinding
|
||||||
|
import io.github.wulkanowy.databinding.ItemMessagePreviewBinding
|
||||||
import io.github.wulkanowy.utils.openInternetBrowser
|
import io.github.wulkanowy.utils.openInternetBrowser
|
||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
import kotlinx.android.synthetic.main.item_message_attachment.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_message_preview.view.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MessagePreviewAdapter @Inject constructor() :
|
class MessagePreviewAdapter @Inject constructor() :
|
||||||
@ -45,44 +46,47 @@ class MessagePreviewAdapter @Inject constructor() :
|
|||||||
val inflater = LayoutInflater.from(parent.context)
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
|
|
||||||
return when (viewType) {
|
return when (viewType) {
|
||||||
ViewType.MESSAGE.id -> MessageViewHolder(inflater.inflate(R.layout.item_message_preview, parent, false))
|
ViewType.MESSAGE.id -> MessageViewHolder(ItemMessagePreviewBinding.inflate(inflater, parent, false))
|
||||||
ViewType.DIVIDER.id -> DividerViewHolder(inflater.inflate(R.layout.item_message_divider, parent, false))
|
ViewType.DIVIDER.id -> DividerViewHolder(ItemMessageDividerBinding.inflate(inflater, parent, false))
|
||||||
ViewType.ATTACHMENT.id -> AttachmentViewHolder(inflater.inflate(R.layout.item_message_attachment, parent, false))
|
ViewType.ATTACHMENT.id -> AttachmentViewHolder(ItemMessageAttachmentBinding.inflate(inflater, parent, false))
|
||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||||
when (holder) {
|
when (holder) {
|
||||||
is MessageViewHolder -> bindMessage(holder.view, requireNotNull(messageWithAttachment).message)
|
is MessageViewHolder -> bindMessage(holder, requireNotNull(messageWithAttachment).message)
|
||||||
is AttachmentViewHolder -> bindAttachment(holder.view, requireNotNull(messageWithAttachment).attachments[position - 2])
|
is AttachmentViewHolder -> bindAttachment(holder, requireNotNull(messageWithAttachment).attachments[position - 2])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
private fun bindMessage(view: View, message: Message) {
|
private fun bindMessage(holder: MessageViewHolder, message: Message) {
|
||||||
with(view) {
|
with(holder.binding) {
|
||||||
messagePreviewSubject.text = if (message.subject.isNotBlank()) message.subject else context.getString(R.string.message_no_subject)
|
messagePreviewSubject.text = if (message.subject.isNotBlank()) message.subject else root.context.getString(R.string.message_no_subject)
|
||||||
messagePreviewDate.text = context.getString(R.string.message_date, message.date.toFormattedString("yyyy-MM-dd HH:mm:ss"))
|
messagePreviewDate.text = root.context.getString(R.string.message_date, message.date.toFormattedString("yyyy-MM-dd HH:mm:ss"))
|
||||||
messagePreviewContent.text = message.content
|
messagePreviewContent.text = message.content
|
||||||
messagePreviewAuthor.text = if (message.folderId == MessageFolder.SENT.id) "${context.getString(R.string.message_to)} ${message.recipient}"
|
messagePreviewAuthor.text = if (message.folderId == MessageFolder.SENT.id) "${root.context.getString(R.string.message_to)} ${message.recipient}"
|
||||||
else "${context.getString(R.string.message_from)} ${message.sender}"
|
else "${root.context.getString(R.string.message_from)} ${message.sender}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindAttachment(view: View, attachment: MessageAttachment) {
|
private fun bindAttachment(holder: AttachmentViewHolder, attachment: MessageAttachment) {
|
||||||
with(view) {
|
with(holder.binding) {
|
||||||
messagePreviewAttachment.visibility = View.VISIBLE
|
messagePreviewAttachment.visibility = View.VISIBLE
|
||||||
messagePreviewAttachment.text = attachment.filename
|
messagePreviewAttachment.text = attachment.filename
|
||||||
setOnClickListener {
|
root.setOnClickListener {
|
||||||
context.openInternetBrowser(attachment.url) { }
|
root.context.openInternetBrowser(attachment.url) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MessageViewHolder(val view: View) : RecyclerView.ViewHolder(view)
|
class MessageViewHolder(val binding: ItemMessagePreviewBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root)
|
||||||
|
|
||||||
class DividerViewHolder(val view: View) : RecyclerView.ViewHolder(view)
|
class DividerViewHolder(val binding: ItemMessageDividerBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root)
|
||||||
|
|
||||||
class AttachmentViewHolder(val view: View) : RecyclerView.ViewHolder(view)
|
class AttachmentViewHolder(val binding: ItemMessageAttachmentBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root)
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
package io.github.wulkanowy.ui.modules.message.preview
|
package io.github.wulkanowy.ui.modules.message.preview
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
import android.view.MenuInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Message
|
import io.github.wulkanowy.data.db.entities.Message
|
||||||
import io.github.wulkanowy.data.db.entities.MessageWithAttachment
|
import io.github.wulkanowy.data.db.entities.MessageWithAttachment
|
||||||
|
import io.github.wulkanowy.databinding.FragmentMessagePreviewBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import io.github.wulkanowy.ui.modules.message.MessageFragment
|
import io.github.wulkanowy.ui.modules.message.MessageFragment
|
||||||
import io.github.wulkanowy.ui.modules.message.send.SendMessageActivity
|
import io.github.wulkanowy.ui.modules.message.send.SendMessageActivity
|
||||||
import kotlinx.android.synthetic.main.fragment_message_preview.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MessagePreviewFragment : BaseFragment(), MessagePreviewView, MainView.TitledView {
|
class MessagePreviewFragment :
|
||||||
|
BaseFragment<FragmentMessagePreviewBinding>(R.layout.fragment_message_preview),
|
||||||
|
MessagePreviewView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: MessagePreviewPresenter
|
lateinit var presenter: MessagePreviewPresenter
|
||||||
@ -56,20 +56,17 @@ class MessagePreviewFragment : BaseFragment(), MessagePreviewView, MainView.Titl
|
|||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_message_preview, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentMessagePreviewBinding.bind(view)
|
||||||
|
messageContainer = binding.messagePreviewContainer
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = messagePreviewContainer
|
|
||||||
presenter.onAttachView(this, (savedInstanceState ?: arguments)?.getSerializable(MESSAGE_ID_KEY) as? Message)
|
presenter.onAttachView(this, (savedInstanceState ?: arguments)?.getSerializable(MESSAGE_ID_KEY) as? Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
messagePreviewErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
binding.messagePreviewErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
|
||||||
with(messagePreviewRecycler) {
|
with(binding.messagePreviewRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = previewAdapter
|
adapter = previewAdapter
|
||||||
}
|
}
|
||||||
@ -100,11 +97,11 @@ class MessagePreviewFragment : BaseFragment(), MessagePreviewView, MainView.Titl
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
messagePreviewProgress.visibility = if (show) VISIBLE else GONE
|
binding.messagePreviewProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
messagePreviewRecycler.visibility = if (show) VISIBLE else GONE
|
binding.messagePreviewRecycler.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showOptions(show: Boolean) {
|
override fun showOptions(show: Boolean) {
|
||||||
@ -122,15 +119,15 @@ class MessagePreviewFragment : BaseFragment(), MessagePreviewView, MainView.Titl
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
messagePreviewError.visibility = if (show) VISIBLE else GONE
|
binding.messagePreviewError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
messagePreviewErrorMessage.text = message
|
binding.messagePreviewErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorRetryCallback(callback: () -> Unit) {
|
override fun setErrorRetryCallback(callback: () -> Unit) {
|
||||||
messagePreviewErrorRetry.setOnClickListener { callback() }
|
binding.messagePreviewErrorRetry.setOnClickListener { callback() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openMessageReply(message: Message?) {
|
override fun openMessageReply(message: Message?) {
|
||||||
|
@ -14,14 +14,14 @@ import android.widget.Toast.LENGTH_LONG
|
|||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Message
|
import io.github.wulkanowy.data.db.entities.Message
|
||||||
import io.github.wulkanowy.data.db.entities.ReportingUnit
|
import io.github.wulkanowy.data.db.entities.ReportingUnit
|
||||||
|
import io.github.wulkanowy.databinding.ActivitySendMessageBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseActivity
|
import io.github.wulkanowy.ui.base.BaseActivity
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import io.github.wulkanowy.utils.hideSoftInput
|
import io.github.wulkanowy.utils.hideSoftInput
|
||||||
import io.github.wulkanowy.utils.showSoftInput
|
import io.github.wulkanowy.utils.showSoftInput
|
||||||
import kotlinx.android.synthetic.main.activity_send_message.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SendMessageActivity : BaseActivity<SendMessagePresenter>(), SendMessageView {
|
class SendMessageActivity : BaseActivity<SendMessagePresenter, ActivitySendMessageBinding>(), SendMessageView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
override lateinit var presenter: SendMessagePresenter
|
override lateinit var presenter: SendMessagePresenter
|
||||||
@ -41,17 +41,17 @@ class SendMessageActivity : BaseActivity<SendMessagePresenter>(), SendMessageVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val isDropdownListVisible: Boolean
|
override val isDropdownListVisible: Boolean
|
||||||
get() = sendMessageTo.isDropdownListVisible
|
get() = binding.sendMessageTo.isDropdownListVisible
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override val formRecipientsData: List<RecipientChipItem>
|
override val formRecipientsData: List<RecipientChipItem>
|
||||||
get() = sendMessageTo.addedChipItems as List<RecipientChipItem>
|
get() = binding.sendMessageTo.addedChipItems as List<RecipientChipItem>
|
||||||
|
|
||||||
override val formSubjectValue: String
|
override val formSubjectValue: String
|
||||||
get() = sendMessageSubject.text.toString()
|
get() = binding.sendMessageSubject.text.toString()
|
||||||
|
|
||||||
override val formContentValue: String
|
override val formContentValue: String
|
||||||
get() = sendMessageMessageContent.text.toString()
|
get() = binding.sendMessageMessageContent.text.toString()
|
||||||
|
|
||||||
override val messageRequiredRecipients: String
|
override val messageRequiredRecipients: String
|
||||||
get() = getString(R.string.message_required_recipients)
|
get() = getString(R.string.message_required_recipients)
|
||||||
@ -64,18 +64,20 @@ class SendMessageActivity : BaseActivity<SendMessagePresenter>(), SendMessageVie
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_send_message)
|
setContentView(ActivitySendMessageBinding.inflate(layoutInflater).apply { binding = this }.root)
|
||||||
setSupportActionBar(sendMessageToolbar)
|
setSupportActionBar(binding.sendMessageToolbar)
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
messageContainer = sendMessageContainer
|
messageContainer = binding.sendMessageContainer
|
||||||
|
|
||||||
presenter.onAttachView(this, intent.getSerializableExtra(EXTRA_MESSAGE) as? Message, intent.getSerializableExtra(EXTRA_REPLY) as? Boolean)
|
presenter.onAttachView(this, intent.getSerializableExtra(EXTRA_MESSAGE) as? Message, intent.getSerializableExtra(EXTRA_REPLY) as? Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
setUpExtendedHitArea()
|
setUpExtendedHitArea()
|
||||||
sendMessageScroll.setOnTouchListener { _, _ -> presenter.onTouchScroll() }
|
with(binding) {
|
||||||
sendMessageTo.onTextChangeListener = presenter::onRecipientsTextChange
|
sendMessageScroll.setOnTouchListener { _, _ -> presenter.onTouchScroll() }
|
||||||
|
sendMessageTo.onTextChangeListener = presenter::onRecipientsTextChange
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
@ -93,27 +95,27 @@ class SendMessageActivity : BaseActivity<SendMessagePresenter>(), SendMessageVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun setReportingUnit(unit: ReportingUnit) {
|
override fun setReportingUnit(unit: ReportingUnit) {
|
||||||
sendMessageFrom.text = unit.senderName
|
binding.sendMessageFrom.text = unit.senderName
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setRecipients(recipients: List<RecipientChipItem>) {
|
override fun setRecipients(recipients: List<RecipientChipItem>) {
|
||||||
sendMessageTo.filterableChipItems = recipients
|
binding.sendMessageTo.filterableChipItems = recipients
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setSelectedRecipients(recipients: List<RecipientChipItem>) {
|
override fun setSelectedRecipients(recipients: List<RecipientChipItem>) {
|
||||||
sendMessageTo.addChips(recipients)
|
binding.sendMessageTo.addChips(recipients)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
sendMessageProgress.visibility = if (show) VISIBLE else GONE
|
binding.sendMessageProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
sendMessageContent.visibility = if (show) VISIBLE else GONE
|
binding.sendMessageContent.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
sendMessageEmpty.visibility = if (show) VISIBLE else GONE
|
binding.sendMessageEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showActionBar(show: Boolean) {
|
override fun showActionBar(show: Boolean) {
|
||||||
@ -121,11 +123,11 @@ class SendMessageActivity : BaseActivity<SendMessagePresenter>(), SendMessageVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun setSubject(subject: String) {
|
override fun setSubject(subject: String) {
|
||||||
sendMessageSubject.setText(subject)
|
binding.sendMessageSubject.setText(subject)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setContent(content: String) {
|
override fun setContent(content: String) {
|
||||||
sendMessageMessageContent.setText(content)
|
binding.sendMessageMessageContent.setText(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showMessage(text: String) {
|
override fun showMessage(text: String) {
|
||||||
@ -137,12 +139,14 @@ class SendMessageActivity : BaseActivity<SendMessagePresenter>(), SendMessageVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun hideDropdownList() {
|
override fun hideDropdownList() {
|
||||||
sendMessageTo.hideDropdownList()
|
binding.sendMessageTo.hideDropdownList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun scrollToRecipients() {
|
override fun scrollToRecipients() {
|
||||||
sendMessageScroll.post {
|
with(binding.sendMessageScroll) {
|
||||||
sendMessageScroll.scrollTo(0, sendMessageTo.bottom - dpToPx(53f).toInt())
|
post {
|
||||||
|
scrollTo(0, binding.sendMessageTo.bottom - dpToPx(53f).toInt())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,24 +157,24 @@ class SendMessageActivity : BaseActivity<SendMessagePresenter>(), SendMessageVie
|
|||||||
private fun setUpExtendedHitArea() {
|
private fun setUpExtendedHitArea() {
|
||||||
fun extendHitArea() {
|
fun extendHitArea() {
|
||||||
val containerHitRect = Rect().apply {
|
val containerHitRect = Rect().apply {
|
||||||
sendMessageContent.getHitRect(this)
|
binding.sendMessageContent.getHitRect(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
val contentHitRect = Rect().apply {
|
val contentHitRect = Rect().apply {
|
||||||
sendMessageMessageContent.getHitRect(this)
|
binding.sendMessageMessageContent.getHitRect(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
contentHitRect.top = contentHitRect.bottom
|
contentHitRect.top = contentHitRect.bottom
|
||||||
contentHitRect.bottom = containerHitRect.bottom
|
contentHitRect.bottom = containerHitRect.bottom
|
||||||
|
|
||||||
sendMessageContent.touchDelegate = TouchDelegate(contentHitRect, sendMessageMessageContent)
|
binding.sendMessageContent.touchDelegate = TouchDelegate(contentHitRect, binding.sendMessageMessageContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessageMessageContent.post {
|
with(binding.sendMessageMessageContent) {
|
||||||
sendMessageMessageContent.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
|
post {
|
||||||
|
addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> extendHitArea() }
|
||||||
extendHitArea()
|
extendHitArea()
|
||||||
}
|
}
|
||||||
extendHitArea()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,24 @@
|
|||||||
package io.github.wulkanowy.ui.modules.message.tab
|
package io.github.wulkanowy.ui.modules.message.tab
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.INVISIBLE
|
import android.view.View.INVISIBLE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Message
|
import io.github.wulkanowy.data.db.entities.Message
|
||||||
import io.github.wulkanowy.data.repositories.message.MessageFolder
|
import io.github.wulkanowy.data.repositories.message.MessageFolder
|
||||||
|
import io.github.wulkanowy.databinding.FragmentMessageTabBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.message.MessageFragment
|
import io.github.wulkanowy.ui.modules.message.MessageFragment
|
||||||
import io.github.wulkanowy.ui.modules.message.preview.MessagePreviewFragment
|
import io.github.wulkanowy.ui.modules.message.preview.MessagePreviewFragment
|
||||||
import kotlinx.android.synthetic.main.fragment_message_tab.*
|
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MessageTabFragment : BaseFragment(), MessageTabView {
|
class MessageTabFragment : BaseFragment<FragmentMessageTabBinding>(R.layout.fragment_message_tab),
|
||||||
|
MessageTabView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: MessageTabPresenter
|
lateinit var presenter: MessageTabPresenter
|
||||||
@ -42,13 +41,10 @@ class MessageTabFragment : BaseFragment(), MessageTabView {
|
|||||||
override val isViewEmpty
|
override val isViewEmpty
|
||||||
get() = tabAdapter.items.isEmpty()
|
get() = tabAdapter.items.isEmpty()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_message_tab, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentMessageTabBinding.bind(view)
|
||||||
|
messageContainer = binding.messageTabRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = messageTabRecycler
|
|
||||||
presenter.onAttachView(this, MessageFolder.valueOf(
|
presenter.onAttachView(this, MessageFolder.valueOf(
|
||||||
(savedInstanceState ?: arguments)?.getString(MESSAGE_TAB_FOLDER_ID).orEmpty()
|
(savedInstanceState ?: arguments)?.getString(MESSAGE_TAB_FOLDER_ID).orEmpty()
|
||||||
))
|
))
|
||||||
@ -57,14 +53,16 @@ class MessageTabFragment : BaseFragment(), MessageTabView {
|
|||||||
override fun initView() {
|
override fun initView() {
|
||||||
tabAdapter.onClickListener = presenter::onMessageItemSelected
|
tabAdapter.onClickListener = presenter::onMessageItemSelected
|
||||||
|
|
||||||
messageTabRecycler.run {
|
with(binding.messageTabRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = tabAdapter
|
adapter = tabAdapter
|
||||||
addItemDecoration(DividerItemDecoration(context))
|
addItemDecoration(DividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
messageTabSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
with(binding) {
|
||||||
messageTabErrorRetry.setOnClickListener { presenter.onRetry() }
|
messageTabSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||||
messageTabErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
messageTabErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
messageTabErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(data: List<Message>) {
|
override fun updateData(data: List<Message>) {
|
||||||
@ -82,31 +80,31 @@ class MessageTabFragment : BaseFragment(), MessageTabView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
messageTabProgress.visibility = if (show) VISIBLE else GONE
|
binding.messageTabProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
messageTabSwipe.isEnabled = enable
|
binding.messageTabSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
messageTabRecycler.visibility = if (show) VISIBLE else INVISIBLE
|
binding.messageTabRecycler.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
messageTabEmpty.visibility = if (show) VISIBLE else INVISIBLE
|
binding.messageTabEmpty.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
messageTabError.visibility = if (show) VISIBLE else GONE
|
binding.messageTabError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
messageTabErrorMessage.text = message
|
binding.messageTabErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showRefresh(show: Boolean) {
|
override fun showRefresh(show: Boolean) {
|
||||||
messageTabSwipe.isRefreshing = show
|
binding.messageTabSwipe.isRefreshing = show
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openMessage(message: Message) {
|
override fun openMessage(message: Message) {
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
package io.github.wulkanowy.ui.modules.mobiledevice
|
package io.github.wulkanowy.ui.modules.mobiledevice
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.view.postDelayed
|
import androidx.core.view.postDelayed
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.MobileDevice
|
import io.github.wulkanowy.data.db.entities.MobileDevice
|
||||||
|
import io.github.wulkanowy.databinding.FragmentMobileDeviceBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import io.github.wulkanowy.ui.modules.mobiledevice.token.MobileDeviceTokenDialog
|
import io.github.wulkanowy.ui.modules.mobiledevice.token.MobileDeviceTokenDialog
|
||||||
import kotlinx.android.synthetic.main.fragment_mobile_device.*
|
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MobileDeviceFragment : BaseFragment(), MobileDeviceView, MainView.TitledView {
|
class MobileDeviceFragment :
|
||||||
|
BaseFragment<FragmentMobileDeviceBinding>(R.layout.fragment_mobile_device), MobileDeviceView,
|
||||||
|
MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: MobileDevicePresenter
|
lateinit var presenter: MobileDevicePresenter
|
||||||
@ -37,29 +37,28 @@ class MobileDeviceFragment : BaseFragment(), MobileDeviceView, MainView.TitledVi
|
|||||||
override val isViewEmpty: Boolean
|
override val isViewEmpty: Boolean
|
||||||
get() = devicesAdapter.items.isEmpty()
|
get() = devicesAdapter.items.isEmpty()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_mobile_device, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentMobileDeviceBinding.bind(view)
|
||||||
|
messageContainer = binding.mobileDevicesRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = mobileDevicesRecycler
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
devicesAdapter.onDeviceUnregisterListener = presenter::onUnregisterDevice
|
devicesAdapter.onDeviceUnregisterListener = presenter::onUnregisterDevice
|
||||||
|
|
||||||
with(mobileDevicesRecycler) {
|
with(binding.mobileDevicesRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = devicesAdapter
|
adapter = devicesAdapter
|
||||||
addItemDecoration(DividerItemDecoration(context))
|
addItemDecoration(DividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
mobileDevicesSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
with(binding) {
|
||||||
mobileDevicesErrorRetry.setOnClickListener { presenter.onRetry() }
|
mobileDevicesSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||||
mobileDevicesErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
mobileDevicesErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
mobileDeviceAddButton.setOnClickListener { presenter.onRegisterDevice() }
|
mobileDevicesErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
mobileDeviceAddButton.setOnClickListener { presenter.onRegisterDevice() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(data: List<MobileDevice>) {
|
override fun updateData(data: List<MobileDevice>) {
|
||||||
@ -88,7 +87,7 @@ class MobileDeviceFragment : BaseFragment(), MobileDeviceView, MainView.TitledVi
|
|||||||
override fun showUndo(device: MobileDevice, position: Int) {
|
override fun showUndo(device: MobileDevice, position: Int) {
|
||||||
var confirmed = true
|
var confirmed = true
|
||||||
|
|
||||||
Snackbar.make(mobileDevicesRecycler, getString(R.string.mobile_device_removed), 3000)
|
Snackbar.make(binding.mobileDevicesRecycler, getString(R.string.mobile_device_removed), 3000)
|
||||||
.setAction(R.string.all_undo) {
|
.setAction(R.string.all_undo) {
|
||||||
confirmed = false
|
confirmed = false
|
||||||
presenter.onUnregisterCancelled(device, position)
|
presenter.onUnregisterCancelled(device, position)
|
||||||
@ -100,31 +99,31 @@ class MobileDeviceFragment : BaseFragment(), MobileDeviceView, MainView.TitledVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
mobileDevicesSwipe.isRefreshing = false
|
binding.mobileDevicesSwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
mobileDevicesProgress.visibility = if (show) VISIBLE else GONE
|
binding.mobileDevicesProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
mobileDevicesEmpty.visibility = if (show) VISIBLE else GONE
|
binding.mobileDevicesEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
mobileDevicesError.visibility = if (show) VISIBLE else GONE
|
binding.mobileDevicesError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
mobileDevicesErrorMessage.text = message
|
binding.mobileDevicesErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
mobileDevicesSwipe.isEnabled = enable
|
binding.mobileDevicesSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
mobileDevicesRecycler.visibility = if (show) VISIBLE else GONE
|
binding.mobileDevicesRecycler.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showTokenDialog() {
|
override fun showTokenDialog() {
|
||||||
|
@ -14,11 +14,11 @@ import android.widget.Toast
|
|||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.pojos.MobileDeviceToken
|
import io.github.wulkanowy.data.pojos.MobileDeviceToken
|
||||||
|
import io.github.wulkanowy.databinding.DialogMobileDeviceBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseDialogFragment
|
import io.github.wulkanowy.ui.base.BaseDialogFragment
|
||||||
import kotlinx.android.synthetic.main.dialog_mobile_device.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MobileDeviceTokenDialog : BaseDialogFragment(), MobileDeviceTokenVIew {
|
class MobileDeviceTokenDialog : BaseDialogFragment<DialogMobileDeviceBinding>(), MobileDeviceTokenVIew {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: MobileDeviceTokenPresenter
|
lateinit var presenter: MobileDeviceTokenPresenter
|
||||||
@ -33,7 +33,7 @@ class MobileDeviceTokenDialog : BaseDialogFragment(), MobileDeviceTokenVIew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_mobile_device, container, false)
|
return DialogMobileDeviceBinding.inflate(inflater).apply { binding = this }.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
@ -42,24 +42,24 @@ class MobileDeviceTokenDialog : BaseDialogFragment(), MobileDeviceTokenVIew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
mobileDeviceDialogClose.setOnClickListener { dismiss() }
|
binding.mobileDeviceDialogClose.setOnClickListener { dismiss() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(token: MobileDeviceToken) {
|
override fun updateData(token: MobileDeviceToken) {
|
||||||
with(mobileDeviceDialogToken) {
|
with(binding.mobileDeviceDialogToken) {
|
||||||
text = token.token
|
text = token.token
|
||||||
setOnClickListener { clickCopy(token.token) }
|
setOnClickListener { clickCopy(token.token) }
|
||||||
}
|
}
|
||||||
with(mobileDeviceDialogSymbol) {
|
with(binding.mobileDeviceDialogSymbol) {
|
||||||
text = token.symbol
|
text = token.symbol
|
||||||
setOnClickListener { clickCopy(token.symbol) }
|
setOnClickListener { clickCopy(token.symbol) }
|
||||||
}
|
}
|
||||||
with(mobileDeviceDialogPin) {
|
with(binding.mobileDeviceDialogPin) {
|
||||||
text = token.pin
|
text = token.pin
|
||||||
setOnClickListener { clickCopy(token.pin) }
|
setOnClickListener { clickCopy(token.pin) }
|
||||||
}
|
}
|
||||||
|
|
||||||
mobileDeviceQr.setImageBitmap(Base64.decode(token.qr, Base64.DEFAULT).let {
|
binding.mobileDeviceQr.setImageBitmap(Base64.decode(token.qr, Base64.DEFAULT).let {
|
||||||
BitmapFactory.decodeByteArray(it, 0, it.size)
|
BitmapFactory.decodeByteArray(it, 0, it.size)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -71,11 +71,11 @@ class MobileDeviceTokenDialog : BaseDialogFragment(), MobileDeviceTokenVIew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun hideLoading() {
|
override fun hideLoading() {
|
||||||
mobileDeviceDialogProgress.visibility = GONE
|
binding.mobileDeviceDialogProgress.visibility = GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent() {
|
override fun showContent() {
|
||||||
mobileDeviceDialogContent.visibility = VISIBLE
|
binding.mobileDeviceDialogContent.visibility = VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun closeDialog() {
|
override fun closeDialog() {
|
||||||
|
@ -2,11 +2,10 @@ package io.github.wulkanowy.ui.modules.more
|
|||||||
|
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.databinding.FragmentMoreBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.about.AboutFragment
|
import io.github.wulkanowy.ui.modules.about.AboutFragment
|
||||||
import io.github.wulkanowy.ui.modules.homework.HomeworkFragment
|
import io.github.wulkanowy.ui.modules.homework.HomeworkFragment
|
||||||
@ -19,10 +18,10 @@ import io.github.wulkanowy.ui.modules.note.NoteFragment
|
|||||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
||||||
import io.github.wulkanowy.ui.modules.settings.SettingsFragment
|
import io.github.wulkanowy.ui.modules.settings.SettingsFragment
|
||||||
import io.github.wulkanowy.utils.getCompatDrawable
|
import io.github.wulkanowy.utils.getCompatDrawable
|
||||||
import kotlinx.android.synthetic.main.fragment_more.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MoreFragment : BaseFragment(), MoreView, MainView.TitledView, MainView.MainChildView {
|
class MoreFragment : BaseFragment<FragmentMoreBinding>(R.layout.fragment_more), MoreView,
|
||||||
|
MainView.TitledView, MainView.MainChildView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: MorePresenter
|
lateinit var presenter: MorePresenter
|
||||||
@ -61,19 +60,16 @@ class MoreFragment : BaseFragment(), MoreView, MainView.TitledView, MainView.Mai
|
|||||||
override val aboutRes: Pair<String, Drawable?>?
|
override val aboutRes: Pair<String, Drawable?>?
|
||||||
get() = context?.run { getString(R.string.about_title) to getCompatDrawable(R.drawable.ic_all_about) }
|
get() = context?.run { getString(R.string.about_title) to getCompatDrawable(R.drawable.ic_all_about) }
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_more, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentMoreBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
moreAdapter.onClickListener = presenter::onItemSelected
|
moreAdapter.onClickListener = presenter::onItemSelected
|
||||||
|
|
||||||
moreRecycler.apply {
|
with(binding.moreRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = moreAdapter
|
adapter = moreAdapter
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,16 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Note
|
import io.github.wulkanowy.data.db.entities.Note
|
||||||
|
import io.github.wulkanowy.databinding.DialogNoteBinding
|
||||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
import kotlinx.android.synthetic.main.dialog_note.*
|
|
||||||
import io.github.wulkanowy.sdk.scrapper.notes.Note.CategoryType
|
import io.github.wulkanowy.sdk.scrapper.notes.Note.CategoryType
|
||||||
|
import io.github.wulkanowy.utils.lifecycleAwareVariable
|
||||||
|
|
||||||
class NoteDialog : DialogFragment() {
|
class NoteDialog : DialogFragment() {
|
||||||
|
|
||||||
|
private var binding: DialogNoteBinding by lifecycleAwareVariable()
|
||||||
|
|
||||||
private lateinit var note: Note
|
private lateinit var note: Note
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -37,19 +40,22 @@ class NoteDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_note, container, false)
|
return DialogNoteBinding.inflate(inflater).apply { binding = this }.root
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
noteDialogDate.text = note.date.toFormattedString()
|
with(binding) {
|
||||||
noteDialogCategory.text = note.category
|
noteDialogDate.text = note.date.toFormattedString()
|
||||||
noteDialogTeacher.text = note.teacher
|
noteDialogCategory.text = note.category
|
||||||
noteDialogContent.text = note.content
|
noteDialogTeacher.text = note.teacher
|
||||||
|
noteDialogContent.text = note.content
|
||||||
|
}
|
||||||
|
|
||||||
if (note.isPointsShow) {
|
if (note.isPointsShow) {
|
||||||
with(noteDialogPoints) {
|
with(binding.noteDialogPoints) {
|
||||||
text = "${if (note.points > 0) "+" else ""}${note.points}"
|
text = "${if (note.points > 0) "+" else ""}${note.points}"
|
||||||
setTextColor(when (CategoryType.getByValue(note.categoryType)) {
|
setTextColor(when (CategoryType.getByValue(note.categoryType)) {
|
||||||
CategoryType.POSITIVE -> ContextCompat.getColor(requireContext(), R.color.note_positive)
|
CategoryType.POSITIVE -> ContextCompat.getColor(requireContext(), R.color.note_positive)
|
||||||
@ -58,6 +64,7 @@ class NoteDialog : DialogFragment() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
noteDialogClose.setOnClickListener { dismiss() }
|
|
||||||
|
binding.noteDialogClose.setOnClickListener { dismiss() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
package io.github.wulkanowy.ui.modules.note
|
package io.github.wulkanowy.ui.modules.note
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Note
|
import io.github.wulkanowy.data.db.entities.Note
|
||||||
|
import io.github.wulkanowy.databinding.FragmentNoteBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import kotlinx.android.synthetic.main.fragment_note.*
|
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class NoteFragment : BaseFragment(), NoteView, MainView.TitledView {
|
class NoteFragment : BaseFragment<FragmentNoteBinding>(R.layout.fragment_note), NoteView,
|
||||||
|
MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: NotePresenter
|
lateinit var presenter: NotePresenter
|
||||||
@ -34,26 +33,25 @@ class NoteFragment : BaseFragment(), NoteView, MainView.TitledView {
|
|||||||
override val isViewEmpty: Boolean
|
override val isViewEmpty: Boolean
|
||||||
get() = noteAdapter.items.isEmpty()
|
get() = noteAdapter.items.isEmpty()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_note, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentNoteBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
noteAdapter.onClickListener = presenter::onNoteItemSelected
|
noteAdapter.onClickListener = presenter::onNoteItemSelected
|
||||||
|
|
||||||
noteRecycler.run {
|
with(binding.noteRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = noteAdapter
|
adapter = noteAdapter
|
||||||
addItemDecoration(DividerItemDecoration(context))
|
addItemDecoration(DividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
noteSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
with(binding) {
|
||||||
noteErrorRetry.setOnClickListener { presenter.onRetry() }
|
noteSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||||
noteErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
noteErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
noteErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showNoteDialog(note: Note) {
|
override fun showNoteDialog(note: Note) {
|
||||||
@ -82,31 +80,31 @@ class NoteFragment : BaseFragment(), NoteView, MainView.TitledView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
noteEmpty.visibility = if (show) VISIBLE else GONE
|
binding.noteEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
noteError.visibility = if (show) VISIBLE else GONE
|
binding.noteError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
noteErrorMessage.text = message
|
binding.noteErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
noteProgress.visibility = if (show) VISIBLE else GONE
|
binding.noteProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
noteSwipe.isEnabled = enable
|
binding.noteSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
noteRecycler.visibility = if (show) VISIBLE else GONE
|
binding.noteRecycler.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
noteSwipe.isRefreshing = false
|
binding.noteSwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package io.github.wulkanowy.ui.modules.schoolandteachers
|
package io.github.wulkanowy.ui.modules.schoolandteachers
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.INVISIBLE
|
import android.view.View.INVISIBLE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
|
import io.github.wulkanowy.databinding.FragmentSchoolandteachersBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
@ -14,10 +13,11 @@ import io.github.wulkanowy.ui.modules.schoolandteachers.school.SchoolFragment
|
|||||||
import io.github.wulkanowy.ui.modules.schoolandteachers.teacher.TeacherFragment
|
import io.github.wulkanowy.ui.modules.schoolandteachers.teacher.TeacherFragment
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import io.github.wulkanowy.utils.setOnSelectPageListener
|
import io.github.wulkanowy.utils.setOnSelectPageListener
|
||||||
import kotlinx.android.synthetic.main.fragment_schoolandteachers.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SchoolAndTeachersFragment : BaseFragment(), SchoolAndTeachersView, MainView.TitledView {
|
class SchoolAndTeachersFragment :
|
||||||
|
BaseFragment<FragmentSchoolandteachersBinding>(R.layout.fragment_schoolandteachers),
|
||||||
|
SchoolAndTeachersView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: SchoolAndTeachersPresenter
|
lateinit var presenter: SchoolAndTeachersPresenter
|
||||||
@ -31,45 +31,44 @@ class SchoolAndTeachersFragment : BaseFragment(), SchoolAndTeachersView, MainVie
|
|||||||
|
|
||||||
override val titleStringId: Int get() = R.string.schoolandteachers_title
|
override val titleStringId: Int get() = R.string.schoolandteachers_title
|
||||||
|
|
||||||
override val currentPageIndex get() = schoolandteachersViewPager.currentItem
|
override val currentPageIndex get() = binding.schoolandteachersViewPager.currentItem
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_schoolandteachers, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentSchoolandteachersBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(pagerAdapter) {
|
with(pagerAdapter) {
|
||||||
containerId = schoolandteachersViewPager.id
|
containerId = binding.schoolandteachersViewPager.id
|
||||||
addFragmentsWithTitle(mapOf(
|
addFragmentsWithTitle(mapOf(
|
||||||
SchoolFragment.newInstance() to getString(R.string.school_title),
|
SchoolFragment.newInstance() to getString(R.string.school_title),
|
||||||
TeacherFragment.newInstance() to getString(R.string.teachers_title)
|
TeacherFragment.newInstance() to getString(R.string.teachers_title)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
with(schoolandteachersViewPager) {
|
with(binding.schoolandteachersViewPager) {
|
||||||
adapter = pagerAdapter
|
adapter = pagerAdapter
|
||||||
offscreenPageLimit = 2
|
offscreenPageLimit = 2
|
||||||
setOnSelectPageListener(presenter::onPageSelected)
|
setOnSelectPageListener(presenter::onPageSelected)
|
||||||
}
|
}
|
||||||
|
|
||||||
with(schoolandteachersTabLayout) {
|
with(binding.schoolandteachersTabLayout) {
|
||||||
setupWithViewPager(schoolandteachersViewPager)
|
setupWithViewPager(binding.schoolandteachersViewPager)
|
||||||
setElevationCompat(context.dpToPx(4f))
|
setElevationCompat(context.dpToPx(4f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
schoolandteachersViewPager.visibility = if (show) VISIBLE else INVISIBLE
|
with(binding) {
|
||||||
schoolandteachersTabLayout.visibility = if (show) VISIBLE else INVISIBLE
|
schoolandteachersViewPager.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
|
schoolandteachersTabLayout.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
schoolandteachersProgress.visibility = if (show) VISIBLE else INVISIBLE
|
binding.schoolandteachersProgress.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onChildFragmentLoaded() {
|
fun onChildFragmentLoaded() {
|
||||||
|
@ -1,89 +1,89 @@
|
|||||||
package io.github.wulkanowy.ui.modules.schoolandteachers.school
|
package io.github.wulkanowy.ui.modules.schoolandteachers.school
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.School
|
import io.github.wulkanowy.data.db.entities.School
|
||||||
|
import io.github.wulkanowy.databinding.FragmentSchoolBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersChildView
|
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersChildView
|
||||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
||||||
import io.github.wulkanowy.utils.openDialer
|
import io.github.wulkanowy.utils.openDialer
|
||||||
import io.github.wulkanowy.utils.openNavigation
|
import io.github.wulkanowy.utils.openNavigation
|
||||||
import kotlinx.android.synthetic.main.fragment_school.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SchoolFragment : BaseFragment(), SchoolView, MainView.TitledView, SchoolAndTeachersChildView {
|
class SchoolFragment : BaseFragment<FragmentSchoolBinding>(R.layout.fragment_school), SchoolView,
|
||||||
|
MainView.TitledView, SchoolAndTeachersChildView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: SchoolPresenter
|
lateinit var presenter: SchoolPresenter
|
||||||
|
|
||||||
override val titleStringId get() = R.string.school_title
|
override val titleStringId get() = R.string.school_title
|
||||||
|
|
||||||
override val isViewEmpty get() = schoolName.text.isBlank()
|
override val isViewEmpty get() = binding.schoolName.text.isBlank()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance() = SchoolFragment()
|
fun newInstance() = SchoolFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_school, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentSchoolBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
schoolSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
with(binding) {
|
||||||
schoolErrorRetry.setOnClickListener { presenter.onRetry() }
|
schoolSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||||
schoolErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
schoolErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
schoolErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
|
||||||
schoolAddressButton.setOnClickListener { presenter.onAddressSelected() }
|
schoolAddressButton.setOnClickListener { presenter.onAddressSelected() }
|
||||||
schoolTelephoneButton.setOnClickListener { presenter.onTelephoneSelected() }
|
schoolTelephoneButton.setOnClickListener { presenter.onTelephoneSelected() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(data: School) {
|
override fun updateData(data: School) {
|
||||||
schoolName.text = data.name
|
with(binding) {
|
||||||
schoolAddress.text = data.address.ifBlank { "-" }
|
schoolName.text = data.name
|
||||||
schoolAddressButton.visibility = if (data.address.isNotBlank()) VISIBLE else GONE
|
schoolAddress.text = data.address.ifBlank { "-" }
|
||||||
schoolTelephone.text = data.contact.ifBlank { "-" }
|
schoolAddressButton.visibility = if (data.address.isNotBlank()) VISIBLE else GONE
|
||||||
schoolTelephoneButton.visibility = if (data.contact.isNotBlank()) VISIBLE else GONE
|
schoolTelephone.text = data.contact.ifBlank { "-" }
|
||||||
schoolHeadmaster.text = data.headmaster
|
schoolTelephoneButton.visibility = if (data.contact.isNotBlank()) VISIBLE else GONE
|
||||||
schoolPedagogue.text = data.pedagogue
|
schoolHeadmaster.text = data.headmaster
|
||||||
|
schoolPedagogue.text = data.pedagogue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
schoolEmpty.visibility = if (show) VISIBLE else GONE
|
binding.schoolEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
schoolError.visibility = if (show) VISIBLE else GONE
|
binding.schoolError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
schoolErrorMessage.text = message
|
binding.schoolErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
schoolProgress.visibility = if (show) VISIBLE else GONE
|
binding.schoolProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
schoolSwipe.isEnabled = enable
|
binding.schoolSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
schoolContent.visibility = if (show) VISIBLE else GONE
|
binding.schoolContent.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
schoolSwipe.isRefreshing = false
|
binding.schoolSwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyParentDataLoaded() {
|
override fun notifyParentDataLoaded() {
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
package io.github.wulkanowy.ui.modules.schoolandteachers.teacher
|
package io.github.wulkanowy.ui.modules.schoolandteachers.teacher
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Teacher
|
import io.github.wulkanowy.data.db.entities.Teacher
|
||||||
|
import io.github.wulkanowy.databinding.FragmentTeacherBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersChildView
|
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersChildView
|
||||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
||||||
import kotlinx.android.synthetic.main.fragment_teacher.*
|
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class TeacherFragment : BaseFragment(), TeacherView, MainView.TitledView,
|
class TeacherFragment : BaseFragment<FragmentTeacherBinding>(R.layout.fragment_teacher),
|
||||||
SchoolAndTeachersChildView {
|
TeacherView, MainView.TitledView, SchoolAndTeachersChildView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: TeacherPresenter
|
lateinit var presenter: TeacherPresenter
|
||||||
@ -38,24 +36,23 @@ class TeacherFragment : BaseFragment(), TeacherView, MainView.TitledView,
|
|||||||
override val isViewEmpty: Boolean
|
override val isViewEmpty: Boolean
|
||||||
get() = teacherAdapter.items.isEmpty()
|
get() = teacherAdapter.items.isEmpty()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_teacher, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentTeacherBinding.bind(view)
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
teacherRecycler.run {
|
with(binding.teacherRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = teacherAdapter
|
adapter = teacherAdapter
|
||||||
addItemDecoration(DividerItemDecoration(context))
|
addItemDecoration(DividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
teacherSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
with(binding) {
|
||||||
teacherErrorRetry.setOnClickListener { presenter.onRetry() }
|
teacherSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||||
teacherErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
teacherErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
teacherErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(data: List<Teacher>) {
|
override fun updateData(data: List<Teacher>) {
|
||||||
@ -66,31 +63,31 @@ class TeacherFragment : BaseFragment(), TeacherView, MainView.TitledView,
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
teacherEmpty.visibility = if (show) VISIBLE else GONE
|
binding.teacherEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
teacherError.visibility = if (show) VISIBLE else GONE
|
binding.teacherError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
teacherErrorMessage.text = message
|
binding.teacherErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
teacherProgress.visibility = if (show) VISIBLE else GONE
|
binding.teacherProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
teacherSwipe.isEnabled = enable
|
binding.teacherSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
teacherRecycler.visibility = if (show) VISIBLE else GONE
|
binding.teacherRecycler.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
teacherSwipe.isRefreshing = false
|
binding.teacherSwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyParentDataLoaded() {
|
override fun notifyParentDataLoaded() {
|
||||||
|
@ -91,19 +91,19 @@ class SettingsFragment : PreferenceFragmentCompat(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showError(text: String, error: Throwable) {
|
override fun showError(text: String, error: Throwable) {
|
||||||
(activity as? BaseActivity<*>)?.showError(text, error)
|
(activity as? BaseActivity<*, *>)?.showError(text, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showMessage(text: String) {
|
override fun showMessage(text: String) {
|
||||||
(activity as? BaseActivity<*>)?.showMessage(text)
|
(activity as? BaseActivity<*, *>)?.showMessage(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showExpiredDialog() {
|
override fun showExpiredDialog() {
|
||||||
(activity as? BaseActivity<*>)?.showExpiredDialog()
|
(activity as? BaseActivity<*, *>)?.showExpiredDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openClearLoginView() {
|
override fun openClearLoginView() {
|
||||||
(activity as? BaseActivity<*>)?.openClearLoginView()
|
(activity as? BaseActivity<*, *>)?.openClearLoginView()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorDetailsDialog(error: Throwable) {
|
override fun showErrorDetailsDialog(error: Throwable) {
|
||||||
|
@ -3,12 +3,13 @@ package io.github.wulkanowy.ui.modules.splash
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import android.widget.Toast.LENGTH_LONG
|
import android.widget.Toast.LENGTH_LONG
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseActivity
|
import io.github.wulkanowy.ui.base.BaseActivity
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SplashActivity : BaseActivity<SplashPresenter>(), SplashView {
|
class SplashActivity : BaseActivity<SplashPresenter, ViewBinding>(), SplashView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
override lateinit var presenter: SplashPresenter
|
override lateinit var presenter: SplashPresenter
|
||||||
|
@ -11,13 +11,16 @@ import android.view.ViewGroup
|
|||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Timetable
|
import io.github.wulkanowy.data.db.entities.Timetable
|
||||||
|
import io.github.wulkanowy.databinding.DialogTimetableBinding
|
||||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||||
|
import io.github.wulkanowy.utils.lifecycleAwareVariable
|
||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
import kotlinx.android.synthetic.main.dialog_timetable.*
|
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
||||||
|
|
||||||
class TimetableDialog : DialogFragment() {
|
class TimetableDialog : DialogFragment() {
|
||||||
|
|
||||||
|
private var binding: DialogTimetableBinding by lifecycleAwareVariable()
|
||||||
|
|
||||||
private lateinit var lesson: Timetable
|
private lateinit var lesson: Timetable
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -39,13 +42,13 @@ class TimetableDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_timetable, container, false)
|
return DialogTimetableBinding.inflate(inflater).apply { binding = this }.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
lesson.run {
|
with(lesson) {
|
||||||
setInfo(info, teacher, canceled, changes)
|
setInfo(info, teacher, canceled, changes)
|
||||||
setSubject(subject, subjectOld)
|
setSubject(subject, subjectOld)
|
||||||
setTeacher(teacher, teacherOld)
|
setTeacher(teacher, teacherOld)
|
||||||
@ -54,74 +57,81 @@ class TimetableDialog : DialogFragment() {
|
|||||||
setTime(start, end)
|
setTime(start, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
timetableDialogClose.setOnClickListener { dismiss() }
|
binding.timetableDialogClose.setOnClickListener { dismiss() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setSubject(subject: String, subjectOld: String) {
|
private fun setSubject(subject: String, subjectOld: String) {
|
||||||
timetableDialogSubject.text = subject
|
with(binding) {
|
||||||
if (subjectOld.isNotBlank() && subjectOld != subject) {
|
timetableDialogSubject.text = subject
|
||||||
timetableDialogSubject.run {
|
if (subjectOld.isNotBlank() && subjectOld != subject) {
|
||||||
paintFlags = paintFlags or STRIKE_THRU_TEXT_FLAG
|
timetableDialogSubject.run {
|
||||||
text = subjectOld
|
paintFlags = paintFlags or STRIKE_THRU_TEXT_FLAG
|
||||||
}
|
text = subjectOld
|
||||||
timetableDialogSubjectNew.run {
|
}
|
||||||
visibility = VISIBLE
|
timetableDialogSubjectNew.run {
|
||||||
text = subject
|
visibility = VISIBLE
|
||||||
|
text = subject
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setInfo(info: String, teacher: String, canceled: Boolean, changes: Boolean) {
|
private fun setInfo(info: String, teacher: String, canceled: Boolean, changes: Boolean) {
|
||||||
when {
|
with(binding) {
|
||||||
info.isNotBlank() -> {
|
when {
|
||||||
if (canceled) {
|
info.isNotBlank() -> {
|
||||||
timetableDialogChangesTitle.setTextColor(requireContext().getThemeAttrColor(R.attr.colorPrimary))
|
if (canceled) {
|
||||||
timetableDialogChanges.setTextColor(requireContext().getThemeAttrColor(R.attr.colorPrimary))
|
timetableDialogChangesTitle.setTextColor(requireContext().getThemeAttrColor(R.attr.colorPrimary))
|
||||||
} else {
|
timetableDialogChanges.setTextColor(requireContext().getThemeAttrColor(R.attr.colorPrimary))
|
||||||
timetableDialogChangesTitle.setTextColor(requireContext().getThemeAttrColor(R.attr.colorTimetableChange))
|
} else {
|
||||||
timetableDialogChanges.setTextColor(requireContext().getThemeAttrColor(R.attr.colorTimetableChange))
|
timetableDialogChangesTitle.setTextColor(requireContext().getThemeAttrColor(R.attr.colorTimetableChange))
|
||||||
}
|
timetableDialogChanges.setTextColor(requireContext().getThemeAttrColor(R.attr.colorTimetableChange))
|
||||||
|
}
|
||||||
|
|
||||||
timetableDialogChanges.text = when {
|
timetableDialogChanges.text = when {
|
||||||
canceled && !changes -> "Lekcja odwołana: $info"
|
canceled && !changes -> "Lekcja odwołana: $info"
|
||||||
changes && teacher.isNotBlank() -> "Zastępstwo: $teacher"
|
changes && teacher.isNotBlank() -> "Zastępstwo: $teacher"
|
||||||
changes && teacher.isBlank() -> "Zastępstwo, ${info.decapitalize()}"
|
changes && teacher.isBlank() -> "Zastępstwo, ${info.decapitalize()}"
|
||||||
else -> info.capitalize()
|
else -> info.capitalize()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
timetableDialogChangesTitle.visibility = GONE
|
||||||
|
timetableDialogChanges.visibility = GONE
|
||||||
}
|
}
|
||||||
} else -> {
|
|
||||||
timetableDialogChangesTitle.visibility = GONE
|
|
||||||
timetableDialogChanges.visibility = GONE
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setTeacher(teacher: String, teacherOld: String) {
|
private fun setTeacher(teacher: String, teacherOld: String) {
|
||||||
when {
|
with(binding) {
|
||||||
teacherOld.isNotBlank() && teacherOld != teacher -> {
|
when {
|
||||||
timetableDialogTeacher.run {
|
teacherOld.isNotBlank() && teacherOld != teacher -> {
|
||||||
visibility = VISIBLE
|
timetableDialogTeacher.run {
|
||||||
paintFlags = paintFlags or STRIKE_THRU_TEXT_FLAG
|
|
||||||
text = teacherOld
|
|
||||||
}
|
|
||||||
if (teacher.isNotBlank()) {
|
|
||||||
timetableDialogTeacherNew.run {
|
|
||||||
visibility = VISIBLE
|
visibility = VISIBLE
|
||||||
text = teacher
|
paintFlags = paintFlags or STRIKE_THRU_TEXT_FLAG
|
||||||
|
text = teacherOld
|
||||||
|
}
|
||||||
|
if (teacher.isNotBlank()) {
|
||||||
|
timetableDialogTeacherNew.run {
|
||||||
|
visibility = VISIBLE
|
||||||
|
text = teacher
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
teacher.isNotBlank() -> timetableDialogTeacher.text = teacher
|
||||||
teacher.isNotBlank() -> timetableDialogTeacher.text = teacher
|
else -> {
|
||||||
else -> {
|
timetableDialogTeacherTitle.visibility = GONE
|
||||||
timetableDialogTeacherTitle.visibility = GONE
|
timetableDialogTeacher.visibility = GONE
|
||||||
timetableDialogTeacher.visibility = GONE
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setGroup(group: String) {
|
private fun setGroup(group: String) {
|
||||||
group.let {
|
with(binding) {
|
||||||
when {
|
when {
|
||||||
it.isNotBlank() -> timetableDialogGroup.text = it
|
group.isNotBlank() -> timetableDialogGroup.text = group
|
||||||
else -> {
|
else -> {
|
||||||
timetableDialogGroupTitle.visibility = GONE
|
timetableDialogGroupTitle.visibility = GONE
|
||||||
timetableDialogGroup.visibility = GONE
|
timetableDialogGroup.visibility = GONE
|
||||||
@ -131,30 +141,32 @@ class TimetableDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setRoom(room: String, roomOld: String) {
|
private fun setRoom(room: String, roomOld: String) {
|
||||||
when {
|
with(binding) {
|
||||||
roomOld.isNotBlank() && roomOld != room -> {
|
when {
|
||||||
timetableDialogRoom.run {
|
roomOld.isNotBlank() && roomOld != room -> {
|
||||||
visibility = VISIBLE
|
timetableDialogRoom.run {
|
||||||
paintFlags = paintFlags or STRIKE_THRU_TEXT_FLAG
|
|
||||||
text = roomOld
|
|
||||||
}
|
|
||||||
if (room.isNotBlank()) {
|
|
||||||
timetableDialogRoomNew.run {
|
|
||||||
visibility = VISIBLE
|
visibility = VISIBLE
|
||||||
text = room
|
paintFlags = paintFlags or STRIKE_THRU_TEXT_FLAG
|
||||||
|
text = roomOld
|
||||||
|
}
|
||||||
|
if (room.isNotBlank()) {
|
||||||
|
timetableDialogRoomNew.run {
|
||||||
|
visibility = VISIBLE
|
||||||
|
text = room
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
room.isNotBlank() -> timetableDialogRoom.text = room
|
||||||
room.isNotBlank() -> timetableDialogRoom.text = room
|
else -> {
|
||||||
else -> {
|
timetableDialogRoomTitle.visibility = GONE
|
||||||
timetableDialogRoomTitle.visibility = GONE
|
timetableDialogRoom.visibility = GONE
|
||||||
timetableDialogRoom.visibility = GONE
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
private fun setTime(start: LocalDateTime, end: LocalDateTime) {
|
private fun setTime(start: LocalDateTime, end: LocalDateTime) {
|
||||||
timetableDialogTime.text = "${start.toFormattedString("HH:mm")} - ${end.toFormattedString("HH:mm")}"
|
binding.timetableDialogTime.text = "${start.toFormattedString("HH:mm")} - ${end.toFormattedString("HH:mm")}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,29 @@
|
|||||||
package io.github.wulkanowy.ui.modules.timetable
|
package io.github.wulkanowy.ui.modules.timetable
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
import android.view.MenuInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog
|
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Timetable
|
import io.github.wulkanowy.data.db.entities.Timetable
|
||||||
|
import io.github.wulkanowy.databinding.FragmentTimetableBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
import io.github.wulkanowy.ui.modules.timetable.completed.CompletedLessonsFragment
|
import io.github.wulkanowy.ui.modules.timetable.completed.CompletedLessonsFragment
|
||||||
|
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
||||||
import io.github.wulkanowy.utils.SchooldaysRangeLimiter
|
import io.github.wulkanowy.utils.SchooldaysRangeLimiter
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import kotlinx.android.synthetic.main.fragment_timetable.*
|
|
||||||
import org.threeten.bp.LocalDate
|
import org.threeten.bp.LocalDate
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class TimetableFragment : BaseFragment(), TimetableView, MainView.MainChildView,
|
class TimetableFragment : BaseFragment<FragmentTimetableBinding>(R.layout.fragment_timetable),
|
||||||
MainView.TitledView {
|
TimetableView, MainView.MainChildView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: TimetablePresenter
|
lateinit var presenter: TimetablePresenter
|
||||||
@ -50,34 +48,33 @@ class TimetableFragment : BaseFragment(), TimetableView, MainView.MainChildView,
|
|||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_timetable, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentTimetableBinding.bind(view)
|
||||||
|
messageContainer = binding.timetableRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = timetableRecycler
|
|
||||||
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
timetableAdapter.onClickListener = presenter::onTimetableItemSelected
|
timetableAdapter.onClickListener = presenter::onTimetableItemSelected
|
||||||
|
|
||||||
with(timetableRecycler) {
|
with(binding.timetableRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = timetableAdapter
|
adapter = timetableAdapter
|
||||||
addItemDecoration(DividerItemDecoration(context))
|
addItemDecoration(DividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
timetableSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
with(binding) {
|
||||||
timetableErrorRetry.setOnClickListener { presenter.onRetry() }
|
timetableSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||||
timetableErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
timetableErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
timetableErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
|
||||||
timetablePreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
timetablePreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||||
timetableNavDate.setOnClickListener { presenter.onPickDate() }
|
timetableNavDate.setOnClickListener { presenter.onPickDate() }
|
||||||
timetableNextButton.setOnClickListener { presenter.onNextDay() }
|
timetableNextButton.setOnClickListener { presenter.onNextDay() }
|
||||||
|
|
||||||
timetableNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
timetableNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
@ -105,15 +102,15 @@ class TimetableFragment : BaseFragment(), TimetableView, MainView.MainChildView,
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun updateNavigationDay(date: String) {
|
override fun updateNavigationDay(date: String) {
|
||||||
timetableNavDate.text = date
|
binding.timetableNavDate.text = date
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
timetableSwipe.isRefreshing = false
|
binding.timetableSwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resetView() {
|
override fun resetView() {
|
||||||
timetableRecycler.smoothScrollToPosition(0)
|
binding.timetableRecycler.smoothScrollToPosition(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFragmentReselected() {
|
override fun onFragmentReselected() {
|
||||||
@ -125,35 +122,35 @@ class TimetableFragment : BaseFragment(), TimetableView, MainView.MainChildView,
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
timetableEmpty.visibility = if (show) VISIBLE else GONE
|
binding.timetableEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
timetableError.visibility = if (show) VISIBLE else GONE
|
binding.timetableError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
timetableErrorMessage.text = message
|
binding.timetableErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showProgress(show: Boolean) {
|
override fun showProgress(show: Boolean) {
|
||||||
timetableProgress.visibility = if (show) VISIBLE else GONE
|
binding.timetableProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
timetableSwipe.isEnabled = enable
|
binding.timetableSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
timetableRecycler.visibility = if (show) VISIBLE else GONE
|
binding.timetableRecycler.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showPreButton(show: Boolean) {
|
override fun showPreButton(show: Boolean) {
|
||||||
timetablePreviousButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
binding.timetablePreviousButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showNextButton(show: Boolean) {
|
override fun showNextButton(show: Boolean) {
|
||||||
timetableNextButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
binding.timetableNextButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showTimetableDialog(lesson: Timetable) {
|
override fun showTimetableDialog(lesson: Timetable) {
|
||||||
|
@ -6,12 +6,14 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import io.github.wulkanowy.R
|
|
||||||
import io.github.wulkanowy.data.db.entities.CompletedLesson
|
import io.github.wulkanowy.data.db.entities.CompletedLesson
|
||||||
import kotlinx.android.synthetic.main.dialog_lesson_completed.*
|
import io.github.wulkanowy.databinding.DialogLessonCompletedBinding
|
||||||
|
import io.github.wulkanowy.utils.lifecycleAwareVariable
|
||||||
|
|
||||||
class CompletedLessonDialog : DialogFragment() {
|
class CompletedLessonDialog : DialogFragment() {
|
||||||
|
|
||||||
|
private var binding: DialogLessonCompletedBinding by lifecycleAwareVariable()
|
||||||
|
|
||||||
private lateinit var completedLesson: CompletedLesson
|
private lateinit var completedLesson: CompletedLesson
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -28,46 +30,54 @@ class CompletedLessonDialog : DialogFragment() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setStyle(STYLE_NO_TITLE, 0)
|
setStyle(STYLE_NO_TITLE, 0)
|
||||||
arguments?.run {
|
arguments?.run {
|
||||||
completedLesson = getSerializable(CompletedLessonDialog.ARGUMENT_KEY) as CompletedLesson
|
completedLesson = getSerializable(ARGUMENT_KEY) as CompletedLesson
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.dialog_lesson_completed, container, false)
|
return DialogLessonCompletedBinding.inflate(inflater).apply { binding = this }.root
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
completedLessonDialogSubject.text = completedLesson.subject
|
with(binding) {
|
||||||
completedLessonDialogTopic.text = completedLesson.topic
|
completedLessonDialogSubject.text = completedLesson.subject
|
||||||
completedLessonDialogTeacher.text = completedLesson.teacher
|
completedLessonDialogTopic.text = completedLesson.topic
|
||||||
completedLessonDialogAbsence.text = completedLesson.absence
|
completedLessonDialogTeacher.text = completedLesson.teacher
|
||||||
completedLessonDialogChanges.text = completedLesson.substitution
|
completedLessonDialogAbsence.text = completedLesson.absence
|
||||||
completedLessonDialogResources.text = completedLesson.resources
|
completedLessonDialogChanges.text = completedLesson.substitution
|
||||||
|
completedLessonDialogResources.text = completedLesson.resources
|
||||||
|
}
|
||||||
|
|
||||||
completedLesson.substitution.let {
|
completedLesson.substitution.let {
|
||||||
if (it.isBlank()) {
|
if (it.isBlank()) {
|
||||||
completedLessonDialogChangesTitle.visibility = View.GONE
|
with(binding) {
|
||||||
completedLessonDialogChanges.visibility = View.GONE
|
completedLessonDialogChangesTitle.visibility = View.GONE
|
||||||
} else completedLessonDialogChanges.text = it
|
completedLessonDialogChanges.visibility = View.GONE
|
||||||
|
}
|
||||||
|
} else binding.completedLessonDialogChanges.text = it
|
||||||
}
|
}
|
||||||
|
|
||||||
completedLesson.absence.let {
|
completedLesson.absence.let {
|
||||||
if (it.isBlank()) {
|
if (it.isBlank()) {
|
||||||
completedLessonDialogAbsenceTitle.visibility = View.GONE
|
with(binding) {
|
||||||
completedLessonDialogAbsence.visibility = View.GONE
|
completedLessonDialogAbsenceTitle.visibility = View.GONE
|
||||||
} else completedLessonDialogAbsence.text = it
|
completedLessonDialogAbsence.visibility = View.GONE
|
||||||
|
}
|
||||||
|
} else binding.completedLessonDialogAbsence.text = it
|
||||||
}
|
}
|
||||||
|
|
||||||
completedLesson.resources.let {
|
completedLesson.resources.let {
|
||||||
if (it.isBlank()) {
|
if (it.isBlank()) {
|
||||||
completedLessonDialogResourcesTitle.visibility = View.GONE
|
with(binding) {
|
||||||
completedLessonDialogResources.visibility = View.GONE
|
completedLessonDialogResourcesTitle.visibility = View.GONE
|
||||||
} else completedLessonDialogResources.text = it
|
completedLessonDialogResources.visibility = View.GONE
|
||||||
|
}
|
||||||
|
} else binding.completedLessonDialogResources.text = it
|
||||||
}
|
}
|
||||||
|
|
||||||
completedLessonDialogClose.setOnClickListener { dismiss() }
|
binding.completedLessonDialogClose.setOnClickListener { dismiss() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
package io.github.wulkanowy.ui.modules.timetable.completed
|
package io.github.wulkanowy.ui.modules.timetable.completed
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.INVISIBLE
|
import android.view.View.INVISIBLE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog
|
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.CompletedLesson
|
import io.github.wulkanowy.data.db.entities.CompletedLesson
|
||||||
|
import io.github.wulkanowy.databinding.FragmentTimetableCompletedBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseFragment
|
import io.github.wulkanowy.ui.base.BaseFragment
|
||||||
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.ui.widgets.DividerItemDecoration
|
||||||
import io.github.wulkanowy.utils.SchooldaysRangeLimiter
|
import io.github.wulkanowy.utils.SchooldaysRangeLimiter
|
||||||
import io.github.wulkanowy.utils.dpToPx
|
import io.github.wulkanowy.utils.dpToPx
|
||||||
import io.github.wulkanowy.utils.getCompatDrawable
|
import io.github.wulkanowy.utils.getCompatDrawable
|
||||||
import kotlinx.android.synthetic.main.fragment_timetable_completed.*
|
|
||||||
import org.threeten.bp.LocalDate
|
import org.threeten.bp.LocalDate
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CompletedLessonsFragment : BaseFragment(), CompletedLessonsView, MainView.TitledView {
|
class CompletedLessonsFragment :
|
||||||
|
BaseFragment<FragmentTimetableCompletedBinding>(R.layout.fragment_timetable_completed),
|
||||||
|
CompletedLessonsView, MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: CompletedLessonsPresenter
|
lateinit var presenter: CompletedLessonsPresenter
|
||||||
@ -40,34 +40,33 @@ class CompletedLessonsFragment : BaseFragment(), CompletedLessonsView, MainView.
|
|||||||
|
|
||||||
override val isViewEmpty get() = completedLessonsAdapter.items.isEmpty()
|
override val isViewEmpty get() = completedLessonsAdapter.items.isEmpty()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
return inflater.inflate(R.layout.fragment_timetable_completed, container, false)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
binding = FragmentTimetableCompletedBinding.bind(view)
|
||||||
|
messageContainer = binding.completedLessonsRecycler
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
messageContainer = completedLessonsRecycler
|
|
||||||
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
completedLessonsAdapter.onClickListener = presenter::onCompletedLessonsItemSelected
|
completedLessonsAdapter.onClickListener = presenter::onCompletedLessonsItemSelected
|
||||||
|
|
||||||
with(completedLessonsRecycler) {
|
with(binding.completedLessonsRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = completedLessonsAdapter
|
adapter = completedLessonsAdapter
|
||||||
addItemDecoration(DividerItemDecoration(context))
|
addItemDecoration(DividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
completedLessonsSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
with(binding) {
|
||||||
completedLessonErrorRetry.setOnClickListener { presenter.onRetry() }
|
completedLessonsSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||||
completedLessonErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
completedLessonErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||||
|
completedLessonErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||||
|
|
||||||
completedLessonsPreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
completedLessonsPreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||||
completedLessonsNavDate.setOnClickListener { presenter.onPickDate() }
|
completedLessonsNavDate.setOnClickListener { presenter.onPickDate() }
|
||||||
completedLessonsNextButton.setOnClickListener { presenter.onNextDay() }
|
completedLessonsNextButton.setOnClickListener { presenter.onNextDay() }
|
||||||
|
|
||||||
completedLessonsNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
completedLessonsNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(data: List<CompletedLesson>) {
|
override fun updateData(data: List<CompletedLesson>) {
|
||||||
@ -85,48 +84,50 @@ class CompletedLessonsFragment : BaseFragment(), CompletedLessonsView, MainView.
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun updateNavigationDay(date: String) {
|
override fun updateNavigationDay(date: String) {
|
||||||
completedLessonsNavDate.text = date
|
binding.completedLessonsNavDate.text = date
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideRefresh() {
|
override fun hideRefresh() {
|
||||||
completedLessonsSwipe.isRefreshing = false
|
binding.completedLessonsSwipe.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
completedLessonsEmpty.visibility = if (show) VISIBLE else GONE
|
binding.completedLessonsEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showErrorView(show: Boolean) {
|
override fun showErrorView(show: Boolean) {
|
||||||
completedLessonError.visibility = if (show) VISIBLE else GONE
|
binding.completedLessonError.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setErrorDetails(message: String) {
|
override fun setErrorDetails(message: String) {
|
||||||
completedLessonErrorMessage.text = message
|
binding.completedLessonErrorMessage.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showFeatureDisabled() {
|
override fun showFeatureDisabled() {
|
||||||
completedLessonsInfo.text = getString(R.string.error_feature_disabled)
|
with(binding) {
|
||||||
completedLessonsInfoImage.setImageDrawable(requireContext().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) {
|
override fun showProgress(show: Boolean) {
|
||||||
completedLessonsProgress.visibility = if (show) VISIBLE else GONE
|
binding.completedLessonsProgress.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enableSwipe(enable: Boolean) {
|
override fun enableSwipe(enable: Boolean) {
|
||||||
completedLessonsSwipe.isEnabled = enable
|
binding.completedLessonsSwipe.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showContent(show: Boolean) {
|
override fun showContent(show: Boolean) {
|
||||||
completedLessonsRecycler.visibility = if (show) VISIBLE else GONE
|
binding.completedLessonsRecycler.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showPreButton(show: Boolean) {
|
override fun showPreButton(show: Boolean) {
|
||||||
completedLessonsPreviousButton.visibility = if (show) VISIBLE else INVISIBLE
|
binding.completedLessonsPreviousButton.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showNextButton(show: Boolean) {
|
override fun showNextButton(show: Boolean) {
|
||||||
completedLessonsNextButton.visibility = if (show) VISIBLE else INVISIBLE
|
binding.completedLessonsNextButton.visibility = if (show) VISIBLE else INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showCompletedLessonDialog(completedLesson: CompletedLesson) {
|
override fun showCompletedLessonDialog(completedLesson: CompletedLesson) {
|
||||||
|
@ -11,14 +11,15 @@ import androidx.appcompat.app.AlertDialog
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
|
import io.github.wulkanowy.databinding.ActivityWidgetConfigureBinding
|
||||||
import io.github.wulkanowy.ui.base.BaseActivity
|
import io.github.wulkanowy.ui.base.BaseActivity
|
||||||
import io.github.wulkanowy.ui.base.WidgetConfigureAdapter
|
import io.github.wulkanowy.ui.base.WidgetConfigureAdapter
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||||
import io.github.wulkanowy.ui.modules.timetablewidget.TimetableWidgetProvider.Companion.EXTRA_FROM_PROVIDER
|
import io.github.wulkanowy.ui.modules.timetablewidget.TimetableWidgetProvider.Companion.EXTRA_FROM_PROVIDER
|
||||||
import kotlinx.android.synthetic.main.activity_widget_configure.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class TimetableWidgetConfigureActivity : BaseActivity<TimetableWidgetConfigurePresenter>(),
|
class TimetableWidgetConfigureActivity :
|
||||||
|
BaseActivity<TimetableWidgetConfigurePresenter, ActivityWidgetConfigureBinding>(),
|
||||||
TimetableWidgetConfigureView {
|
TimetableWidgetConfigureView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -32,7 +33,7 @@ class TimetableWidgetConfigureActivity : BaseActivity<TimetableWidgetConfigurePr
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setResult(RESULT_CANCELED)
|
setResult(RESULT_CANCELED)
|
||||||
setContentView(R.layout.activity_widget_configure)
|
setContentView(ActivityWidgetConfigureBinding.inflate(layoutInflater).apply { binding = this }.root)
|
||||||
|
|
||||||
intent.extras.let {
|
intent.extras.let {
|
||||||
presenter.onAttachView(this, it?.getInt(EXTRA_APPWIDGET_ID), it?.getBoolean(EXTRA_FROM_PROVIDER))
|
presenter.onAttachView(this, it?.getInt(EXTRA_APPWIDGET_ID), it?.getBoolean(EXTRA_FROM_PROVIDER))
|
||||||
@ -40,7 +41,7 @@ class TimetableWidgetConfigureActivity : BaseActivity<TimetableWidgetConfigurePr
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(widgetConfigureRecycler) {
|
with(binding.widgetConfigureRecycler) {
|
||||||
adapter = configureAdapter
|
adapter = configureAdapter
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.LifecycleObserver
|
||||||
|
import androidx.lifecycle.OnLifecycleEvent
|
||||||
|
import kotlin.properties.ReadWriteProperty
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
class LifecycleAwareVariable<T : Any> : ReadWriteProperty<Fragment, T>, LifecycleObserver {
|
||||||
|
|
||||||
|
private var _value: T? = null
|
||||||
|
|
||||||
|
override fun setValue(thisRef: Fragment, property: KProperty<*>, value: T) {
|
||||||
|
thisRef.viewLifecycleOwner.lifecycle.removeObserver(this)
|
||||||
|
_value = value
|
||||||
|
thisRef.viewLifecycleOwner.lifecycle.addObserver(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getValue(thisRef: Fragment, property: KProperty<*>) = _value
|
||||||
|
?: throw IllegalStateException("Trying to call an lifecycle-aware value outside of the view lifecycle, or the value has not been initialized")
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||||
|
fun onDestroyView() {
|
||||||
|
_value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LifecycleAwareVariableActivity<T : Any> : ReadWriteProperty<AppCompatActivity, T>, LifecycleObserver {
|
||||||
|
|
||||||
|
private var _value: T? = null
|
||||||
|
|
||||||
|
override fun setValue(thisRef: AppCompatActivity, property: KProperty<*>, value: T) {
|
||||||
|
thisRef.lifecycle.removeObserver(this)
|
||||||
|
_value = value
|
||||||
|
thisRef.lifecycle.addObserver(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getValue(thisRef: AppCompatActivity, property: KProperty<*>) = _value
|
||||||
|
?: throw IllegalStateException("Trying to call an lifecycle-aware value outside of the view lifecycle, or the value has not been initialized")
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||||
|
fun onDestroyView() {
|
||||||
|
_value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
fun <T : Any> Fragment.lifecycleAwareVariable() = LifecycleAwareVariable<T>()
|
||||||
|
|
||||||
|
fun <T : Any> AppCompatActivity.lifecycleAwareVariable() = LifecycleAwareVariableActivity<T>()
|
@ -1,10 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout 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_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/aboutRecycler"
|
android:id="@+id/aboutRecycler"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent"
|
||||||
|
tools:listitem="@layout/item_about" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user