8000 GitHub - ma-myair/android-navigation: Navigation in android made easy
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ma-myair/android-navigation

 
 

Repository files navigation

Shapeshifter

Shapeshifter takes care of navigation through fragments in given activity reducing the boilerplate & repeating code.

Basic idea behind this library. A library with generic navigation Requests and Builders which target navigation controller of given activity. Navigation controller consumes the requests and handles the fragment transactions.

How to implement

  1. Create your SampleNavigationController by extending BaseNavigationController.

    public class SampleNavigationController extends BaseNavigationController {
          
          private final int containerId;
          private final String rootTag;
    
          public SampleNavigationController(int containerId, String rootTag) {
              this.containerId = containerId;
              this.rootTag = rootTag;
          }
    
          @Override
          protected int getContainerId() {
              return containerId;
          }
    
          @Override
          protected String getRootTag() {
              return rootTag;
          }
    
          @Override    
          protected int getFragmentTransition() {
              return TRANSIT_NONE;
          }
          
    }

    You can also implement your own custom NavigationController by implementing NavigationController.

  2. Add your SampleNavigationController to given activity

    private final NavigationController navigationController = new SampleNavigationController(R.id.frameLayout, "root_activity_root_tag");
  3. Implement IShapeshifter in your activity.

    public class RootActivity extends AppCompatActivity implements IShapeshifter {
    
          private final NavigationController navigationController = new SampleNavigationController(R.id.frameLayout, "root_activity_root_tag");
    
          @Override
          public NavigationController getNavigationController() {
              return navigationController;
          }
          
    }

    This makes the library know how to target the NavigationController of your activity.

How to use

Library currently supports forward and backward navigation.

To initialize first fragment when your activity starts:

Shapeshifter.with(this)
      .forward()
      .setFragment(CircleFragment.newInstance())
      .navigate(ForwardMode.REPLACEMENT);

To navigate to new fragment from navigation menu (pop all and replace):

Shapeshifter.with(getActivity())
      .forward()
      .setFragment(CircleFragment.newInstance())
      .navigate(ForwardMode.NEW);

To navigate to new fragment and add it to backstack:

Shapeshifter.with(getActivity())
      .forward()
      .setFragment(CircleFragment.newInstance())
      .navigate(ForwardMode.WITHOUT_REPLACEMENT);

Download

  • soon to be on jcenter :)

About

Navigation in android made easy

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%
0