Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
3de637c8
Commit
3de637c8
authored
Nov 13, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrade base presenter to hook exceptions by overriding only to simple methods
parent
ad925ad9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
30 deletions
+44
-30
BigantoBasePresenter.kt
...biganto/visual/roompark/conductor/BigantoBasePresenter.kt
+37
-1
ScreenController.kt
...ual/roompark/presentation/screen/auth/ScreenController.kt
+1
-4
ScreenPresenter.kt
...sual/roompark/presentation/screen/auth/ScreenPresenter.kt
+6
-24
SnackBarModule.kt
...isual/roompark/util/view_utils/snackbar/SnackBarModule.kt
+0
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/BigantoBasePresenter.kt
View file @
3de637c8
package
com.biganto.visual.roompark.conductor
package
com.biganto.visual.roompark.conductor
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.data.service.network.NoNetworkException
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.hannesdorfmann.mosby3.mvi.MviBasePresenter
import
com.hannesdorfmann.mosby3.mvi.MviBasePresenter
import
com.hannesdorfmann.mosby3.mvp.MvpView
import
com.hannesdorfmann.mosby3.mvp.MvpView
import
com.jakewharton.rxrelay2.PublishRelay
import
com.jakewharton.rxrelay2.PublishRelay
import
io.reactivex.Observable
/**
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
*/
abstract
class
BigantoBasePresenter
<
V
:
MvpView
,
VS
>
abstract
class
BigantoBasePresenter
<
V
:
MvpView
,
VS
>
:
MviBasePresenter
<
V
,
VS
>(){
:
MviBasePresenter
<
V
,
VS
>()
{
protected
val
restoreStateObservable
=
protected
val
restoreStateObservable
=
PublishRelay
.
create
<
VS
>()
PublishRelay
.
create
<
VS
>()
fun
observableParseError
(
t
:
Throwable
):
Observable
<
VS
>
=
Observable
.
defer
{
Observable
.
just
(
parseError
(
t
))
}
abstract
fun
vsByCode
(
code
:
Int
):
(
ExceptionString
)
->
VS
abstract
fun
vsByThrowable
(
t
:
Throwable
):
(
ExceptionString
)
->
VS
open
fun
parseError
(
t
:
Throwable
):
VS
=
when
(
t
)
{
is
CustomApiException
->
parseError
(
t
)
is
NoNetworkException
->
parseError
(
t
)
else
->
parseError
(
t
)
}
private
fun
parseError
(
e
:
CustomApiException
)
=
onCodeReturn
(
e
)
private
fun
parseError
(
e
:
NoNetworkException
)
=
onNoNetwork
(
e
)
private
fun
parseError
(
e
:
Exception
)
=
onRandomError
(
e
)
open
fun
onRandomError
(
t
:
Throwable
):
VS
=
vsByThrowable
(
t
).
invoke
(
ExceptionString
(
R
.
string
.
unknown_error
,
null
)
)
open
fun
onNoNetwork
(
e
:
NoNetworkException
):
VS
=
vsByThrowable
(
e
).
invoke
(
ExceptionString
(
R
.
string
.
no_network_error
,
null
)
)
private
fun
onCodeReturn
(
e
:
CustomApiException
):
VS
=
vsByCode
(
e
.
code
).
invoke
(
ExceptionString
(
e
))
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/auth/ScreenController.kt
View file @
3de637c8
...
@@ -9,7 +9,6 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController
...
@@ -9,7 +9,6 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.presentation.screen.home.home_routing.HomeBottomNavigationController
import
com.biganto.visual.roompark.presentation.screen.home.home_routing.HomeBottomNavigationController
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.RouterTransaction
import
com.google.android.material.button.MaterialButton
import
com.google.android.material.button.MaterialButton
import
com.google.android.material.snackbar.Snackbar
import
com.google.android.material.textfield.TextInputLayout
import
com.google.android.material.textfield.TextInputLayout
import
com.jakewharton.rxbinding3.view.clicks
import
com.jakewharton.rxbinding3.view.clicks
import
io.reactivex.Observable
import
io.reactivex.Observable
...
@@ -69,14 +68,12 @@ class AuthScreenController :
...
@@ -69,14 +68,12 @@ class AuthScreenController :
override
fun
render
(
viewState
:
AuthScreenViewState
)
{
override
fun
render
(
viewState
:
AuthScreenViewState
)
{
super
.
render
(
viewState
)
super
.
render
(
viewState
)
Timber
.
d
(
"Render state $viewState"
)
Timber
.
d
(
"Render state $viewState"
)
when
(
viewState
as
BaseState
){
when
(
viewState
){
is
AuthScreenViewState
.
Idle
->
render
(
viewState
)
is
AuthScreenViewState
.
Idle
->
render
(
viewState
)
is
AuthScreenViewState
.
Authorization
->
render
(
viewState
)
is
AuthScreenViewState
.
Authorization
->
render
(
viewState
)
is
AuthScreenViewState
.
SignedIn
->
render
(
viewState
)
is
AuthScreenViewState
.
SignedIn
->
render
(
viewState
)
is
AuthScreenViewState
.
SignInError
->
render
(
viewState
)
is
AuthScreenViewState
.
SignInError
->
render
(
viewState
)
is
AuthScreenViewState
.
SomeError
->
render
(
viewState
)
is
AuthScreenViewState
.
SomeError
->
render
(
viewState
)
is
BaseState
.
HandleError
->
render
(
viewState
)
}
}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/auth/ScreenPresenter.kt
View file @
3de637c8
package
com.biganto.visual.roompark.presentation.screen.auth
package
com.biganto.visual.roompark.presentation.screen.auth
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.data.service.network.NoNetworkException
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.interactor.AuthInteractor
import
com.biganto.visual.roompark.domain.interactor.AuthInteractor
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
...
@@ -21,29 +18,14 @@ class AuthScreenPresenter @Inject constructor(
...
@@ -21,29 +18,14 @@ class AuthScreenPresenter @Inject constructor(
)
)
:
BigantoBasePresenter
<
AuthScreen
,
AuthScreenViewState
>()
{
:
BigantoBasePresenter
<
AuthScreen
,
AuthScreenViewState
>()
{
private
fun
parseError
(
t
:
Throwable
):
AuthScreenViewState
=
override
fun
vsByCode
(
code
:
Int
):
(
ExceptionString
)
->
AuthScreenViewState
=
when
(
t
)
{
when
(
code
)
{
is
CustomApiException
->
onCodeReturn
(
e
=
t
)
101
->
{
e
:
ExceptionString
->
AuthScreenViewState
.
SignInError
(
e
)}
is
NoNetworkException
->
onNoNetwork
(
t
)
else
->
{
e
:
ExceptionString
->
AuthScreenViewState
.
SomeError
(
e
)}
else
->
onRandomError
(
t
)
}
private
fun
onRandomError
(
t
:
Throwable
):
AuthScreenViewState
=
AuthScreenViewState
.
SomeError
(
ExceptionString
(
R
.
string
.
unknown_error
,
null
)
)
private
fun
onNoNetwork
(
e
:
NoNetworkException
):
AuthScreenViewState
=
AuthScreenViewState
.
SomeError
(
ExceptionString
(
R
.
string
.
no_network_error
,
null
)
)
private
fun
onCodeReturn
(
e
:
CustomApiException
):
AuthScreenViewState
=
when
(
e
.
code
)
{
else
->
AuthScreenViewState
.
SignInError
(
ExceptionString
(
e
))
}
}
override
fun
vsByThrowable
(
t
:
Throwable
):
(
ExceptionString
)
->
AuthScreenViewState
=
{
e
:
ExceptionString
->
AuthScreenViewState
.
SomeError
(
e
)}
override
fun
bindIntents
()
{
override
fun
bindIntents
()
{
...
...
app/src/main/java/com/biganto/visual/roompark/util/view_utils/snackbar/SnackBarModule.kt
View file @
3de637c8
...
@@ -81,7 +81,6 @@ interface ISnackBarProvider{
...
@@ -81,7 +81,6 @@ interface ISnackBarProvider{
val
isRootBounded
:
Boolean
val
isRootBounded
:
Boolean
val
snackBar
:
Snackbar
?
val
snackBar
:
Snackbar
?
fun
showSnackBar
(
@StringRes
stringId
:
Int
)
fun
showSnackBar
(
@StringRes
stringId
:
Int
)
fun
showSnackBar
(
erorrMessage
:
Any
?)
fun
showSnackBar
(
message
:
String
)
fun
showSnackBar
(
message
:
String
)
fun
showSnackBar
(
message
:
String
,
length
:
Int
)
fun
showSnackBar
(
message
:
String
,
length
:
Int
)
fun
showSnackBar
(
message
:
String
,
type
:
SnackBarMessageType
,
length
:
Int
)
fun
showSnackBar
(
message
:
String
,
type
:
SnackBarMessageType
,
length
:
Int
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment