I am experience Android Developer of almost 2.5 years, who was simple writing all codes in Activity class.
Recently I came across many good things about development that will make developer life awesome.
- Retrofit
- RxJava/RxAndroid
- Dagger
- MVP pattern
- Testing code (Unit Test)
What I learned (at least to start with project)
Retrofit
RxJava/RxAndroid
Whats my confusion about MVP
There are people who follow the code style
- View (Interface)
- Presenter (Interface)
- PresenterImplementation (Class)
- Interactor (Interface)
- InteractorImplementation (Class)
But , I follow
- View (Interface)
- Presenter (Class) --- implements --> [ PresenterForView (Interface) & PresenterForInteractor (Interface) ]
- PresenterForView (Interface) -- Its works for View (eg . login button clicked in View i.e, Activity) . Takes login click from View and gives to Interactor
- PresenterForInteractor (Interface) -- Its works for Interactor (eg . gets response from Interactor like success , failure to show in View i.e, Activity) .
- Interactor (Class) : does validation logics , calls webservice (Rxjava & Retrofit used) , returns the NoNetwork,TimeOut,Failure, Success response to PresenterForInteractor
Many people say that Logics (if..else) should only be written in Interactor . Your View(Activity) , Presenter should not contain (If else statement) app logic.
There many tutorials found on Medium in which people do anything .
They write half app logic in Presenter , rest in Interactor
I tried to follow the First Option of writing every app login in Interactor
But there are scenario where I get confused where to write app login
- onActivityResult
- onRequestPermission
- using data in 2nd Activity got from 1st Actiity via Intent.putExtras (which I always use in OnCreate() of 2nd Activity)