Git Product home page Git Product logo

androidjobdemo's Introduction

Android Job Example

This is a sample project based on the @adavis tutorial Background Work with Android Job and Dagger tutorial here

Acknowledges

  • This sample project aims to show a clock with the time of the device's local time zone
  • It schedules a job each 15 minutes which will show an App Notification with the last time it was saved
  • It was developed using Kotlin language, coroutines for async task running, Evernote Android Job and Dagger as stated on the tutorial
  • The project structure is divided into packages. It uses a MVP architecture with one entity (Main)
  • Dagger2 Dependency Injection classes are in di package.
  • JobCreator file is in core.job package
  • Job definition is in notification package.
  • AppModule provides the application object, the application context object and the SharedPreferences instance.
  • JobModule provides the JobManager instance and the Job instance of ShowNotificationJob class.
  • On the JobCreator onRun method, it was injected a lateinit var of the job instead of a Map<String, Provider>, due to the fact that it was throwing an Exception when Building the project regarding to the Map. Cannot be provided without an @Provides- or @Produces-annotated method. [FIXED]

Update

  • Last Exception reported was fixed thanks to @adavis as she reply to me regarding the issue 1 of this project. App runs perfectly!

License

MIT

Please contact me by mail for either comments, doubts or any suggestions you might have.

androidjobdemo's People

Contributors

jairaviles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

androidjobdemo's Issues

Error when injecting Job Provider Map

So, I did change the dependency Map into App Job Creator. It is now as:

@Singleton
class AppJobCreator
    @Inject constructor(): JobCreator {

    @Inject
    lateinit var jobs: Map<String, Provider<Job>>

    override fun create(tag: String): Job? {
        val jobProvider = jobs[tag]
        return jobProvider?.get()
    }

}

After cleaning an building again, it now shows the following on building exception regarding Dagger2 dependency injection. What could you suggest? Sorry but I am quite new also with Dagger2. That being said I think I'm getting confused.

Error:(9, 2) error: [dagger.android.AndroidInjector.inject(T)] java.util.Map<java.lang.String,? 
extends javax.inject.Provider<com.evernote.android.job.Job>> cannot be provided without an 
@Provides-annotated method.
public abstract interface AppComponent {
                ^
      java.util.Map<java.lang.String,? extends 
javax.inject.Provider<com.evernote.android.job.Job>> is injected at
          mx.jairaviles.androidevernotejobexample.core.job.AppJobCreator.jobs
      mx.jairaviles.androidevernotejobexample.core.job.AppJobCreator is injected at
          mx.jairaviles.androidevernotejobexample.di.module.JobsModule.provideJobManager(…, 
appJobCreator)
      com.evernote.android.job.JobManager is injected at
          mx.jairaviles.androidevernotejobexample.main.MainPresenter.<init>(…, mJobManager)
      mx.jairaviles.androidevernotejobexample.main.MainPresenter is injected at
          mx.jairaviles.androidevernotejobexample.main.MainActivity.presenter
      mx.jairaviles.androidevernotejobexample.main.MainActivity is injected at
          dagger.android.AndroidInjector.inject(arg0)

Does not run the scheduler in background after closing app

Your codes are great but its having one major issue. When you close the app, the rescheduling of job fails. The only solution is to execute JobManager.ceate() from Application.onCreate(). Do update me when you have a fix for this. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.