Coder Social home page Coder Social logo

navigationcomponentplayground-1's Introduction

Navigation Component Playground

This is a sample project where I experimented with different aspects of the Android Navigation Component.

What's implemented?

  • single Activity with Fragments
  • navigation graph in XML
  • handling of notifications (explicit deep links)
  • custom handling of implicit deep links (more on that later)
  • passing arguments between Fragments via Safe Args
  • starting Fragments for result and waiting for that result (similar to Activity's startActivityForResult and onActivityResult)
  • transitions between fragments with shared Toolbar
  • a simple Toolbar navigation icon morphing ("<-" -> "X")
  • base Dagger setup with a FragmentFactory used to create Fragments with non-default constructors

There's no MVP/MVVM/MVI here - just the Navigation Component to make the sample simple.

How does it look like?

App

Graph

What's custom in deep link handling?

Normally deep links would clear the entire back stack and start fresh. There are some differences between explicit and implicit deep links as well whether Intent.FLAG_ACTIVITY_NEW_TASK was provided or not.

In the sample app, regardless of Intent.FLAG_ACTIVITY_NEW_TASK I wanted to show the Fragment on top of the existing stack if the app was in the background or and start a new stack only if it was killed.

Also, this deep link when opened would pop specific Fragments from the back stack.

Handling Fragments results

My approach is based on Using Navigation Architecture Component in a large banking app article with some tweaks added to be able to pop the back stack further than the previous screen e.g. 2 screens back.

In the sample app this happens when e.g. we have the following stack:

Offer Fragment --> Collective login Fragment -> Login with password Fragment

Now, what we would like to do is go back to Offer Fragment and in there handle this result and e.g. start Apply Fragment.

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.