Giter Site home page Giter Site logo

october's Introduction

October Circle CI

Apache 2.0 Android

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.

Wiki

  • 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

Show me the code:

/**
 * 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();
    }
}

Dependency

Latest stable version: Latest Version Bintray Version Maven Central

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'
}

Technologies, architectural and design patterns

References

The following projects were references in my research.

License

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.

october's People

Contributors

franriadigos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

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.