Android Framework that aims to provide a quick way to implement Clean Architecture.
Some features:
- Safe Model View Presenter architecture following standard Android lifecycle.
- Fast and automatic dependency injection using Dagger 2.
- Provides some Repository Strategy sources.
- Error handling interface for latest Retrofit version.
- Getting started
- Working with Fragments
- UseCases, Repository and Cache
- Working with Retrofit
- Handling Exceptions
- Providing objects with October Scopes (Dagger)
- Dealing with Realm
- Unit Testing
- Espresso Testing
/**
* Presenters respect the Android lifecycle and convention methods.
* Common lifecycle Activity methods are going to be delegated on the Presenter by October.
*/
@PerActivity // Per Activity scope
public class SamplePresenter extends OctoberPresenter<ISampleView>
implements ISamplePresenter<ISampleView> {
@Inject
SampleUseCase sampleUseCase;
@Inject
public SamplePresenter() {}
@Override
public void onCreate() {
super.onCreate();
// Setup Loading Dialog by default
attachLoading(sampleUseCase); // (see wikis)
}
@Override
public void onViewCreated() {
super.onViewCreated();
// Start loading some data
sampleUseCase
.asObservable()
.compose(bindToLifecycle())
.subscribe(new SampleSubscriber())
}
class SampleSubscriber extends OctoberSubscriber<Object> {
@Override
public void onError(OctoberException e) {
e.printStackTrace();
getView().showError(e.getCause().getMessage());
}
@Override
public void onNext(Object data) {
getView().render(data)
}
}
}
/**
* October will attach and detach automatically your presenter and view respectively.
* It is only needed to provide the Presenter interface as a parameterized type.
*/
@ActivityComponent // Automatic Dagger component injection
public class SampleActivity extends OctoberCompatActivity<ISamplePresenter>
implements ISampleView {
// October binds Butterknife automatically
@Bind(R.id.sample_textview) TextView sampleTextView;
// You don't need to initialize any Dagger Component here in order to inject
// Just remember to annotate you class with @ActivityComponent or @FragmentComponent
@Inject
Navigator navigator;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_sample);
}
@OnClick(R.id.sample_button)
public void onClick(View view) {
getPresenter().onSampleButtonClicked();
}
}
In order to work with Dagger 2 and benefits from automatic dependency injection of October, you need to apply the android-apt gradle plugin to run annotation processing.
If you are working with gradle, add the dependency to your build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'
dependencies{
compile 'com.kuassivi.october:october:x.y.z'
apt 'com.kuassivi.october:october-compiler:x.y.z'
}
If you are following your own Clean Architecture design or you just need to access October features from a Java module, use the following dependency in your gradle java module:
dependencies{
compile 'com.kuassivi.october:october-core:x.y.z'
}
- Model View Presenter
- Repository
- Interactor UseCases
- RxJava
- RxLifecycle
- Dagger2
- Butterknife
- Cache
- Realm
The following projects were references in my research.
Copyright (C) 2015 Francisco Gonzalez-Armijo Riádigos
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.