GithubHelp home page GithubHelp logo

morristech / backstack_bottomnavigation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gitelitenovice/backstack_bottomnavigation

0.0 1.0 0.0 692 KB

A library that helps you, handling fragment Backstack like Piece of cake in Kotlin

Kotlin 65.04% Java 34.96%

backstack_bottomnavigation's Introduction

Bottomnavlibrary v1.01

API Android Arsenal Twitter URL Maintenance Ask Me Anything ! PRs Welcome ForTheBadge built-with-love

How this is helpful for you?

With the help of this library , handling fragment will be Piece of cake for you. This library helps you to keeps history of previous tabs so that when the current tab's stack is exhausted the system back button will navigate to the previously selected tab. If you want to switch between fragments with botttomnavigation view, without losing fragments state and along with if you want to maintain backstack of fragments. Then this library is for you.

**Note:-This example handles backstack and even app restores when after killed by Android System, all backstacks are preserved.

If you want to say thanks or want to share how much you like my efforts, then you can share it with me with Say Thanks!

Webp net-resizeimage Webp net-resizeimage (1) Webp net-resizeimage (2)

Includle this library in your project

For Gradle

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
         implementation 'com.github.GitEliteNovice:BackStack_BottomNavigation:v1.01'
}

For Maven

       <repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

Step 2. Add the dependency

<dependency>
   <groupId>com.github.GitEliteNovice</groupId>
    <artifactId>BackStack_BottomNavigation</artifactId>
    <version>v1.01</version>
</dependency>

For implementation

Make instance of Library like this

 fragmentStackNew= com.aryan.bottomnavlibrary.FragmentStackNew.Builder()
                     .bottomMaxCount(3)                      // bottom tabs you have 
                     .conatiner_id(R.id.frag_container)     // container id when you want add fragments	  	         
		 .lastFragmentToStay(HomeFragment::class.java).   // last fragment to reach when all fragment removed from backstack
                     .build(this)            

 fragmentStackNew.updateFrag(HomeFragment::class.java,null).       // add fragment to show 

If you want to send extra data to fragment, you can do something like this

 bundle= Bundle()
 bundle.putString("Name","Aryan")
 bundle.putInt("Age",27)
   	    
 fragmentStackNew.updateFrag(HomeFragment::class.java,bundle).    // send extra data to fragment

If you want to handle state even when the activity kills by andoid os

 override fun onSaveInstanceState(outState: Bundle) {
     var outStatenew=  fragmentStackNew.setOutstatebundle(outState).    // add oustate bundle to library instance
      super.onSaveInstanceState(outStatenew)
   }

Inside onCreate method, do something like this

if (savedInstanceState==null){

 fragmentStackNew= com.aryan.bottomnavlibrary.FragmentStackNew.Builder()
                       .bottomMaxCount(3)
                       .conatiner_id(R.id.frag_container).
                        lastFragmentToStay(HomeFragment::class.java)
                         .build(this)

       bundle.putString("Name","Aryan")
       bundle.putInt("Age",27)
  
   fragmentStackNew.updateFrag(HomeFragment::class.java,bundle)
  
   }
else
  {

fragmentStackNew= com.aryan.bottomnavlibrary.FragmentStackNew.Builder()
    .bottomMaxCount(3)
    .conatiner_id(R.id.frag_container).
    lastFragmentToStay(HomeFragment::class.java)
    .build(this)
         
fragmentStackNew.savedInstanceState(savedInstanceState)

   }

This example includes following things

  • BottomNavLibrary
  • BottomNavigationView


Android library to keeps a history of previous tabs

Built with ❤︎ by Aryan Dhankar.

Connect With Me

Aryan Dhankar (Elite Novice) I love making new friends, please feel free to connect with me.

Connect me on Google+ Connect me on Facebook Connect me on LinkedIn

Question / Contact Me

Please feel free to ping me at [email protected].

backstack_bottomnavigation's People

Contributors

gitelitenovice avatar

Watchers

 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.