Skip to content

Commit

Permalink
refactor: run code on every x launch renamed and added default pref k…
Browse files Browse the repository at this point in the history
…ey as an argument
  • Loading branch information
CraZyLegenD committed Feb 7, 2021
1 parent 259842a commit 3edc87f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import com.crazylegend.kotlinextensions.context.isGestureNavigationEnabled
import com.crazylegend.kotlinextensions.context.shortToast
import com.crazylegend.kotlinextensions.exhaustive
import com.crazylegend.kotlinextensions.gestureNavigation.EdgeToEdge
import com.crazylegend.kotlinextensions.internetdetector.InternetDetector
import com.crazylegend.kotlinextensions.internetdetector.InternetDetectorFlow
import com.crazylegend.kotlinextensions.log.debug
import com.crazylegend.kotlinextensions.misc.RunCodeEveryXLaunchOnAppOpened
import com.crazylegend.kotlinextensions.misc.RunCodeEveryXLaunch
import com.crazylegend.kotlinextensions.transition.stagger
import com.crazylegend.kotlinextensions.transition.utils.fadeRecyclerTransition
import com.crazylegend.kotlinextensions.views.asSearchView
Expand Down Expand Up @@ -87,7 +86,7 @@ class MainAbstractActivity : AppCompatActivity() {
}
}

RunCodeEveryXLaunchOnAppOpened.runCode(this, 2) {
RunCodeEveryXLaunch.runCode(this, 2) {
debug("TEST RUN AT 2 LAUNCHES")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import com.crazylegend.kotlinextensions.context.getSharedPreferencesByTag
/**
* Created by crazy on 8/13/20 to long live and prosper !
*/
object RunCodeEveryXLaunchOnAppOpened {
object RunCodeEveryXLaunch {

private const val prefKey = "RunCodeEveryXLaunch"
private const val defaultPrefKey = "RunCodeEveryXLaunch"
private const val launchCountPref = "launchCount"
private const val dateFirstLaunchPref = "dateFirLaunched"

fun runCode(context: Context, launchesUntilRun: Int, codeToRun: () -> Unit) {
fun runCode(context: Context, launchesUntilRun: Int, prefKey: String = defaultPrefKey, codeToRun: () -> Unit) {

val prefs = context.getSharedPreferencesByTag(prefKey)

Expand Down

0 comments on commit 3edc87f

Please sign in to comment.