-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work towards controlling the lifecycle and the app tasks with…
… coroutines
- Loading branch information
1 parent
dccb8b9
commit b429166
Showing
8 changed files
with
80 additions
and
21 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
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/antonioleiva/bandhookkotlin/ui/activity/CoroutineActivity.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,24 @@ | ||
package com.antonioleiva.bandhookkotlin.ui.activity | ||
|
||
import android.support.v7.app.AppCompatActivity | ||
import com.github.finecinnamon.JobHolder | ||
import kotlinx.coroutines.experimental.Job | ||
|
||
/** | ||
* Base class for all activities that use coroutine trees for handling their lifecycle and tasks | ||
*/ | ||
abstract class CoroutineActivity : AppCompatActivity(), JobHolder { | ||
override var job: Job? = null | ||
|
||
override fun onPause() { | ||
super.onPause() | ||
|
||
job?.cancel() | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
|
||
job = Job() | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.github.finecinnamon | ||
|
||
import kotlinx.coroutines.experimental.Job | ||
|
||
/** | ||
* Represents classes that can execute tasks on a coroutine based job tree | ||
*/ | ||
interface JobHolder { | ||
val job: Job? | ||
} |