Skip to content

maiconhellmann/teamwork-sample

Repository files navigation

README

Screenshots

Download apk

Teamwork sample app

Architecture

Libraries and tools included:

Requirements

  • Android SDK.
  • Kotlin 1.2.21.
  • Latest Android SDK Tools and build tools.

Architecture

This project follows ribot's Android architecture guidelines that are based on MVP (Model View Presenter). Read more about them here.

How to implement a new screen following MVP

Imagine you have to implement a sign in screen.

  1. Create a new package under ui called signin
  2. Create a new class called SignInContract. Inside SignInContract, create an interface called View extending MvPView and an abstract class called Presenter extending BasePresenter<View>.
class SignInContract{
    interface View: MvPView{
    }
    abstract class Presenter: BasePresenter < View>(){
    }
}
  1. Create a new class called SignInPresenter extending SignInContract.Presenter.
class SignInPresenter(): SignInContract.Presenter(){
}
  1. Provide dependency injection to Presenter at PresenterModule.
@Provides
@ConfigPersistent
fun provideSignInPresenter(): SignInContract.Presenter{
    return SignInPresenter()
}
  1. Create a new Activity called SignInActivity. You could also use a Fragment. You should extend BaseActivity() or BaseFragment() and your view contract definied.
class SignInActivity(): BaseActivity(), SignInContract.View {
    @Inject lateinit var presenter: SignInContract.Presenter
    
    override fun onCreate(savedInstanceState: Bundle?){
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_signin)
        activityComponent.inject(this)
        presenter.attachView(this)
    }
}
  1. Provide activity injector method at ActivityComponent or ConfigPersistentComponent for fragments.
  2. Create a SignInPresenterTest and write unit tests. Remember to mock the view and also the DataManager.

Tests

To run unit tests on your machine:

gradlew test

Release

Change you version number and version name in your app build.gradle:

versionCode 1
versionName "1.0"

To generate a new version, use the following command:

gradlew clean test assembleRelease

The apk file will be in:

trunk\app\build\outputs\apk\release\app-release.apk

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors