Commit 423dc854 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

need to resolve insets issue (status bar? )

parent 3dfee915
package com.biganto.visual.roompark.data.local package com.biganto.visual.roompark.data.local
import android.content.Context import android.content.Context
import com.afollestad.rxkprefs.Pref
import com.afollestad.rxkprefs.rxkPrefs import com.afollestad.rxkprefs.rxkPrefs
import com.biganto.visual.androidplayer.data.repository.local.ILocalStore import com.biganto.visual.androidplayer.data.repository.local.ILocalStore
import dagger.Binds import dagger.Binds
...@@ -28,6 +29,8 @@ class UserHolder @Inject constructor(val context : Context) : ILocalStore ...@@ -28,6 +29,8 @@ class UserHolder @Inject constructor(val context : Context) : ILocalStore
} }
private val prefs = rxkPrefs(context) private val prefs = rxkPrefs(context)
private val userSession : Pref<String> = prefs.string(RECENT_UUID_KEY, EMPTY_PREF_VALUE_KEY)
companion object { companion object {
const val RECENT_UUID_KEY = "com.biganto.visual.androidplayer.LAST_USER_UUD" const val RECENT_UUID_KEY = "com.biganto.visual.androidplayer.LAST_USER_UUD"
const val EMPTY_PREF_VALUE_KEY = "NO_ACTIVE_SESSION" const val EMPTY_PREF_VALUE_KEY = "NO_ACTIVE_SESSION"
...@@ -46,15 +49,16 @@ class UserHolder @Inject constructor(val context : Context) : ILocalStore ...@@ -46,15 +49,16 @@ class UserHolder @Inject constructor(val context : Context) : ILocalStore
.observe() .observe()
override fun recentUser(): Observable<in UserState> = override fun recentUser(): Observable<in UserState> =
prefs.string(RECENT_UUID_KEY, EMPTY_PREF_VALUE_KEY) userSession
.observe() .observe()
.map { .map {
Timber.d(" AUTH VALUE: $it")
if (it == EMPTY_PREF_VALUE_KEY) return@map UserState.NotAuthenticated() if (it == EMPTY_PREF_VALUE_KEY) return@map UserState.NotAuthenticated()
else return@map UserState.Authenticated(it) else return@map UserState.Authenticated(it)
} }
override fun setRecentUser(uuid: String?) = override fun setRecentUser(uuid: String?) =
Completable.fromObservable(prefs.string(RECENT_UUID_KEY, uuid ?: EMPTY_PREF_VALUE_KEY).observe()) Completable.fromCallable{userSession.set(uuid?:EMPTY_PREF_VALUE_KEY)}
} }
sealed class UserState{ sealed class UserState{
......
...@@ -59,7 +59,8 @@ class AuthContractModule @Inject constructor( ...@@ -59,7 +59,8 @@ class AuthContractModule @Inject constructor(
api.authenticate(email,password) api.authenticate(email,password)
.map ( ::fromRaw ) .map ( ::fromRaw )
.flatMap{ db.upsertUser(it) } .flatMap{ db.upsertUser(it) }
.doOnNext { local.setRecentUser(it.uuid.toString()) } .doOnNext{Timber.d("user id: ${it.uuid}")}
.doOnNext { local.setRecentUser(it.uuid.toString()).blockingAwait() }
.map(::fromEntity) .map(::fromEntity)
override fun validateAuthState(): Observable<Boolean> = local.recentUser() override fun validateAuthState(): Observable<Boolean> = local.recentUser()
......
...@@ -10,11 +10,8 @@ import javax.inject.Inject ...@@ -10,11 +10,8 @@ import javax.inject.Inject
class AuthUseCase @Inject constructor( class AuthUseCase @Inject constructor(
private val authContract: AuthContract private val authContract: AuthContract
){ ){
fun validateAuth() = authContract.validateAuthState() fun validateAuth() = authContract.validateAuthState()
fun signIn(login:String,pwd:String) = authContract.signIn(login,pwd) fun signIn(login:String,pwd:String) = authContract.signIn(login,pwd)
} }
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.home.home_routing package com.biganto.visual.roompark.presentation.screen.home.home_routing
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.View import android.view.View
import androidx.annotation.IdRes import androidx.annotation.IdRes
import androidx.annotation.NonNull import androidx.annotation.NonNull
...@@ -43,7 +42,7 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds) ...@@ -43,7 +42,7 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds)
} }
override fun getStartupMenuId(): Int = override fun getStartupMenuId(): Int =
args.getInt(OPEN_CHILD_CONTROLLER_KEY, R.id.tab_feeds) args.getInt(OPEN_CHILD_CONTROLLER_KEY, R.id.tab_feeds)
@Inject @Inject
...@@ -56,40 +55,34 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds) ...@@ -56,40 +55,34 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds)
override lateinit var injectedPresenter: HomeScreenPresenter override lateinit var injectedPresenter: HomeScreenPresenter
fun getComponent() = DaggerHomeScreenComponent fun getComponent() = DaggerHomeScreenComponent
.factory() .factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity) .create(RoomParkApplication.component, activity as RoomParkMainActivity)
.inject(this) .inject(this)
override fun render(viewState: HomeScreenViewState) { override fun render(viewState: HomeScreenViewState) {
when(viewState){ when (viewState) {
is HomeScreenViewState.Idle -> render(viewState) is HomeScreenViewState.Idle -> render(viewState)
is HomeScreenViewState.ToScreen -> render(viewState) is HomeScreenViewState.ToScreen -> render(viewState)
is HomeScreenViewState.SomeError -> render(viewState) is HomeScreenViewState.SomeError -> render(viewState)
} }
} }
private fun render(viewState: HomeScreenViewState.Idle){ private fun render(viewState: HomeScreenViewState.Idle) {
} }
private fun render(viewState: HomeScreenViewState.SomeError) = private fun render(viewState: HomeScreenViewState.SomeError) =
showError(viewState.exception) showError(viewState.exception)
private fun render(viewState: HomeScreenViewState.ToScreen){ private fun render(viewState: HomeScreenViewState.ToScreen) {
// snacky.showSnackBar("lul") // snacky.showSnackBar("lul")
} }
override fun getLayoutId() = R.layout.tab_routing_screen_view override fun getLayoutId() = R.layout.tab_routing_screen_view
override val tag: String override val tag: String
...@@ -100,7 +93,8 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds) ...@@ -100,7 +93,8 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds)
bottomNavigation.show() bottomNavigation.show()
Timber.d(" onViewBound: ${this::class}") Timber.d(" onViewBound: ${this::class}")
bottomNavigationView = ((activity as RoomParkMainActivity) as IBottomNavigation).bottomNavigation bottomNavigationView =
((activity as RoomParkMainActivity) as IBottomNavigation).bottomNavigation
bottomNavigationView.visibility = BottomNavigationView.VISIBLE bottomNavigationView.visibility = BottomNavigationView.VISIBLE
controllerContainer = view.findViewById(R.id.tabContainer) controllerContainer = view.findViewById(R.id.tabContainer)
bottomNavigationView.setOnNavigationItemSelectedListener { item -> bottomNavigationView.setOnNavigationItemSelectedListener { item ->
...@@ -146,19 +140,21 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds) ...@@ -146,19 +140,21 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds)
val childRouter = getChildRouter(currentlySelectedItemId) val childRouter = getChildRouter(currentlySelectedItemId)
Timber.d("in back stack - ${childRouter?.backstackSize}") Timber.d("in back stack - ${childRouter?.backstackSize}")
if (childRouter != null) { if (childRouter != null) {
val backStackSizeCondition = childRouter.backstackSize < 0
val backStackResult = childRouter.handleBack() if (childRouter.backstackSize<2) return false
if (backStackResult
&& backStackSizeCondition if (childRouter.handleBack())
)
navigateTo(getControllerFor(R.id.tab_feeds), false) navigateTo(getControllerFor(R.id.tab_feeds), false)
return backStackResult return true
} else { } else {
Log.e(TAG, "handleBack called with getChildRouter(currentlySelectedItemId) == null.", Timber.e(
IllegalStateException( IllegalStateException(
"handleBack called with getChildRouter(currentlySelectedItemId) == null.")) "handleBack called with getChildRouter(currentlySelectedItemId) == null."
),
"handleBack called with getChildRouter(currentlySelectedItemId) == null."
)
} }
return false return false
} }
......
...@@ -72,8 +72,8 @@ class SplashScreenController : ...@@ -72,8 +72,8 @@ class SplashScreenController :
private fun render(viewState: SplashScreenViewState.ToHomeScreen){ private fun render(viewState: SplashScreenViewState.ToHomeScreen){
router.setRoot(RouterTransaction.with(HomeBottomNavigationController()) router.setRoot(RouterTransaction.with(HomeBottomNavigationController())
.popChangeHandler(FadeChangeHandler()) .popChangeHandler(FadeChangeHandler(200L))
.pushChangeHandler(FadeChangeHandler()) .pushChangeHandler(FadeChangeHandler(300L))
) )
} }
......
...@@ -4,6 +4,9 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity ...@@ -4,6 +4,9 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.SplashInteractor import com.biganto.visual.roompark.domain.interactor.SplashInteractor
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.schedulers.Schedulers
import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -29,7 +32,10 @@ class SplashScreenPresenter @Inject constructor( ...@@ -29,7 +32,10 @@ class SplashScreenPresenter @Inject constructor(
if (it) SplashScreenViewState.ToHomeScreen() if (it) SplashScreenViewState.ToHomeScreen()
else SplashScreenViewState.ToAuthScreen() else SplashScreenViewState.ToAuthScreen()
} }
.delay (250, TimeUnit.MILLISECONDS)
) )
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
subscribeViewState(state.cast(SplashScreenViewState::class.java), SplashScreen::render) subscribeViewState(state.cast(SplashScreenViewState::class.java), SplashScreen::render)
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
android:id="@+id/bottom_drawer_menu" android:id="@+id/bottom_drawer_menu"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".base.RoomParkMainActivity"> tools:context=".base.RoomParkMainActivity">
...@@ -24,11 +23,11 @@ ...@@ -24,11 +23,11 @@
android:clipToPadding="true" android:clipToPadding="true"
android:theme="@style/ThemeOverlay.AppCompat.Light" android:theme="@style/ThemeOverlay.AppCompat.Light"
app:expanded="false" app:expanded="false"
app:liftOnScroll="true"
app:layout_behavior=".util.view_utils.app_bar.DragControlAppBarLayoutBehaviour" app:layout_behavior=".util.view_utils.app_bar.DragControlAppBarLayoutBehaviour"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:liftOnScroll="true"
tools:visibility="visible"> tools:visibility="visible">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
...@@ -47,9 +46,9 @@ ...@@ -47,9 +46,9 @@
android:layout_height="?android:attr/actionBarSize" android:layout_height="?android:attr/actionBarSize"
android:visibility="invisible" android:visibility="invisible"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
app:titleTextAppearance="@style/Header_TextView.Main_Header"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:showAsAction="always" app:showAsAction="always"
app:titleTextAppearance="@style/Header_TextView.Main_Header"
tools:visibility="invisible"> tools:visibility="invisible">
</androidx.appcompat.widget.Toolbar> </androidx.appcompat.widget.Toolbar>
...@@ -62,7 +61,7 @@ ...@@ -62,7 +61,7 @@
android:id="@+id/conductor_container" android:id="@+id/conductor_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" > app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<include <include
layout="@layout/test_progress_status" layout="@layout/test_progress_status"
...@@ -71,12 +70,12 @@ ...@@ -71,12 +70,12 @@
</FrameLayout> </FrameLayout>
<!-- <com.bluelinelabs.conductor.ChangeHandlerFrameLayout--> <!-- <com.bluelinelabs.conductor.ChangeHandlerFrameLayout-->
<!-- android:id="@+id/conductor_container"--> <!-- android:id="@+id/conductor_container"-->
<!-- android:layout_width="match_parent"--> <!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"--> <!-- android:layout_height="match_parent"-->
<!-- android:background="@color/colorBackground"--> <!-- android:background="@color/colorBackground"-->
<!-- app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />--> <!-- app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />-->
<!--</android.support.constraint.ConstraintLayout>--> <!--</android.support.constraint.ConstraintLayout>-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment