Skip to content

[FragmentsHandler] Swapping bundler not working on multi window mode when device is rotated #74

Description

Prerequisite: Other Foldable Devices (ex. Samsung Fold 2)

Steps to reproduce:

  1. Open the FragmentsHandler Sample on multi window mode on other foldable devices (ex. Samsung Fold 2)
  2. Rotate the device a couple of times
  3. Change the app to cover the entire display area

Expectation: The DualStartFragment and DualEndFragment are visible

Actual: The SingleScreenFragment and DualEndFragment are visible

Cause: onActivityPreCreated lifecycle callback is called twice from time to time

Possible Solution:

// Other companion properties and functions
    private const val PRE_CREATED_CALL_DELAY = 500
// Other properties
    private var lastActivityPreCreatedTimestamp = System.currentTimeMillis() - PRE_CREATED_CALL_DELAY

    override fun onActivityPreCreated(activity: Activity, savedInstanceState: Bundle?) {
        val currentTimestamp = System.currentTimeMillis()
        if (currentTimestamp - lastActivityPreCreatedTimestamp < PRE_CREATED_CALL_DELAY) {
            super.onActivityPreCreated(activity, savedInstanceState)
            return
        }
        
        // .....
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions