MCPcopy Index your code
hub / github.com/bluelinelabs/Conductor

github.com/bluelinelabs/Conductor @3.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 3.2.0 ↗ · + Follow
1,205 symbols 3,504 edges 103 files 147 documented · 12%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

GitHub Actions Workflow Android Arsenal Javadocs

Conductor

A small, yet full-featured framework that allows building View-based Android applications. Conductor provides a light-weight wrapper around standard Android Views that does just about everything you'd want:

Conductor
:tada: Easy integration
:point_up: Single Activity apps without using Fragments
:recycle: Simple but powerful lifecycle management
:train: Navigation and backstack handling
:twisted_rightwards_arrows: Beautiful transitions between views
:floppy_disk: State persistence
:phone: Callbacks for onActivityResult, onRequestPermissionsResult, etc
:european_post_office: MVP / MVVM / MVI / VIPER / MVC ready

Conductor is architecture-agnostic and does not try to force any design decisions on the developer. We here at BlueLine Labs tend to use either MVP or MVVM, but it would work equally well with standard MVC or whatever else you want to throw at it.

Installation

def conductorVersion = '3.2.0'

implementation "com.bluelinelabs:conductor:$conductorVersion"

// AndroidX Transition change handlers:
implementation "com.bluelinelabs:conductor-androidx-transition:$conductorVersion"

// ViewPager PagerAdapter:
implementation "com.bluelinelabs:conductor-viewpager:$conductorVersion"

// ViewPager2 Adapter:
implementation "com.bluelinelabs:conductor-viewpager2:$conductorVersion"

// RxJava2 Autodispose support:
implementation "com.bluelinelabs:conductor-autodispose:$conductorVersion"

// Lifecycle-aware Controllers (architecture components):
implementation "com.bluelinelabs:conductor-archlifecycle:$conductorVersion"

SNAPSHOT

Just use 3.2.1-SNAPSHOT as your version number in any of the dependencies above and add the url to the snapshot repository:

allprojects {
  repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  }
}

Components to Know

Conductor Components
Controller The Controller is the View wrapper that will give you all of your lifecycle management features. Think of it as a lighter-weight and more predictable Fragment alternative with an easier to manage lifecycle.
Router A Router implements navigation and backstack handling for Controllers. Router objects are attached to Activity/containing ViewGroup pairs. Routers do not directly render or push Views to the container ViewGroup, but instead defer this responsibility to the ControllerChangeHandler specified in a given transaction.
ControllerChangeHandler ControllerChangeHandlers are responsible for swapping the View for one Controller to the View of another. They can be useful for performing animations and transitions between Controllers. Several default ControllerChangeHandlers are included.
RouterTransaction Transactions are used to define data about adding Controllers. RouterTransactions are used to push a Controller to a Router with specified ControllerChangeHandlers, while ChildControllerTransactions are used to add child Controllers.

Getting Started

Minimal Activity implementation

public class MainActivity extends Activity {

    private Router router;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        ViewGroup container = (ViewGroup) findViewById(R.id.controller_container);

        router = Conductor.attachRouter(this, container, savedInstanceState)
            .setPopRootControllerMode(PopRootControllerMode.NEVER);
        if (!router.hasRootController()) {
            router.setRoot(RouterTransaction.with(new HomeController()));
        }
    }

    @Override
    public void onBackPressed() {
        if (!router.handleBack()) {
            super.onBackPressed();
        }
    }

}

Minimal Controller implementation

public class HomeController extends Controller {

    @Override
    protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable Bundle savedViewState) {
        View view = inflater.inflate(R.layout.controller_home, container, false);
        ((TextView) view.findViewById(R.id.tv_title)).setText("Hello World");
        return view;
    }

}

Sample Project

Demo app - Shows how to use all basic and most advanced functions of Conductor.

Controller Lifecycle

The lifecycle of a Controller is significantly simpler to understand than that of a Fragment. A lifecycle diagram is shown below:

Controller Lifecycle

Advanced Topics

Retain View Modes

setRetainViewMode can be called on a Controller with one of two values: RELEASE_DETACH, which will release the Controller's view as soon as it is detached from the screen (saves memory), or RETAIN_DETACH, which will ensure that a Controller holds on to its view, even if it's not currently shown on the screen (good for views that are expensive to re-create).

Custom Change Handlers

ControllerChangeHandler can be subclassed in order to perform different functions when changing between two Controllers. Two convenience ControllerChangeHandler subclasses are included to cover most basic needs: AnimatorChangeHandler, which will use an Animator object to transition between two views, and TransitionChangeHandler, which will use Lollipop's Transition framework for transitioning between views.

Child Routers & Controllers

getChildRouter can be called on a Controller in order to get a nested Router into which child Controllers can be pushed. This enables creating advanced layouts, such as Master/Detail.

RxJava Lifecycle

If the AutoDispose dependency has been added, there is a ControllerScopeProvider available that can be used along with the standard AutoDispose library.

Community Projects

The community has provided several helpful modules to make developing apps with Conductor even easier. Here's a collection of helpful libraries:

License

Copyright 2020 BlueLine Labs, Inc.

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.

Extension points exported contracts — how you extend this code

ControllerChangeCompletedListener (Interface)
A simplified listener for being notified when the change is complete. This MUST be called by any custom ControllerChange [2 …
conductor/src/main/java/com/bluelinelabs/conductor/ControllerChangeHandler.java
OnTransitionPreparedListener (Interface)
(no doc) [2 implementers]
conductor-modules/androidx-transition/src/main/java/com/bluelinelabs/conductor/changehandler/androidxtransition/TransitionChangeHandler.java
ToolbarProvider (Interface)
(no doc)
demo/src/main/java/com/bluelinelabs/conductor/demo/ToolbarProvider.kt
ControllerChangeListener (Interface)
A listener interface useful for allowing external classes to be notified of change events. [1 implementers]
conductor/src/main/java/com/bluelinelabs/conductor/ControllerChangeHandler.java
TargetTitleEntryControllerListener (Interface)
(no doc)
demo/src/main/java/com/bluelinelabs/conductor/demo/controllers/TargetTitleEntryController.kt
ViewAttachListener (Interface)
(no doc) [3 implementers]
conductor/src/main/java/com/bluelinelabs/conductor/internal/ViewAttachHandler.java
RouterRequiringFunc (Interface)
(no doc)
conductor/src/main/java/com/bluelinelabs/conductor/internal/RouterRequiringFunc.kt

Core symbols most depended-on inside this repo

pushController
called by 132
conductor/src/main/java/com/bluelinelabs/conductor/Router.java
setRoot
called by 54
conductor/src/main/java/com/bluelinelabs/conductor/Router.java
with
called by 44
conductor/src/main/java/com/bluelinelabs/conductor/RouterTransaction.kt
pushChangeHandler
called by 43
conductor/src/main/java/com/bluelinelabs/conductor/RouterTransaction.kt
getView
called by 35
conductor/src/main/java/com/bluelinelabs/conductor/Controller.java
popChangeHandler
called by 32
conductor/src/main/java/com/bluelinelabs/conductor/RouterTransaction.kt
getChildRouter
called by 29
conductor/src/main/java/com/bluelinelabs/conductor/Controller.java
getRouter
called by 28
conductor/src/main/java/com/bluelinelabs/conductor/Controller.java

Shape

Method 1,045
Class 141
Interface 8
Function 6
Enum 5

Languages

Java62%
Kotlin38%

Modules by API surface

conductor/src/main/java/com/bluelinelabs/conductor/Controller.java120 symbols
conductor/src/main/java/com/bluelinelabs/conductor/Router.java71 symbols
conductor-modules/androidx-transition/src/main/java/com/bluelinelabs/conductor/changehandler/androidxtransition/SharedElementTransitionChangeHandler.java48 symbols
conductor/src/main/java/com/bluelinelabs/conductor/internal/LifecycleHandler.java41 symbols
demo/src/main/java/com/bluelinelabs/conductor/demo/util/AnimUtils.java40 symbols
conductor/src/test/java/com/bluelinelabs/conductor/ControllerLifecycleCallbacksTests.kt40 symbols
conductor/src/test/java/com/bluelinelabs/conductor/ControllerTests.kt32 symbols
conductor/src/main/java/com/bluelinelabs/conductor/ControllerHostedRouter.java29 symbols
conductor/src/main/java/com/bluelinelabs/conductor/internal/OwnViewTreeLifecycleAndRegistry.kt28 symbols
conductor/src/main/java/com/bluelinelabs/conductor/ControllerChangeHandler.java28 symbols
conductor-modules/viewpager2/src/main/java/com/bluelinelabs/conductor/viewpager2/RouterStateAdapter.kt24 symbols
conductor/src/test/java/com/bluelinelabs/conductor/RouterTests.kt21 symbols

For agents

$ claude mcp add Conductor \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact