Skip to content

Commit

Permalink
Merge pull request #98 from itachi1706/dependency-update-fix
Browse files Browse the repository at this point in the history
Update Preferences Dependency to 1.2.0
  • Loading branch information
itachi1706 authored Mar 7, 2022
2 parents de48dc6 + 742a496 commit 2d3bffc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Disable. Remove if its causing issues
android.disableAutomaticComponentCreation=true
2 changes: 1 addition & 1 deletion helperlib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.preference:preference-ktx:1.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@file:Suppress("unused")
@file:Suppress("unused", "MemberVisibilityCanBePrivate")

package com.itachi1706.helperlib.concurrent

import android.content.Context
import com.itachi1706.helperlib.concurrent.Constants.Status
import com.itachi1706.helperlib.helpers.LogHelper
import kotlinx.coroutines.*
Expand All @@ -10,9 +11,9 @@ import java.util.concurrent.Executors
/**
* Replacement of AsyncTask in Kotlin Coroutine format
*/
abstract class CoroutineAsyncTask<Params, Progress, Result>(val taskName: String) {
abstract class CoroutineAsyncTask<Params, Progress, Result>(val taskName: String, val context: Context) {

val logTAG by lazy {
private val logTAG by lazy {
CoroutineAsyncTask::class.java.simpleName
}

Expand Down Expand Up @@ -63,7 +64,7 @@ abstract class CoroutineAsyncTask<Params, Progress, Result>(val taskName: String
status = Status.RUNNING

// Needs access to main thread as it can setup UI
GlobalScope.launch(Dispatchers.Main) {
CoroutineScope(Dispatchers.Main).launch {
preJob = launch(Dispatchers.Main) {
printLog("$taskName onPreExecute started")
onPreExecute()
Expand Down Expand Up @@ -93,7 +94,7 @@ abstract class CoroutineAsyncTask<Params, Progress, Result>(val taskName: String
isCancelled = true
status = Status.FINISHED
if (bgJob!!.isCompleted) {
GlobalScope.launch(Dispatchers.Main) {
CoroutineScope(Dispatchers.Main).launch {
onCancelled(bgJob!!.await())
}
}
Expand All @@ -104,7 +105,7 @@ abstract class CoroutineAsyncTask<Params, Progress, Result>(val taskName: String
}

fun publishProgress(vararg progress: Progress) {
GlobalScope.launch(Dispatchers.Main) {
CoroutineScope(Dispatchers.Main).launch {
if (!isCancelled) {
onProgressUpdate(*progress)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object PrefHelper {
* @return SharedPreference singleton object
*/
@JvmStatic
fun getDefaultSharedPreferences(context: Context?): SharedPreferences {
fun getDefaultSharedPreferences(context: Context): SharedPreferences {
val old = StrictMode.getThreadPolicy()
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder(old).permitDiskReads().build())
val sp = PreferenceManager.getDefaultSharedPreferences(context)
Expand Down

0 comments on commit 2d3bffc

Please sign in to comment.