Git Product home page Git Product logo

mint-router's Introduction

Mint Router GitHub issues License

  • Router library for providing elegant way to define "Router" layer in VIPER architecture.
  • This defines a consistent way to navigate between activities and avoid calling startActivity anywhere.
  • This also implies by RouteProtocol to fulfil any pre-requisite an Activity might need.
  • Reduces boiler plate code by creating intents and calling startActivity internally.

Release

Available Version: 1.0.0 on jcenter

Library Source

Jump to library source.

Getting Started

Prerequisites

Minimum API Level is 21.

Adding the library

In your app level gradle (4.0+), add:

    implementation 'net.crystalapps:mint-router:1.0.0'

for gradle versions below 4.0 use:

    compile 'net.crystalapps:mint-router:1.0.0'

Using in your project

  • For simple route to any Activity you can call:
    Router.route( this, DetailsActivity.class);
  • For simple route with flag to finish current activity use:
    Router.route( this, DetailsActivity.class, true);
  • To customize intent which the RouteEngine is using, you can provide your own Routeable instance by implementing RouteProtocol

  • You can also add start delay, which will specify how long the activity will wait before starting, by overriding getLaunchDelay in custom Route class.

public class DetailsRouter implements RouteProtocol {


    private int delay;

    public LoginRouter(int delay) {
        this.delay = delay;
    }

    @Override
    public int getLaunchDelay() {
        return delay;
    }

    @Override
    public boolean willActivityFinish() {
        return false;
    }

    @NonNull
    @Override
    public Intent getIntent(@NonNull Context context) {
        Intent intent = new Intent(context, DetailsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        return intent;
    }
}

Then call:

    // this will use your custom configuration
    Router.route( this, new DetailsRouter(3000) );
    
 

Contributing

Contributions are welcomed as long as they dont break the code. Please create an issue and have a discussion before pull request.

Hosting

Hosted at JCenter: https://bintray.com/syedowaisali/maven/mint-router

Authors

License

This project is licensed under the Apache 2.0 License - see the LICENSE.md file for details.

Sources from Android and Android APIs are subject to the licensing terms as per Android Open Source Project (AOSP).

mint-router's People

Contributors

owais-vd avatar syedowaisali avatar talhahasanzia avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

talhahasanzia

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.