platform API License Maven Central Android Arsenal

Asyncer (Backgrounnd Task Manager Library)

  • It let you do your task in background thread with callback of completion or failure.
  • It is Light weight, super easy to implement (See Example)
  • It is based on android’s modern Architecture: Coroutine

How to use this library,

  1. Add it in your setting.gradle in project view:

  pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        (maven { url 'https://jitpack.io' })
    }
}
rootProject.name = "devcomm"
include ':app'
  1. Add the dependency in app level build.gradle:

  dependencies {
	  implementation 'com.github.DevComm-in:Asyncer:v1.0.0'
  }

Example Use Case:

class MainActivity : AppCompatActivity() {

    // start btn
    private lateinit var btn : Button
    
    //progressbar
    private lateinit var progressBar: ProgressBar

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        btn = findViewById(R.id.btn)
        progressBar = findViewById(R.id.progress_bar)


        btn.setOnClickListener{
            onClick()
        }

    }


    //when start btn is clicked
    private fun onClick(){
    
        //sowing indicator that background task is started
        progressBar.visibility = View.VISIBLE
        
        Asyncer().init(object : Task {
        
            //your background task
            override fun backgroundTask() {
                for(i in 1..100000){
                    Log.d("count", "backgroundTask: $i")
                }
            }

            /** what do you wanna do when task is cmpleted
            *   I am turning off progressBar and toasting a message 
            */
            override fun onTaskCompletion() {
                progressBar.visibility = View.GONE
                Toast.makeText(this@MainActivity, "Done", Toast.LENGTH_SHORT).show()
                Log.d("TAG", "onTaskCompletion")
            }
        })
    }

}

Contributing

Contributions are always welcome! See contributing.md for ways to get started.

Please adhere to this project’s code of conduct.

GitHub

View Github