forked from bilgehankalkan/showcase
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from Trendyol/ChangingLifecycleShowcaseBugFix
Changing lifecycle showcase bug fix
- Loading branch information
Showing
20 changed files
with
398 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
library/src/main/java/com/trendyol/showcase/showcase/ShowcaseLifecycleOwner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.trendyol.showcase.showcase | ||
|
||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.LifecycleEventObserver | ||
import androidx.lifecycle.LifecycleOwner | ||
|
||
class ShowcaseLifecycleOwner( | ||
private val lifecycle: Lifecycle, | ||
private val controller: ShowcaseStateController, | ||
) : LifecycleEventObserver { | ||
|
||
init { | ||
lifecycle.addObserver(this) | ||
} | ||
|
||
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) { | ||
if (source.lifecycle.currentState == Lifecycle.State.DESTROYED) { | ||
onDestroy() | ||
return | ||
} | ||
if (event == Lifecycle.Event.ON_STOP) { | ||
onDestroy() | ||
return | ||
} | ||
} | ||
|
||
private fun onDestroy() { | ||
lifecycle.removeObserver(this) | ||
controller.onStateChanged(ShowcaseState.DESTROY) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
library/src/main/java/com/trendyol/showcase/showcase/ShowcaseState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.trendyol.showcase.showcase | ||
|
||
sealed class ShowcaseState { | ||
object IDLE : ShowcaseState() | ||
object DESTROY : ShowcaseState() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
sample/src/main/java/com/trendyol/sample/MedusaLifecycleOwner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.trendyol.sample | ||
|
||
import androidx.lifecycle.LifecycleOwner | ||
import androidx.lifecycle.LifecycleRegistry | ||
|
||
class MedusaLifecycleOwner : LifecycleOwner { | ||
|
||
private val lifecycleRegistry = LifecycleRegistry(this) | ||
|
||
override fun getLifecycle(): LifecycleRegistry = lifecycleRegistry | ||
} |
8 changes: 8 additions & 0 deletions
8
sample/src/main/java/com/trendyol/sample/NavigationOperation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.trendyol.sample | ||
|
||
import com.trendyol.medusalib.navigator.Navigator | ||
|
||
interface NavigationOperation { | ||
|
||
fun operate(navigator: Navigator) | ||
} |
10 changes: 10 additions & 0 deletions
10
sample/src/main/java/com/trendyol/sample/NavigationOperationHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.trendyol.sample | ||
|
||
import com.trendyol.medusalib.navigator.Navigator | ||
|
||
class NavigationOperationHandler constructor(private val navigator: Navigator) { | ||
|
||
fun execute(navigationOperation: NavigationOperation) { | ||
navigationOperation.operate(navigator) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.trendyol.sample | ||
|
||
import androidx.fragment.app.Fragment | ||
|
||
class OneFragment : Fragment(R.layout.fragment_one){ | ||
|
||
companion object{ | ||
@JvmStatic | ||
fun newInstance() = OneFragment() | ||
} | ||
} |
Oops, something went wrong.