package pl.droidsonroids.droidsmap

import pl.droidsonroids.droidsmap.feature.office.ui.OfficeUiGateway
import pl.droidsonroids.droidsmap.feature.room.ui.RoomUiGateway

class FlowManager(private val officeFeatureGateway: OfficeUiGateway, private val roomFeatureGateway: RoomUiGateway, terminateListener: Terminatable) {

    var currentPerspective = Perspective.OFFICE

    init {
        officeFeatureGateway.registerFlowChangeCallback(this)
        roomFeatureGateway.registerFlowChangeCallback(this)
        officeFeatureGateway.requestOffice()
    }

    fun onBackButtonPressed() {
        if (currentPerspective == Perspective.ROOM) {
            currentPerspective = Perspective.OFFICE

            roomFeatureGateway.onPerspectiveChanged(false)
            officeFeatureGateway.onPerspectiveChanged(true)
        } else {
            officeFeatureGateway.onPerspectiveChanged(false)
        }
    }
}

package pl.droidsonroids.droidsmap

import pl.droidsonroids.droidsmap.feature.office.ui.OfficeUiGateway
import pl.droidsonroids.droidsmap.feature.room.ui.RoomUiGateway

class FlowManager(private val officeFeatureGateway: OfficeUiGateway, private val roomFeatureGateway: RoomUiGateway, private val terminateListener: Terminatable) {

    var currentPerspective = Perspective.OFFICE

    init {
        officeFeatureGateway.registerFlowChangeCallback(this)
        roomFeatureGateway.registerFlowChangeCallback(this)
        officeFeatureGateway.requestOffice()
    }

    fun onBackButtonPressed() {
        if (currentPerspective == Perspective.ROOM) {
            currentPerspective = Perspective.OFFICE

            roomFeatureGateway.onPerspectiveChanged(false)
            officeFeatureGateway.onPerspectiveChanged(true)
        } else {
            officeFeatureGateway.onPerspectiveChanged(false)
            terminateListener.onTerminate()
        }
    }
}

Implement app gets terminated upon back button press in office perspective
Implement app gets terminated upon back button press in office perspective

DroidsOnRoids/DroidsMap,DroidsOnRoids/DroidsMap