Skip to content

Commit

Permalink
fix gradle build library
Browse files Browse the repository at this point in the history
  • Loading branch information
ThuanPx committed Sep 15, 2021
1 parent b454357 commit f7fa034
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 47 deletions.
4 changes: 1 addition & 3 deletions KtExt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.0"
implementation "androidx.appcompat:appcompat:1.3.0"
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha02"
implementation "androidx.appcompat:appcompat:1.3.1"
}
22 changes: 0 additions & 22 deletions KtExt/src/main/java/com/thuanpx/ktext/context/ActivityExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,15 @@ import androidx.annotation.NonNull
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.thuanpx.ktext.AnimationType
import com.thuanpx.ktext.Constant
import com.thuanpx.ktext.SLIDE_TO_LEFT
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch
import kotlin.reflect.KClass

/**
* Created by ThuanPx on 3/15/20.
*/

/**
* Launches a new coroutine and repeats `block` every time the Activity's viewLifecycleOwner
* is in and out of `minActiveState` lifecycle state.
* Source: https://medium.com/androiddevelopers/repeatonlifecycle-api-design-story-8670d1a7d333
*/
inline fun FragmentActivity.launchAndRepeatWithViewLifecycle(
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
crossinline block: suspend CoroutineScope.() -> Unit
) {
this.lifecycleScope.launch {
this@launchAndRepeatWithViewLifecycle.lifecycle.repeatOnLifecycle(minActiveState) {
block()
}
}
}

fun <T : Activity> FragmentActivity.goTo(
cls: KClass<T>,
Expand Down
20 changes: 0 additions & 20 deletions KtExt/src/main/java/com/thuanpx/ktext/context/FragmentExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,12 @@ import androidx.annotation.IdRes
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.thuanpx.ktext.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

/**
* Created by ThuanPx on 3/15/20.
*/

/**
* Launches a new coroutine and repeats `block` every time the Fragment's viewLifecycleOwner
* is in and out of `minActiveState` lifecycle state.*
* Source: https://medium.com/androiddevelopers/repeatonlifecycle-api-design-story-8670d1a7d333
*/
inline fun Fragment.launchAndRepeatWithViewLifecycle(
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
crossinline block: suspend CoroutineScope.() -> Unit
) {
viewLifecycleOwner.lifecycleScope.launch {
viewLifecycleOwner.lifecycle.repeatOnLifecycle(minActiveState) {
block()
}
}
}

fun Fragment.replaceFragment(
@IdRes containerId: Int,
Expand Down
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.0"
implementation "androidx.appcompat:appcompat:1.3.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha02"
implementation "androidx.appcompat:appcompat:1.3.1"
implementation project(':KtExt')
}

0 comments on commit f7fa034

Please sign in to comment.