Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

An easy way to bind Toolbar into one activity with multiple fragments.

License

Notifications You must be signed in to change notification settings

OmicoArchive/ActionBarBinder

Repository files navigation

ActionBarBinder

An easy way to bind Toolbar into one activity with multiple fragments.

Usage

Maven Central

Add the ActionBarBinder dependency to your app

Kotlin
dependencies {
    implementation("me.omico.binder.actionbar:binder:<version>")
}
Groovy
dependencies {
    implementation 'me.omico.binder.actionbar:binder:<version>'
}

Refer to the following code to bind your fragment's Toolbar

Kotlin

You can follow the FirstFragment.kt just simplify add bindToolbar(Toolbar) method, and then we are all done. It will automatically unbind our Toolbar when the fragment is destroyed.

Java

It will be a little complicated in Java.

There are two ways to achieve this.

First, make your fragment extends ActionBarFragment. You can find this example in SecondFragment.java.

Or, you can fowllow the ActionBarFragment to create an FragmentActionBarBinder instance in your own fragment.

FragmentActionBarBinder binder = FragmentActionBarBinder.create(Fragment)
binder.bindToolbar(Toolbar)

For more information, please look at FragmentActionBarBinder.kt.

License

Copyright 2020 Omico

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

An easy way to bind Toolbar into one activity with multiple fragments.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages