All Projects → adrielcafe → kaptain

adrielcafe / kaptain

Licence: MIT License
👨‍✈️ multi-module navigation on Android has never been so easier!

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to kaptain

Jcnavigator
A decoupled navigator framework of jumping between modules or apps for iOS development.
Stars: ✭ 33 (+37.5%)
Mutual labels:  module, navigation, navigator
Navigator
Android Multi-module navigator, trying to find a way to navigate into a modularized android project
Stars: ✭ 131 (+445.83%)
Mutual labels:  navigation, navigator, activity
Re Navigate
Example of React Native Navigation with re-frame/re-natal
Stars: ✭ 61 (+154.17%)
Mutual labels:  navigation, navigator
Hybrid Navigation
React Native Navigation that supports seamless navigation between Native and React.
Stars: ✭ 258 (+975%)
Mutual labels:  navigation, navigator
React Router Navigation
⛵️ A complete navigation library for React Native, React DOM and React Router
Stars: ✭ 498 (+1975%)
Mutual labels:  navigation, navigator
Scene
Android Single Activity Applications framework without Fragment.
Stars: ✭ 1,793 (+7370.83%)
Mutual labels:  navigation, activity
Native Navigation
Native navigation library for React Native applications
Stars: ✭ 3,126 (+12925%)
Mutual labels:  navigation, navigator
Androidpreferenceactivity
Provides an alternative implementation of Android's PreferenceActivity
Stars: ✭ 63 (+162.5%)
Mutual labels:  navigation, activity
React Native Navigation
A complete native navigation solution for React Native
Stars: ✭ 12,387 (+51512.5%)
Mutual labels:  navigation, navigator
navigator
Annotation processor that eliminates navigation and Bundle boilerplate
Stars: ✭ 13 (-45.83%)
Mutual labels:  navigation, activity
ktx
简化Android开发的Kotlin库
Stars: ✭ 39 (+62.5%)
Mutual labels:  activity
MockAppMVVM
A sample app structure using the MVVM architecture using Retrofit, Dagger2, LiveData, RxJava, ViewModel and Room.
Stars: ✭ 14 (-41.67%)
Mutual labels:  navigation
Object-Goal-Navigation
Pytorch code for NeurIPS-20 Paper "Object Goal Navigation using Goal-Oriented Semantic Exploration"
Stars: ✭ 107 (+345.83%)
Mutual labels:  navigation
MMM-EmbedYoutube
Embed youtube video for MagicMirror
Stars: ✭ 29 (+20.83%)
Mutual labels:  module
Site
Israel Hiking Map has maps, route planning, and travel information for Israel. This repository holds the files needed for running the Israel Hiking Map site and apps.
Stars: ✭ 52 (+116.67%)
Mutual labels:  navigation
icingaweb2-module-pnp
Integrate PNP graphs into Icinga Web 2
Stars: ✭ 32 (+33.33%)
Mutual labels:  module
LittleNavmapOFMTheme
Open Flightmaps VFR Map Theme for Little Navmap
Stars: ✭ 34 (+41.67%)
Mutual labels:  navigation
pkg-require
require node files relative to your package directory
Stars: ✭ 22 (-8.33%)
Mutual labels:  module
co2
Nous sommes passé à GitLab. Go : https://gitlab.adullact.net/pixelhumain/co2
Stars: ✭ 22 (-8.33%)
Mutual labels:  module
tsioc
AOP, Ioc container, Boot framework, unit testing framework , activities workflow framework.
Stars: ✭ 15 (-37.5%)
Mutual labels:  activity

JitPack Github Actions Android API Kotlin ktlint License MIT

Kaptain

Kaptain is a small, dependencyless and easy to use Android library that helps you to navigate between activities spread over several modules.

Usage

Given the following project structure:

/app
  MyApplication.kt
/feature-a
  FeatureAActivity.kt
/feature-b
  FeatureBActivity.kt
/feature-shared
  Destination.kt
  • app module imports all modules below
  • feature-a and feature-b imports only feature-shared
  • feature-shared imports nothing

1. Define destinations

First, you must list all possible destinations (Activities) of your app. Create a sealed class that implements the KaptainDestination interface.

Optionally, you can add arguments to your destination using a data class.

sealed class Destination : KaptainDestination {

    object FeatureA : Destination()
    data class FeatureB(val message: String) : Destination()
}

2. Create a Kaptain instance

Next, create a new Kaptain instance and associate your destinations with the corresponding Activities.

class MyApplication : Application() {
    
    val kaptain = Kaptain {
        add<Destination.FeatureA, FeatureAActivity>()
        add<Destination.FeatureB, FeatureBActivity>()
    }
}

Ideally, you should inject this instance as a singleton using a DI library. Check the sample app for an example using Koin.

3. Navigate between activities

Now you can navigate to any Activity, from any module:

class FeatureAActivity : AppCompatActivity() {

    fun goToFeatureB() {
        kaptain.navigate(
            activity = this,
            destination = Destination.FeatureB(message = "Ahoy!"),
            requestCode = 0x123 // Optional
        )
    }
}

4. Retrieve a destination content

After arrive at your destination, you can retrieve it's content:

class FeatureBActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_feature_b)

        val importantMessage = kaptain.fromIntent<Destination.FeatureB>(this)?.message
    }
}

Dynamic feature modules

Kaptain works great with dynamic features!

1. Add destinations on demand

You can add/remove destinations at any time:

kaptain.add<Destination.DynamicFeatureA, DynamicFeatureAActivity>()
kaptain.remove<Destination.DynamicFeatureB>()

2. Make sure the destination exists before navigating

if (kaptain.has<Destination.DynamicFeatureA>) {
    kaptain.navigate(this, Destination.DynamicFeatureA)
}

Import to your project

  1. Add the JitPack repository in your root build.gradle at the end of repositories:
allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
  1. Next, add the library to your module:
dependencies {
    implementation "com.github.adrielcafe.kaptain:kaptain:$currentVersion"
}

Current version: JitPack

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].